Skip to content

Issue #85: Stop logging TA Key Provision success with SEC_LOG_ERROR. - #86

Merged
riwoh merged 5 commits into
mainfrom
fix/issue-85-log-levels
Sep 18, 2026
Merged

riwoh merged 5 commits into
mainfrom
fix/issue-85-log-levels

Conversation

@riwoh

@riwoh riwoh commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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 of ERROR: lines in the log.

Change

No public header changes. The existing SEC_LOG macro already logs through the same logger hook without the ERROR: 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 from SEC_LOG_ERROR to SEC_LOG. Genuine failure paths still use SEC_LOG_ERROR.
  • src/sec_adapter_utils.c: SecUtils_MkDir logged SEC_LOG_ERROR("Warning Mkdir %s failed", ...) for a condition it deliberately continues past; that is now SEC_LOG("Warning: Mkdir %s failed", ...).

I swept every SEC_LOG_ERROR call site in src/, include/, and test/ looking for messages that were not reporting a failure; the ones above were the only matches.

Testing

make sec_api builds clean (only pre-existing warnings).

Also fixed the "AppeFairplay" typo in the success message touched by this change.

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
Copilot AI lite review requested due to automatic review settings September 3, 2026 03:01
Avoid changing the public sec_security.h header; the existing SEC_LOG
macro already logs without the ERROR prefix.
@riwoh riwoh changed the title fix: use non-error log levels for success and informational messages fix: do not log provisioning success and info messages as errors Sep 3, 2026
@riwoh riwoh changed the title fix: do not log provisioning success and info messages as errors Issue #85: Stop logging TA Key Provision success with SEC_LOG_ERROR. Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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_INFO and SEC_LOG_WARNING macros (built on existing SEC_LOG plumbing) to support informational and warning messages.
  • Converted SoC TA provisioning “handling” and “completed successfully” logs from SEC_LOG_ERROR to SEC_LOG_INFO (and fixed the “AppeFairplay” typo in the touched success message).
  • Updated SecUtils_MkDir to use SEC_LOG_WARNING for 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.

Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_utils.c
Copilot AI review requested due to automatic review settings September 3, 2026 03:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 errno makes 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 errno makes 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

Comment thread src/sec_adapter_soc_provisioning.c Outdated

@mhabrat mhabrat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review and address Copilot review comments.

Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_soc_provisioning.c Outdated
- 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.
Copilot AI review requested due to automatic review settings September 8, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

Comment thread src/sec_adapter_soc_provisioning.c Outdated
Comment thread src/sec_adapter_soc_provisioning.c Outdated
Fairplay -> FairPlay (fixing case)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 8, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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

  • numPaths is never used inside provisioning_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:319
  • strerror(errno) is passed as an argument to SEC_LOG, but C does not specify function argument evaluation order; SEC_LOG also evaluates other arguments (e.g., syscall(SYS_gettid)) that could clobber errno, resulting in an incorrect error string. Capture errno to a local variable before logging.
    src/sec_adapter_utils.c:328
  • Same errno/argument-evaluation-order issue here: capture errno before calling SEC_LOG so the logged strerror matches the failing mkdir.

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

Copilot AI review requested due to automatic review settings September 8, 2026 16:15
@riwoh
riwoh requested a review from mhabrat September 8, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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_ta from bool to Sec_Result (and updates return values), which is a functional behavior change that impacts the SecSocProv_Ta_Provision return 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

@riwoh
riwoh merged commit d5c4910 into main Sep 18, 2026
9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ta key provision calls using SEC_LOG_ERROR

3 participants