Re: [PATCH] keys: Make the KEY_NEED_* perms an enum rather than a mask
From: David Howells
Date: Wed May 13 2020 - 19:25:30 EST
Casey Schaufler <casey@xxxxxxxxxxxxxxxx> wrote:
> > - if (perm & ~KEY_NEED_ALL)
> > - return -EINVAL;
> > + switch (need_perm) {
> > + default:
> > + return -EACCES;
> ...
> Is the change from -EINVAL to -EACCES a bug fix?
> Does it introduce an incompatibility?
It shouldn't happen. All the actual cases should be covered explicitly in the
switch. It's to catch a programming issue in the kernel where a new value
gets added to the enum but not propagated to all the places that check for it.
I'd actually prefer it to be something even more obvious, especially as EINVAL
is so widely used in the kernel. Should I put a WARN_ON in there?
David