Skip to contentSkip to conversation

linux-next: build warnings after merge of the keys tree

PATCH Stephen Rothwell 2 participants 5 messages Jul 30, 2019 – Jul 31, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the keys tree, today's linux-next build (x86_64 allmodconfig) produced these warnings:

In file included from include/linux/keyctl.h:11,
from include/linux/key.h:35,
from include/linux/cred.h:13,
from fs/verity/signature.c:10:
fs/verity/signature.c: In function 'fsverity_init_signature':
include/uapi/linux/keyctl.h:52:24: warning: passing argument 5 of 'keyring_alloc' makes pointer from integer without a cast [-Wint-conversion]

 #define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */
                        ^

fs/verity/signature.c:140:25: note: in expansion of macro 'KEY_POS_SEARCH'
current_cred(), KEY_POS_SEARCH |
^~~~~~~~~~~~~~
In file included from include/linux/cred.h:13,
from fs/verity/signature.c:10:
include/linux/key.h:386:20: note: expected 'struct key_acl *' but argument is of type 'int'
extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,

                    ^~~~~~~~~~~~~

Caused by commit

f802f2b3a991 ("keys: Replace uid/gid/perm permissions checking with an ACL")

interacting with commit

318ce3c7b2ff ("fs-verity: support builtin file signatures")

from the fsverity tree.

(Have I mentioned that I have API changes? ;-))

I have applied the following merge fix patch:

From: Stephen Rothwell <[email protected]>
Date: Tue, 30 Jul 2019 12:13:38 +1000
Subject: [PATCH] fsverity: merge fix for keyring_alloc API change

---
 fs/verity/signature.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
fs/verity/signature.c +14 -3
index c8b255232de5..a7aac30c56ae 100644
@@ -131,15 +131,26 @@ static inline int __init fsverity_sysctl_init(void)
 }
 #endif /* !CONFIG_SYSCTL */
 
+static struct key_acl fsverity_acl = {
+	.usage	= REFCOUNT_INIT(1),
+	.possessor_viewable = true,
+	.nr_ace	= 2,
+	.aces = {
+		KEY_POSSESSOR_ACE(KEY_ACE_SEARCH | KEY_ACE_JOIN |
+				  KEY_ACE_INVAL),
+		KEY_OWNER_ACE(KEY_ACE_VIEW | KEY_ACE_READ | KEY_ACE_WRITE |
+			      KEY_ACE_CLEAR | KEY_ACE_SEARCH |
+			      KEY_ACE_SET_SECURITY | KEY_ACE_REVOKE),
+	}
+};
+
 int __init fsverity_init_signature(void)
 {
 	struct key *ring;
 	int err;
 
 	ring = keyring_alloc(".fs-verity", KUIDT_INIT(0), KGIDT_INIT(0),
-			     current_cred(), KEY_POS_SEARCH |
-				KEY_USR_VIEW | KEY_USR_READ | KEY_USR_WRITE |
-				KEY_USR_SEARCH | KEY_USR_SETATTR,
+			     current_cred(), &fsverity_acl,
 			     KEY_ALLOC_NOT_IN_QUOTA, NULL, NULL);
 	if (IS_ERR(ring))
 		return PTR_ERR(ring);
Signature · 5 lines
2.20.1

-- 
Cheers,
Stephen Rothwell
maintainer
#1 lore raw
Quoted 12 lines · Stephen Rothwell

Subject: [PATCH] fsverity: merge fix for keyring_alloc API change

---
 fs/verity/signature.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
fs/verity/signature.c +0 -0
index c8b255232de5..a7aac30c56ae 100644

fs/verity/signature.c static inline int __init fsverity_sysctl_init(void) · line 136

Quoted 6 lines
fs/verity/signature.c +3 -0
@@ -131,15 +131,26 @@ static inline int __init fsverity_sysctl_init(void)
 }
 #endif /* !CONFIG_SYSCTL */
 
+static struct key_acl fsverity_acl = {
+	.usage	= REFCOUNT_INIT(1),
+	.possessor_viewable = true,

I don't think .possessor_viewable should be set here, since there's no KEY_POSSESSOR_ACE(KEY_ACE_VIEW) in the ACL. David, this bool is supposed to mean such an entry is present, right? Is it really necessary, since it's redundant with the ACL itself?

Quoted 11 lines
fs/verity/signature.c +10 -0
+	.nr_ace	= 2,
+	.aces = {
+		KEY_POSSESSOR_ACE(KEY_ACE_SEARCH | KEY_ACE_JOIN |
+				  KEY_ACE_INVAL),
+		KEY_OWNER_ACE(KEY_ACE_VIEW | KEY_ACE_READ | KEY_ACE_WRITE |
+			      KEY_ACE_CLEAR | KEY_ACE_SEARCH |
+			      KEY_ACE_SET_SECURITY | KEY_ACE_REVOKE),
+	}
+};
+
 int __init fsverity_init_signature(void)

fs/verity/signature.c static inline int __init fsverity_sysctl_init(void) · line 154

Quoted 10 lines
fs/verity/signature.c +1 -3
 {
 	struct key *ring;
 	int err;
 
 	ring = keyring_alloc(".fs-verity", KUIDT_INIT(0), KGIDT_INIT(0),
-			     current_cred(), KEY_POS_SEARCH |
-				KEY_USR_VIEW | KEY_USR_READ | KEY_USR_WRITE |
-				KEY_USR_SEARCH | KEY_USR_SETATTR,
+			     current_cred(), &fsverity_acl,
 			     KEY_ALLOC_NOT_IN_QUOTA, NULL, NULL);

Otherwise this looks good, thanks Stephen. I'll want to remove a few of these permissions in a separate patch later, but for now we can just keep it equivalent to the original code as you've done.

We'll have the same problem in fs/crypto/ in a week or two if/when I apply another patch series. For that one I'll send you a merge resolution so you don't have to do it yourself...

Thanks,

- Eric

#2 lore raw

Hi Eric,

Quoted 10 lines · On Mon, 29 Jul 2019 20:47:04 -0700 Eric Biggers <[email protected]> wrote:

fs/verity/signature.c static inline int __init fsverity_sysctl_init(void) · line 136

Quoted 3 lines · Stephen Rothwell
fs/verity/signature.c +3 -0
+static struct key_acl fsverity_acl = {
+	.usage	= REFCOUNT_INIT(1),
+	.possessor_viewable = true,  

I don't think .possessor_viewable should be set here, since there's no KEY_POSSESSOR_ACE(KEY_ACE_VIEW) in the ACL. David, this bool is supposed to mean such an entry is present, right? Is it really necessary, since it's redundant with the ACL itself?

OK, I can take that out of the patch for tomorrow.

Quoted 3 lines

Otherwise this looks good, thanks Stephen. I'll want to remove a few of these permissions in a separate patch later, but for now we can just keep it equivalent to the original code as you've done.

Thanks for the review.

Quoted 3 lines

We'll have the same problem in fs/crypto/ in a week or two if/when I apply another patch series. For that one I'll send you a merge resolution so you don't have to do it yourself...

That will be great, thanks.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer
#3 lore raw
Quoted 14 lines · Stephen Rothwell

Hi Eric,

Quoted 10 lines · On Mon, 29 Jul 2019 20:47:04 -0700 Eric Biggers <[email protected]> wrote:

fs/verity/signature.c static inline int __init fsverity_sysctl_init(void) · line 136

Quoted 3 lines · Stephen Rothwell
fs/verity/signature.c +3 -0
+static struct key_acl fsverity_acl = {
+	.usage	= REFCOUNT_INIT(1),
+	.possessor_viewable = true,  

I don't think .possessor_viewable should be set here, since there's no KEY_POSSESSOR_ACE(KEY_ACE_VIEW) in the ACL. David, this bool is supposed to mean such an entry is present, right? Is it really necessary, since it's redundant with the ACL itself?

Quoted 8 lines

OK, I can take that out of the patch for tomorrow.

Quoted 3 lines

Otherwise this looks good, thanks Stephen. I'll want to remove a few of these permissions in a separate patch later, but for now we can just keep it equivalent to the original code as you've done.

Thanks for the review.

Hmm, apparently it's not *exactly* equivalent, since the ACL is missing INVAL and JOIN permission for the owner, while those were originally granted by SEARCH permission. We don't need those, but just to keep the merge resolution itself as boring as possible, can you please use the following to make it equivalent:

static struct key_acl fsverity_acl = {
	.usage	= REFCOUNT_INIT(1),
	.nr_ace	= 2,
	.aces = {
		KEY_POSSESSOR_ACE(KEY_ACE_SEARCH | KEY_ACE_JOIN |
				  KEY_ACE_INVAL),
		KEY_OWNER_ACE(KEY_ACE_VIEW | KEY_ACE_READ | KEY_ACE_WRITE |
			      KEY_ACE_SEARCH | KEY_ACE_SET_SECURITY |
			      KEY_ACE_INVAL | KEY_ACE_REVOKE | KEY_ACE_JOIN |
			      KEY_ACE_CLEAR),
	}
};

Thanks!

- Eric

#4 lore raw

Hi Eric,

Quoted 29 lines · On Tue, 30 Jul 2019 18:40:34 -0700 Eric Biggers <[email protected]> wrote:
Quoted 14 lines · Stephen Rothwell

Hi Eric,

Quoted 10 lines · On Mon, 29 Jul 2019 20:47:04 -0700 Eric Biggers <[email protected]> wrote:

fs/verity/signature.c static inline int __init fsverity_sysctl_init(void) · line 136

Quoted 3 lines · Stephen Rothwell
fs/verity/signature.c +3 -0
+static struct key_acl fsverity_acl = {
+	.usage	= REFCOUNT_INIT(1),
+	.possessor_viewable = true,    

I don't think .possessor_viewable should be set here, since there's no KEY_POSSESSOR_ACE(KEY_ACE_VIEW) in the ACL. David, this bool is supposed to mean such an entry is present, right? Is it really necessary, since it's redundant with the ACL itself?

Quoted 7 lines

OK, I can take that out of the patch for tomorrow.

Quoted 3 lines

Otherwise this looks good, thanks Stephen. I'll want to remove a few of these permissions in a separate patch later, but for now we can just keep it equivalent to the original code as you've done.

Thanks for the review.

Hmm, apparently it's not *exactly* equivalent, since the ACL is missing INVAL and JOIN permission for the owner, while those were originally granted by SEARCH permission. We don't need those, but just to keep the merge resolution itself as boring as possible, can you please use the following to make it equivalent:

Quoted 12 lines
static struct key_acl fsverity_acl = {
	.usage	= REFCOUNT_INIT(1),
	.nr_ace	= 2,
	.aces = {
		KEY_POSSESSOR_ACE(KEY_ACE_SEARCH | KEY_ACE_JOIN |
				  KEY_ACE_INVAL),
		KEY_OWNER_ACE(KEY_ACE_VIEW | KEY_ACE_READ | KEY_ACE_WRITE |
			      KEY_ACE_SEARCH | KEY_ACE_SET_SECURITY |
			      KEY_ACE_INVAL | KEY_ACE_REVOKE | KEY_ACE_JOIN |
			      KEY_ACE_CLEAR),
	}
};

OK, I have fixed up the patch for today (not quite as above, but equivalently since I am editting a patch and I usually get that wrong :-))

Signature · 2 lines
Cheers,
Stephen Rothwell