Skip to content

Implement aws-lc-provider error queue handling - #3488

Open
geedo0 wants to merge 2 commits into
feat/provider-fipsfrom
feat/provider-errors
Open

geedo0 wants to merge 2 commits into
feat/provider-fipsfrom
feat/provider-errors

Conversation

@geedo0

@geedo0 geedo0 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Context and motivation

This wires up error reporting for the provider so users can get feedback on failed operations. We align the implementation strategy around the ACCP precedent of marking and draining the error queues on each border-crossing.

Two properties of the two libraries shape what is possible here:

  • AWS-LC's error queue is pull-only. There is no raise-time callback to bridge, so records can only be
    collected around a call that has already returned.
  • The two libraries' error numbering diverges. AWS-LC's library ids differ from OpenSSL's above 11, and
    each library numbers its reasons independently, so an AWS-LC code filed under an OpenSSL library id
    resolves against the wrong per-library table and renders as another library's reason.

Description of changes

A private error library. The provider files everything under its own awslc error library through the
core error upcalls, and publishes reason strings for its own codes via
OSSL_FUNC_PROVIDER_GET_REASON_STRINGS.

A reason namespace with three disjoint ranges (internal/backend.h):

Range Contents
1 to 99 AWS-LC's cross-library reasons, kept at their own numbers. AWS-LC resolves these without consulting the library field, so one entry serves every library and the provider does not tag them.
100 to 4095 The provider's own reasons, AWSLC_PROV_R_*.
4096 and up An AWS-LC library-specific reason, as `(library << 12)

A bracket around every call into AWS-LC. awslc_prov_error_mark() before, then
AWSLC_PROV_ERROR_SETTLE(...) with the slot's own result, which comes back unchanged:

  • Success discards to the mark. AWS-LC queues records on recoverable internal paths, and a successful
    call must not leak those to the application.
  • Failure re-raises AWS-LC's records oldest first, which is how OpenSSL's queue is read, or raises the
    slot's own reason and detail if AWS-LC queued none. A failed dispatch call never leaves the queue empty.

Detail composed on the AWS-LC side. backend/errors.c renders AWS-LC <library>: <reason>: <data>,
because only that translation unit can see AWS-LC's reason tables.

First integration. SHA-2 brackets its init, update, final, and context allocation, and raises
AWSLC_PROV_R_INVALID_PARAMETER for its own argument rejections and AWSLC_PROV_R_UNAPPROVED_OPERATION
when an indicator callback vetoes a result.

Testing

Backend suite (test/backend/errors_test.cc, 8 tests). Only the AWS-LC-linked binary can force a
record onto AWS-LC's queue, so the translation is covered there rather than through the provider interface.

Review considerations

  • Looking for feedback on the error code remapping strategy and how we pack in the library IDs.
  • The failure half of the bracket has no test that executes it. No SHA-2 path can fail through EVP:
    SHA*_Init and SHA*_Update do not fail, EVP_DigestFinal_ex always passes the advertised size so the
    backend bounds check is unreachable, and only the AWS-LC-linked binary can force an allocation failure
    while that binary does not run dispatch functions. It closes with the first operation whose backend can
    fail. The discard half, the raise half, and the substitution are each covered.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache
2.0 license and the ISC license.

@geedo0
geedo0 requested a review from a team as a code owner September 4, 2026 12:28

@github-actions github-actions Bot 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.

clang-tidy made some suggestions

Comment thread provider/backend/errors.c Outdated
if (out == NULL) {
return 0;
}
memset(out, 0, sizeof(*out));

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.

warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]

  memset(out, 0, sizeof(*out));
  ^
Additional context

provider/backend/errors.c:35: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11

  memset(out, 0, sizeof(*out));
  ^

Comment thread provider/backend/errors.c
Comment thread provider/backend/errors.c
Comment thread provider/frontend/operations/digests/sha2.c
static int awslc_prov_sha2_init_op(void *dctx, const OSSL_PARAM params[],
awslc_prov_sha2_init_fn init) {
AWSLC_PROV_SHA2_CTX *ctx = (AWSLC_PROV_SHA2_CTX *)dctx;
int ok;

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.

warning: variable 'ok' is not initialized [cppcoreguidelines-init-variables]

Suggested change
int ok;
int ok = 0;

size_t inl,
awslc_prov_sha2_update_fn update) {
AWSLC_PROV_SHA2_CTX *ctx = (AWSLC_PROV_SHA2_CTX *)dctx;
int ok;

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.

warning: variable 'ok' is not initialized [cppcoreguidelines-init-variables]

Suggested change
int ok;
int ok = 0;

@geedo0
geedo0 force-pushed the feat/provider-errors branch from 961b477 to 2682ae8 Compare September 4, 2026 20:00
Bridge AWS-LC's pull-only error queue onto OpenSSL's. The back side drains each
record and translates it into a boundary-neutral form; the front side re-raises it
under a private "awslc" error library that the core allocates for this load, since
OpenSSL owns the reason-string tables for its own library ids and the two forks
pack their codes differently.

Reason codes occupy three disjoint ranges beneath that library. AWS-LC's
cross-library reasons pass through untagged, the provider's own three reasons sit
at 100 to 4095, and an AWS-LC library-specific reason is tagged with the library
that raised it, since AWS-LC reason numbers repeat across libraries.

Only the provider's own reasons are registered with the core. An AWS-LC-origin
reason carries its library and reason text in the record's detail instead,
composed on the side that can resolve AWS-LC's own tables, so nothing here
duplicates data AWS-LC already resolves at runtime.

Every dispatch slot reaching AWS-LC brackets its backend calls: mark on entry,
then hand the slot's own result to AWSLC_PROV_ERROR_SETTLE, which discards on
success and translates or falls back to the slot's reason on failure. A failed
call never leaves the queue empty, and a successful one never leaks the records
AWS-LC queues on recoverable internal paths.
@geedo0
geedo0 force-pushed the feat/provider-errors branch from 2682ae8 to fc6f113 Compare September 4, 2026 20:12
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat/provider-fips@aa6f6da). Learn more about missing BASE report.

Additional details and impacted files
@@                  Coverage Diff                  @@
##             feat/provider-fips    #3488   +/-   ##
=====================================================
  Coverage                      ?   78.34%           
=====================================================
  Files                         ?      700           
  Lines                         ?   125598           
  Branches                      ?    17378           
=====================================================
  Hits                          ?    98396           
  Misses                        ?    26331           
  Partials                      ?      871           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🔒 Security ReviewView Report

Please review before merging.

@justsmth
justsmth self-requested a review September 8, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants