[otp_ctrl] dif_otp_ctrl_dai_program32() does not check partition write lock
Open
Nobody has claimed this yet.
- Dominant language
- SystemVerilog
- Stars
- 3.6k
- Forks
- 1.1k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 141
Description
Description
Description
dif_otp_ctrl_dai_program32() (dif_otp_ctrl.c:725-767) is a public API that
programs a 32-bit word into an OTP partition without verifying whether the
target partition is write-locked.
Evidence
// dif_otp_ctrl.c:725-767
dif_otp_ctrl_dai_program32() {
// ... align_mask check ...
// ... is_lifecycle check ...
// ... bounds check ...
// Write address, value, WR command
// NO check for partition write lock!
return kDifOk;
}
Lock management functions exist (dif_otp_ctrl_lock_reading(),
dif_otp_ctrl_reading_is_locked()) but are never called from the
program path.
Impact
While the OTP hardware will reject writes to locked partitions, the DIF
returns kDifOk before the hardware response is known. The caller cannot
distinguish "program accepted" from "program ignored due to lock" without
polling status separately.
Suggested Fix
Add a partition write-lock check before programming:
if (partition_is_write_locked(partition)) {
return kDifLocked;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read dif_otp_ctrl.c:725-767 and compare dif_otp_ctrl_lock_reading() with dif_otp_ctrl_reading_is_locked(). Trace how partition locks are represented and how DIF status values such as kDifLocked are handled before changing the programming path. Done means a locked partition is detected before the write command and the API returns the locked status instead of kDifOk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100