Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safety: only run rx hooks on whitelisted msgs #1903

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Mar 3, 2025

#1851 but for rx

catches a few missing rx checks:

FAILED test_models.py::TestCarModel_14_CHEVROLET_BOLT_EUV::test_panda_safety_carstate@CarTestRoute(route='f08912a233c1584f|2022-08-11--18-02-41', car_model=<CAR.CHEVROLET_BOLT_EUV>, segment=1) - AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'regenBraking': 312}
FAILED test_models.py::TestCarModel_20_CHEVROLET_VOLT::test_panda_safety_carstate@CarTestRoute(route='c950e28c26b5b168|2018-05-30--22-03-41', car_model=<CAR.CHEVROLET_VOLT>, segment=None) - AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'regenBraking': 30}
FAILED test_models.py::TestCarModel_43_GENESIS_GV60_EV_1ST_GEN::test_panda_safety_carstate@CarTestRoute(route='b5d6dc830ad63071|2022-12-12--21-28-25', car_model=<CAR.GENESIS_GV60_EV_1ST_GEN>, segment=12) - AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'controlsAllowed': 9}
FAILED test_models.py::TestCarModel_183_RIVIAN_R1_GEN1::test_panda_safety_carstate_fuzzy@CarTestRoute(route='bc095dc92e101734/000000db--ee9fe46e57', car_model=<CAR.RIVIAN_R1_GEN1>, segment=None) - IndexError: list index out of range
FAILED test_models.py::TestCarModel_241_TOYOTA_RAV4_PRIME::test_panda_safety_carstate@CarTestRoute(route='20ba9ade056a8c7b|2021-02-08--21-57-35', car_model=<CAR.TOYOTA_RAV4_PRIME>, segment=None) - AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'gasPressed': 349}
FAILED test_models.py::TestCarModel_247_TOYOTA_SIENNA::test_panda_safety_carstate@CarTestRoute(route='eb6acd681135480d|2019-06-20--20-00-00', car_model=<CAR.TOYOTA_SIENNA>, segment=None) - AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'brakePressed': 184}

@sshane sshane changed the title Only run rx hooks on msgs in safety_config.rx_msgs safety: only run rx hooks on whitelisted msgs Mar 3, 2025
@github-actions github-actions bot added the car safety vehicle-specific safety code label Mar 3, 2025
@sshane sshane added this to the openpilot 0.9.8 milestone Mar 3, 2025
@sshane sshane requested a review from adeebshihadeh March 7, 2025 08:04
@sshane
Copy link
Contributor Author

sshane commented Mar 7, 2025

Just did the structure so far, will fix the bugs in another PR first. @adeebshihadeh Did you have any thoughts about how this is done? Maybe it's cleaner if this hook returns a bool like the others, so true if it detects a relay malfunction and false if not, instead of calling this generic_rx_checks everywhere.

@@ -296,6 +301,7 @@ static safety_config chrysler_init(uint16_t param) {
const safety_hooks chrysler_hooks = {
.init = chrysler_init,
.rx = chrysler_rx_hook,
.rx_relay_malfunction = chrysler_rx_relay_malfunction_hook,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.rx_relay_malfunction = chrysler_rx_relay_malfunction_hook,
.stock_ecu_hook = chrysler_stock_ecu_hook,

?

Comment on lines +219 to +222
// the relay malfunction hook runs on all incoming rx messages
if (current_hooks->rx_relay_malfunction != NULL) {
current_hooks->rx_relay_malfunction(to_push);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to do this. We need to keep moving towards removing the Turing completeness in the safety mode implementations. The information for this check should be fully contained the safety mode config struct and not require a full free-form C function.

Instead of adding another, I think we want to remove the fwd hook and use that same config for this. I tried this briefly but it needed some more though: 595685a.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per usual, the right fix is likely a red diff :)

@sshane
Copy link
Contributor Author

sshane commented Mar 8, 2025

There's actually failures in 7 safety modes, and the Hyundai ones seem the most complex to fix. We might need to clean up the safety first. Going to fix the latest one only for the release (Rivian): #1949

@jyoung8607 Toyota SEC OC doesn't define different RX checks, so it's missing some of the new addresses, can you fix?

@sshane sshane marked this pull request as draft March 8, 2025 00:38
@jyoung8607
Copy link
Collaborator

@jyoung8607 Toyota SEC OC doesn't define different RX checks, so it's missing some of the new addresses, can you fix?

#1953

LMK of any issues, otherwise click merge if your testing likes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
car safety vehicle-specific safety code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants