Issue #85: Stop logging TA Key Provision success with SEC_LOG_ERROR. - #86
Conversation
Add SEC_LOG_INFO and SEC_LOG_WARNING macros and use them for messages that are not errors, so successful SoC TA provisioning no longer shows up as ERROR in the logs. Fixes #85
Avoid changing the public sec_security.h header; the existing SEC_LOG macro already logs without the ERROR prefix.
There was a problem hiding this comment.
🟡 Changes recommended
The touched provisioning code still has a bool/Sec_Result return-type mismatch risk and a confirmed cleanup bug in the Netflix read-failure path that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR corrects misleading logging in the adapter by introducing non-error log macros and updating SoC TA provisioning and utility logs so successful/expected paths no longer emit ERROR: messages.
Changes:
- Added
SEC_LOG_INFOandSEC_LOG_WARNINGmacros (built on existingSEC_LOGplumbing) to support informational and warning messages. - Converted SoC TA provisioning “handling” and “completed successfully” logs from
SEC_LOG_ERRORtoSEC_LOG_INFO(and fixed the “AppeFairplay” typo in the touched success message). - Updated
SecUtils_MkDirto useSEC_LOG_WARNINGfor mkdir failures that are intentionally non-fatal.
File summaries
| File | Description |
|---|---|
| include/sec_security.h | Adds SEC_LOG_INFO / SEC_LOG_WARNING macros with INFO: / WARNING: prefixes. |
| src/sec_adapter_soc_provisioning.c | Switches successful provisioning progress/success logs from ERROR to INFO; fixes one success-message typo. |
| src/sec_adapter_utils.c | Changes non-fatal mkdir failures from ERROR to WARNING. |
Review details
Suppressed comments (4)
src/sec_adapter_soc_provisioning.c:705
- On this early return,
parameters(allocated above) is not freed, leaking memory on provisioning-data read failures.
if (readNetflixData(processorHandle, &netflixProvisioningData) == false) {
SEC_LOG_ERROR("Failed to read Netflix provisioning data");
return SEC_RESULT_FAILURE;
}
src/sec_adapter_soc_provisioning.c:645
- Typo in error message: "Falied" -> "Failed".
SEC_LOG_ERROR("Falied sa_key_provision_ta call in playready 2k");
src/sec_adapter_soc_provisioning.c:661
- Typo in error message: "Falied" -> "Failed".
SEC_LOG_ERROR("Falied sa_key_provision_ta call in playready 3k");
src/sec_adapter_utils.c:327
- This warning doesn’t include the underlying errno reason, which makes diagnosing mkdir failures difficult. Consider logging
strerror(errno).
if (mkdir(tmp, S_IRWXU) != 0 && errno != EEXIST) {
SEC_LOG("Warning: Mkdir %s failed", tmp);
//return SEC_RESULT_FAILURE;
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The functional change is low-risk and aligns logging severity with actual failure vs. success paths, with only minor wording/log-detail nits noted.
Review details
Suppressed comments (6)
src/sec_adapter_soc_provisioning.c:645
- Typo in error log message: "Falied" -> "Failed".
SEC_LOG_ERROR("Falied sa_key_provision_ta call in playready 2k");
src/sec_adapter_soc_provisioning.c:661
- Typo in error log message: "Falied" -> "Failed".
SEC_LOG_ERROR("Falied sa_key_provision_ta call in playready 3k");
src/sec_adapter_soc_provisioning.c:629
- Typo in error log message: "Falied" -> "Failed".
SEC_LOG_ERROR("Falied sa_key_provision_ta call in widevine");
src/sec_adapter_soc_provisioning.c:696
- Log messages use inconsistent naming/casing ("AppleFairplay") compared to the earlier "Apple FairPlay" handling message; keeping the same spelling/casing improves grep-ability.
SEC_LOG_ERROR("Failed to call sa_key_provision_ta in AppleFairplay");
return SEC_RESULT_FAILURE;
}
SEC_LOG("AppleFairplay provisioning completed successfully");
src/sec_adapter_utils.c:317
- This warning log drops the reason for the mkdir failure; including
errnomakes field debugging easier while still keeping it non-error severity.
SEC_LOG("Warning: Mkdir %s failed", tmp);
src/sec_adapter_utils.c:326
- This warning log drops the reason for the mkdir failure; including
errnomakes field debugging easier while still keeping it non-error severity.
SEC_LOG("Warning: Mkdir %s failed", tmp);
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
mhabrat
left a comment
There was a problem hiding this comment.
Review and address Copilot review comments.
- Change provisioning_ta to return Sec_Result instead of bool; the implementation already returned SEC_RESULT_*, so a bool return meant false on success and true on failure. - Free the sa_import_parameters_soc allocation on every read*Data early return, which previously leaked on provisioning-data read failures. - Fix 'Falied' -> 'Failed' typos in the widevine and playready logs. - Use consistent 'Apple MFi' / 'Apple Fairplay' product naming across handling, error and success logs. - Drop the duplicate 'Handling Netflix provisioning' log inside provisioning_ta; SecSocProv_Ta_Provision already emits it and no other provisioning type logs it there. - Include strerror(errno) in the non-fatal SecUtils_MkDir warnings.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are low-risk and limited to logging/message correctness, with only minor message wording/capitalization nits identified.
Review details
Suppressed comments (5)
src/sec_adapter_soc_provisioning.c:691
- Error message uses "Fairplay" capitalization; use consistent "FairPlay" product name in logs.
SEC_LOG_ERROR("Failed to read Apple Fairplay provisioning data");
src/sec_adapter_soc_provisioning.c:699
- Error message uses "Fairplay" capitalization; use consistent "FairPlay" product name in logs.
SEC_LOG_ERROR("Failed to call sa_key_provision_ta in Apple Fairplay");
src/sec_adapter_soc_provisioning.c:702
- Success message uses "Fairplay" capitalization; use consistent "FairPlay" product name in logs.
SEC_LOG("Apple Fairplay provisioning completed successfully");
src/sec_adapter_soc_provisioning.c:665
- This error message is grammatically unclear (missing "to") and uses inconsistent product capitalization ("playready 3k" vs other "PlayReady 3K" logs).
SEC_LOG_ERROR("Failed sa_key_provision_ta call in playready 3k");
src/sec_adapter_soc_provisioning.c:648
- This error message is grammatically unclear (missing "to") and uses inconsistent product capitalization ("playready 2k" vs other "PlayReady 2K" logs).
SEC_LOG_ERROR("Failed sa_key_provision_ta call in playready 2k");
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
Fairplay -> FairPlay (fixing case) Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces a couple of concrete correctness/quality issues (unsafe errno usage with unspecified argument evaluation order in logging, and an unused provisioning_ta parameter) that should be addressed before approval.
Review details
Suppressed comments (5)
Previously missed (3) — in code that hasn't changed since the last review.
src/sec_adapter_soc_provisioning.c:607
numPathsis never used insideprovisioning_ta, which will trigger unused-parameter warnings and makes the signature misleading. If it’s intentionally unused, explicitly mark it unused (or remove it and update call sites).
src/sec_adapter_utils.c:319strerror(errno)is passed as an argument toSEC_LOG, but C does not specify function argument evaluation order;SEC_LOGalso evaluates other arguments (e.g.,syscall(SYS_gettid)) that could clobbererrno, resulting in an incorrect error string. Captureerrnoto a local variable before logging.
src/sec_adapter_utils.c:328- Same
errno/argument-evaluation-order issue here: captureerrnobefore callingSEC_LOGso the loggedstrerrormatches the failingmkdir.
src/sec_adapter_soc_provisioning.c:692
- The log message uses "Fairplay" while other messages in this file use "FairPlay"; for consistency (and to match the earlier "Handling Apple FairPlay provisioning"), this should use "FairPlay".
if (readAppleFairPlayData(processorHandle, &appleFairplayProvisioningData) == false) {
SEC_LOG_ERROR("Failed to read Apple Fairplay provisioning data");
SEC_FREE(parameters);
src/sec_adapter_soc_provisioning.c:702
- These messages use "Fairplay"; elsewhere the file uses "FairPlay". Update both strings to keep log output consistent.
if (status != SA_STATUS_OK) {
SEC_LOG_ERROR("Failed to call sa_key_provision_ta in Apple Fairplay");
return SEC_RESULT_FAILURE;
}
SEC_LOG("Apple Fairplay provisioning completed successfully");
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟢 Approval recommended
The changes are low-risk and improve logging correctness (with consistent Sec_Result returns) without altering public headers.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/sec_adapter_soc_provisioning.c:610
- PR description focuses on logging-only changes, but this hunk also changes
provisioning_tafrombooltoSec_Result(and updates return values), which is a functional behavior change that impacts theSecSocProv_Ta_Provisionreturn value. Please update the PR description (or add a note in the commit/PR) to explicitly call out this functional fix so reviewers/consumers aren’t surprised.
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
Fixes #85
Problem
Successful SoC TA key provisioning (Widevine, PlayReady 2K/3K, Apple MFi, Apple FairPlay, Netflix) logged its progress and success messages through
SEC_LOG_ERROR, so a clean provisioning run showed up as a series ofERROR:lines in the log.Change
No public header changes. The existing
SEC_LOGmacro already logs through the same logger hook without theERROR:prefix, so the non-error call sites now use it.src/sec_adapter_soc_provisioning.c: 13 non-error messages ("Handling <x> provisioning" and "<x> provisioning completed successfully") moved fromSEC_LOG_ERRORtoSEC_LOG. Genuine failure paths still useSEC_LOG_ERROR.src/sec_adapter_utils.c:SecUtils_MkDirloggedSEC_LOG_ERROR("Warning Mkdir %s failed", ...)for a condition it deliberately continues past; that is nowSEC_LOG("Warning: Mkdir %s failed", ...).I swept every
SEC_LOG_ERRORcall site insrc/,include/, andtest/looking for messages that were not reporting a failure; the ones above were the only matches.Testing
make sec_apibuilds clean (only pre-existing warnings).Also fixed the "AppeFairplay" typo in the success message touched by this change.