From: sashiko-bot@kernel.org
To: "Manuel Huber" <manuelh@nvidia.com>
Cc: linux-security-module@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH RFC 4/4] selftests/ipe: test the IPE policy keyring
Date: Mon, 19 Oct 2026 21:57:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-178282@kernel.org> (raw)
In-Reply-To: <20261019-b4-ipe-keyring-rfc-v1-4-156f0b93e843@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] selftests/ipe: missing CONFIG_CRYPTO_SHA256 in config fragment
- [Low] selftests/ipe: keyctl id check precedes already-provisioned keyring check
--
commit 0116188a11e090ec7a12ebe17082312fda668a18
Author: Manuel Huber <manuelh@nvidia.com>
selftests/ipe: test the IPE policy keyring
This commit adds a kselftest script and configuration fragment to validate
IPE policy keyring operations for both sealed and unsealed boot parameter
states.
> diff --git a/tools/testing/selftests/ipe/config b/tools/testing/selftests/ipe/config
> new file mode 100644
> index 0000000000000..498c224d2c182
> --- /dev/null
> +++ b/tools/testing/selftests/ipe/config
> @@ -0,0 +1,7 @@
> +CONFIG_AUDIT=y
> +CONFIG_AUDITSYSCALL=y
> +CONFIG_KEYS=y
> +CONFIG_PROC_FS=y
> +CONFIG_SECURITY=y
> +CONFIG_SECURITYFS=y
> +CONFIG_SECURITY_IPE=y
[Severity: Medium]
Should this config fragment also include CONFIG_CRYPTO_SHA256=y (along with
CONFIG_NET=y and CONFIG_SYSFS=y, which CONFIG_AUDIT and CONFIG_SECURITY
depend on)?
In test-ipe-keyring.sh, generate_keypair() and sign_policy() generate
RSA-2048 X.509 certificates and PKCS#7 signatures using SHA-256. When a
signed policy is written to /sys/kernel/security/ipe/new_policy,
new_policy() -> ipe_new_policy() -> verify_pkcs7_signature() ->
pkcs7_verify() -> pkcs7_digest() allocates the shash algorithm:
crypto/asymmetric_keys/pkcs7_verify.c:pkcs7_digest() {
...
tfm = crypto_alloc_shash(sinfo->sig->hash_algo, 0, 0);
if (IS_ERR(tfm))
return (PTR_ERR(tfm) == -ENOENT) ? -ENOPKG : PTR_ERR(tfm);
...
}
Although CONFIG_SECURITY_IPE selects CONFIG_CRYPTO_LIB_SHA256,
CONFIG_PKCS7_MESSAGE_PARSER, and CONFIG_SYSTEM_DATA_VERIFICATION, none of
those select CONFIG_CRYPTO_SHA256 to register the "sha256" crypto_shash
algorithm.
Without CONFIG_CRYPTO_SHA256=y, pkcs7_digest() returns -ENOPKG. That causes
positive policy loads in test_unsealed_keyring() to fail, and causes the
negative checks in test_sealed_keyring() and test_unsealed_keyring() to
falsely pass before ipe_new_policy() ever reaches ipe_keyring_lookup():
security/ipe/policy.c:ipe_new_policy() {
...
if (rc == -ENOKEY || rc == -EKEYREJECTED) {
keyring = ipe_keyring_lookup();
if (keyring)
rc = verify_pkcs7_signature(NULL, 0, new->pkcs7,
pkcs7len, keyring,
VERIFYING_UNSPECIFIED_SIGNATURE,
set_pkcs7_data, new);
}
...
}
> diff --git a/tools/testing/selftests/ipe/test-ipe-keyring.sh b/tools/testing/selftests/ipe/test-ipe-keyring.sh
> new file mode 100755
> index 0000000000000..557ccc825fe24
> --- /dev/null
> +++ b/tools/testing/selftests/ipe/test-ipe-keyring.sh
[ ... ]
> + keyctl setperm "$KEY_SPEC_IPE_KEYRING" \
> + "$IPE_KEYRING_PERM_LOCKED" >/dev/null 2>&1 ||
> + fail "drop mutation permissions from the keyring"
> + ktap_test_pass "mutation permissions can be dropped"
> +
> + if keyctl id "$KEY_SPEC_IPE_KEYRING" >/dev/null 2>&1; then
> + fail "the special key ID granted possession rights"
> + fi
> + ktap_test_pass "the special key ID grants no possession rights"
[ ... ]
> +keyring_serial=$(keyctl id "$KEY_SPEC_IPE_KEYRING" 2>/dev/null) ||
> + skip "KEY_SPEC_IPE_KEYRING does not resolve"
> +keyring_description=$(keyctl describe "$keyring_serial" 2>/dev/null) ||
> + skip "cannot describe the IPE keyring"
> +case "$keyring_description" in
> + *"keyring: .ipe") ;;
> + *) skip "KEY_SPEC_IPE_KEYRING resolved to an unexpected key" ;;
> +esac
> +
> +keyring_unsealed=$(cat /sys/module/ipe/parameters/keyring_unsealed)
> +case "$keyring_unsealed" in
> + Y)
> + [ "$(keyring_key_count)" = 0 ] ||
> + skip "the IPE keyring has already been provisioned"
> + test_unsealed_keyring
> + ;;
[Severity: Low]
Can the "the IPE keyring has already been provisioned" skip check be
reached if the keyring was already provisioned and locked?
When the keyring is locked with IPE_KEYRING_PERM_LOCKED (0x08030000),
KEY_USR_SEARCH is dropped. Because lookup_user_key() returns an unpossessed
key reference for KEY_SPEC_IPE_KEYRING, running keyctl id on
KEY_SPEC_IPE_KEYRING fails with -EACCES once locked (as verified in
test_unsealed_keyring() above).
When test-ipe-keyring.sh is run a second time or on a system where the
keyring was already provisioned and locked, the initial keyctl id check at
the top of the script will fail and skip with "KEY_SPEC_IPE_KEYRING does
not resolve" before reaching the keyring_key_count() check (which uses
keyctl list and only needs read/view permissions). Should the
keyring_key_count() check happen before calling keyctl id when
keyring_unsealed is Y?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261019-b4-ipe-keyring-rfc-v1-0-156f0b93e843@nvidia.com?part=4
next prev parent reply other threads:[~2026-10-19 21:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 21:40 [PATCH RFC 0/4] IPE: add a dedicated policy keyring Manuel Huber via B4 Relay
2026-10-19 21:40 ` [PATCH RFC 1/4] ipe: add the .ipe " Manuel Huber via B4 Relay
2026-10-19 21:52 ` Randy Dunlap
2026-10-19 23:15 ` Fan Wu
2026-10-19 21:40 ` [PATCH RFC 2/4] keys: add KEY_SPEC_IPE_KEYRING Manuel Huber via B4 Relay
2026-10-19 23:24 ` Fan Wu
2026-10-19 21:40 ` [PATCH RFC 3/4] Documentation: ipe: document the IPE keyring Manuel Huber via B4 Relay
2026-10-19 21:40 ` [PATCH RFC 4/4] selftests/ipe: test the IPE policy keyring Manuel Huber via B4 Relay
2026-10-19 21:57 ` sashiko-bot [this message]
2026-10-19 23:28 ` Fan Wu
2026-10-19 21:54 ` [PATCH RFC 0/4] IPE: add a dedicated " Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-178282@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=manuelh@nvidia.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox