]> git.baikalelectronics.ru Git - kernel.git/commit
KEYS: allow reaching the keys quotas exactly
authorEric Biggers <ebiggers@google.com>
Thu, 14 Feb 2019 16:20:01 +0000 (16:20 +0000)
committerJames Morris <james.morris@microsoft.com>
Fri, 15 Feb 2019 22:12:08 +0000 (14:12 -0800)
commit0b0742867b503042c6598bd78937f94d1aabe3aa
tree55aeebf54986fb1923cbee1d7f202e853b8f609b
parent3bc515da302440671ad31a3ad9079d1f7ff0a7bb
KEYS: allow reaching the keys quotas exactly

If the sysctl 'kernel.keys.maxkeys' is set to some number n, then
actually users can only add up to 'n - 1' keys.  Likewise for
'kernel.keys.maxbytes' and the root_* versions of these sysctls.  But
these sysctls are apparently supposed to be *maximums*, as per their
names and all documentation I could find -- the keyrings(7) man page,
Documentation/security/keys/core.rst, and all the mentions of EDQUOT
meaning that the key quota was *exceeded* (as opposed to reached).

Thus, fix the code to allow reaching the quotas exactly.

Fixes: af9cfda53d9c ("keys: make the keyring quotas controllable through /proc/sys")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <james.morris@microsoft.com>
security/keys/key.c