fix(can): close the race between the identity check and the read-only store
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #60 của @Tichael — đã merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Start by reading the implementations of set_can_read_only(), is_can_read_only(), and the identity confirmation and revocation functions mentioned in the issue. Then inspect the existing CAN tests and add the described interleaving test: confirm identity, unlock, clear only the identity flag, and assert the bus reads as read-only. Done when the test passes and an unconfirmed identity always reads as read-only.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Follow-up to #49.
Problem
set_can_read_only(false) checks the identity flag and then stores the read-only flag in two separate steps:
let enabled = enabled || crate::can_log::is_can_logging() || !is_car_identity_confirmed();
CAN_READ_ONLY.store(enabled, Ordering::Relaxed);
If revoke_car_identity() runs between those two steps, the order is:
set_can_read_only(false)reads identity = confirmed, soenabled = false.revoke_car_identity()clears the identity and storesCAN_READ_ONLY = true.set_can_read_only(false)storesCAN_READ_ONLY = false.
The bus ends up unlocked with no confirmed identity, which is what the gate is meant to prevent.
Is it reachable today?
No. Nothing calls set_can_read_only(false) yet, and embassy tasks on one executor only switch at await points. It becomes possible if these functions are ever called from an interrupt, a second executor (e.g. an interrupt-priority executor on ESP) or another thread on PC.
The CAN logging check doesn't have this gap: is_can_read_only() already ORs in is_can_logging(), so it's enforced when the flag is read.
Suggested fix
Treat the identity like logging: OR !is_car_identity_confirmed() into is_can_read_only(), so an unconfirmed identity always reads as read-only, whatever CAN_READ_ONLY holds. Alternatively, wrap the check and the store in critical_section::with (core-interface already depends on critical-section).
Add a test that confirms, unlocks, and then clears only the identity flag (simulating the interleaving) and asserts that is_can_read_only() returns true.
- Ngôn ngữ chính
- Rust
- Star
- 1
- Fork
- 0
- Merge trung bình
- 11 giờ 26 phút
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenCarControls/firmware
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 51/100
OpenCarControls/firmware#68 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
OpenCarControls/firmware#55 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
OpenCarControls/firmware#54 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
First-setup pairing window is too short and stays open after the first bondCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
OpenCarControls/firmware#53 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
OpenCarControls/firmware#51 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenCarControls/firmware
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
farion1231/cc-switch#8829 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ci good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
longbridge/gpui-kit#3677 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
E-pr-welcome
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
seanmonstar/reqwest#3121 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
ilya-zlobintsev/LACT#1235 ·
Maintainer thường phản hồi trong vòng 1 ngày