fsverity: don't check builtin signatures when require_signatures=0
Subsystems (5)
Eric Biggers
maintainerPATCH 1/1 fsverity: don't check builtin signatures when require_signatures=0
From: Eric Biggers <[email protected]>
An issue that arises when migrating from builtin signatures to userspace signatures is that existing files that have builtin signatures cannot be opened unless either CONFIG_FS_VERITY_BUILTIN_SIGNATURES is disabled or the signing certificate is left in the .fs-verity keyring.
Since builtin signatures provide no security benefit when fs.verity.require_signatures=0 anyway, let's just skip the signature verification in this case.
--- fs/verity/signature.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
fs/verity/signature.c +16 -2
@@ -13,8 +13,8 @@#include <linux/verification.h> /* -* /proc/sys/fs/verity/require_signatures -* If 1, all verity files must have a valid builtin signature. +* /proc/sys/fs/verity/require_signatures. If 1, then builtin signatures are +* verified and all verity files must have a valid builtin signature. */ static int fsverity_require_signatures;
@@ -54,6 +54,20 @@ int fsverity_verify_signature(const struct fsverity_info *vi,return 0 ; } +/* +* If require_signatures=0, don't verify builtin signatures. +* Originally, builtin signatures were verified opportunistically in +* this case. However, no security property is possible when +* require_signatures=0 anyway. Skipping the builtin signature +* verification makes it easier to migrate existing files from builtin +* signature verification to userspace signature verification. +*/ +if (!fsverity_require_signatures) { +fsverity_warn (inode, +"Not checking builtin signature due to require_signatures=0" ); +return 0 ; + } + d =kzalloc (sizeof (*d) + hash_alg->digest_size,GFP_KERNEL );if (!d)return -ENOMEM ;
base-commit: 479174d402bcf60789106eedc4def3957c060bad
Signature · 8 lines
2.38.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 12 lines · Eric Biggers
From: Eric Biggers <[email protected]>
An issue that arises when migrating from builtin signatures to userspace signatures is that existing files that have builtin signatures cannot be opened unless either
CONFIG_FS_VERITY_BUILTIN_SIGNATURESis disabled or the signing certificate is left in the .fs-verity keyring.Since builtin signatures provide no security benefit when fs.verity.require_signatures=0 anyway, let's just skip the signature verification in this case.
Quoted 6 lines
Fixes 432434c9f8e1 ("fs-verity: support builtin file signatures")Cc <[email protected]> # v5.4+Signed-off-by Eric Biggers <[email protected]>--- fs/verity/signature.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Eric Biggers
maintainerQuoted 13 lines · Luca Boccassi
Quoted 12 lines · Eric Biggers
From: Eric Biggers <[email protected]>
An issue that arises when migrating from builtin signatures to userspace signatures is that existing files that have builtin signatures cannot be opened unless either
CONFIG_FS_VERITY_BUILTIN_SIGNATURESis disabled or the signing certificate is left in the .fs-verity keyring.Since builtin signatures provide no security benefit when fs.verity.require_signatures=0 anyway, let's just skip the signature verification in this case.
Quoted 8 lines
Quoted 6 lines
Fixes 432434c9f8e1 ("fs-verity: support builtin file signatures")Cc <[email protected]> # v5.4+Signed-off-by Eric Biggers <[email protected]>--- fs/verity/signature.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)Acked-by Luca Boccassi <[email protected]>
So if I can't apply
https://lore.kernel.org/linux-fscrypt/[email protected]
("fsverity: mark builtin signatures as deprecated") due to IPE, wouldn't I not be able to apply this patch either? Surely IPE isn't depending on fs.verity.require_signatures=1, given that it enforces the policy itself?
- Eric
Quoted 22 lines · Eric Biggers
Quoted 20 lines · Luca Boccassi
Quoted 18 lines · Eric Biggers
From: Eric Biggers <[email protected]>
An issue that arises when migrating from builtin signatures to userspace signatures is that existing files that have builtin signatures cannot be opened unless either
CONFIG_FS_VERITY_BUILTIN_SIGNATURESis disabled or the signing certificate is left in the .fs-verity keyring.Since builtin signatures provide no security benefit when fs.verity.require_signatures=0 anyway, let's just skip the signature verification in this case.
Fixes 432434c9f8e1 ("fs-verity: support builtin file signatures")Cc <[email protected]> # v5.4+Signed-off-by Eric Biggers <[email protected]>--- fs/verity/signature.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 1 line
Acked-by Luca Boccassi <[email protected]>So if I can't apply
https://lore.kernel.org/linux-fscrypt/[email protected]
("fsverity: mark builtin signatures as deprecated") due to IPE, wouldn't I not be able to apply this patch either? Surely IPE isn't depending on fs.verity.require_signatures=1, given that it enforces the policy itself?
I'm not sure what you mean? Skipping verification when this syscfg is disabled makes sense to me, as you noted it doesn't serve any purpose in that case.
Kind regards,
Luca Boccassi
Eric Biggers
maintainerQuoted 31 lines · Luca Boccassi
Quoted 22 lines · Eric Biggers
Quoted 20 lines · Luca Boccassi
Quoted 18 lines · Eric Biggers
From: Eric Biggers <[email protected]>
An issue that arises when migrating from builtin signatures to userspace signatures is that existing files that have builtin signatures cannot be opened unless either
CONFIG_FS_VERITY_BUILTIN_SIGNATURESis disabled or the signing certificate is left in the .fs-verity keyring.Since builtin signatures provide no security benefit when fs.verity.require_signatures=0 anyway, let's just skip the signature verification in this case.
Fixes 432434c9f8e1 ("fs-verity: support builtin file signatures")Cc <[email protected]> # v5.4+Signed-off-by Eric Biggers <[email protected]>--- fs/verity/signature.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)Quoted 7 lines
Quoted 1 line
Acked-by Luca Boccassi <[email protected]>So if I can't apply
https://lore.kernel.org/linux-fscrypt/[email protected]
("fsverity: mark builtin signatures as deprecated") due to IPE, wouldn't I not be able to apply this patch either? Surely IPE isn't depending on fs.verity.require_signatures=1, given that it enforces the policy itself?
Quoted 3 lines
I'm not sure what you mean? Skipping verification when this syscfg is disabled makes sense to me, as you noted it doesn't serve any purpose in that case.
Currently, fsverity builtin signatures are only useful if fs.verity.require_signatures is set to 1 *and* userspace actually checks that files have fsverity enabled. However, IPE would change that if it actually gets merged upstream, at least based on the version that was most recently sent out. It would introduce a use of fsverity builtin signatures directly in the kernel
(https://lore.kernel.org/r/1654714889-26728-14-git-send-email-deven.desai@linux.microsoft.com
and
https://lore.kernel.org/r/1654714889-26728-15-git-send-email-deven.desai@linux.microsoft.com).
IIUC, the IPE patches add code that checks whether a file has a fsverity builtin signature, and if so it assumes that it was verified by fs/verity/ and creates a *boolean* file property "fsverity_signature" for IPE to operate on.
Since the IPE patches check for the presence of a builtin signature directly, instead of indirectly by checking whether the inode has fsverity enabled at all, there would be no need for the fs.verity.require_signatures setting with IPE.
The IPE patches do assume that the signature, if present, always gets verified by fs/verity/. That's what this patch would break.
Of course, for upstream I shouldn't care about breaking out-of-tree code. So I could apply this anyway. But I'd at least like to be consistent. If "fsverity:
mark builtin signatures as deprecated" isn't going to be applied because of IPE, then I'd think this patch shouldn't be applied either, for the same reason...
- Eric