mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] KEYS: allow reaching the keys quotas exactly
@ 2019-02-14 16:19 David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2019-02-14 16:19 UTC (permalink / raw)
  To: jmorris; +Cc: linux-security-module, keyrings, dhowells, ebiggers, linux-kernel

From: Eric Biggers <ebiggers@google.com>

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: 0b77f5bfb45c ("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>
---

 security/keys/key.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/keys/key.c b/security/keys/key.c
index 44a80d6741a1..0ec9322af4f9 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -265,8 +265,8 @@ struct key *key_alloc(struct key_type *type, const char *desc,
 
 		spin_lock(&user->lock);
 		if (!(flags & KEY_ALLOC_QUOTA_OVERRUN)) {
-			if (user->qnkeys + 1 >= maxkeys ||
-			    user->qnbytes + quotalen >= maxbytes ||
+			if (user->qnkeys + 1 > maxkeys ||
+			    user->qnbytes + quotalen > maxbytes ||
 			    user->qnbytes + quotalen < user->qnbytes)
 				goto no_quota;
 		}


^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH 0/4] keys: Miscellaneous fixes
@ 2019-02-14 16:19 David Howells
  2019-02-14 16:20 ` [PATCH 1/4] KEYS: allow reaching the keys quotas exactly David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2019-02-14 16:19 UTC (permalink / raw)
  To: jmorris; +Cc: linux-security-module, keyrings, dhowells, ebiggers, linux-kernel


Hi James,

Here are some keyrings fixes.

 (1) Handle quotas better, allowing full quota to be reached.

 (2) Fix the creation of shortcuts in the assoc_array internal
     representation when the index key needs to be an exact multiple of the
     machine word size.

 (3) Fix a dependency loop between the request_key contruction record and
     the request_key authentication key.  The construction record isn't
     really necessary and can be dispensed with.

 (4) Set the timestamp on a new key rather than leaving it as 0.  This
     would ordinarily be fine - provided the system clock is never set to a
     time before 1970.

The patches can be found here tagged thusly:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
	keys-fixes-20190214

and also on the following branch:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=keys-fixes

David
---
David Howells (3):
      assoc_array: Fix shortcut creation
      keys: Fix dependency loop between construction record and auth key
      keys: Timestamp new keys

Eric Biggers (1):
      KEYS: allow reaching the keys quotas exactly


 fs/nfs/nfs4idmap.c                   |   31 ++++++++-------
 include/keys/request_key_auth-type.h |   36 +++++++++++++++++
 include/linux/key-type.h             |   22 +++-------
 lib/assoc_array.c                    |    8 ++--
 security/keys/internal.h             |   13 ------
 security/keys/key.c                  |    5 +-
 security/keys/keyctl.c               |    1 
 security/keys/process_keys.c         |    1 
 security/keys/request_key.c          |   72 ++++++++++++++--------------------
 security/keys/request_key_auth.c     |   16 ++++----
 10 files changed, 108 insertions(+), 97 deletions(-)
 create mode 100644 include/keys/request_key_auth-type.h


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-14 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 16:19 [PATCH 1/4] KEYS: allow reaching the keys quotas exactly David Howells
2019-02-14 16:19 [PATCH 0/4] keys: Miscellaneous fixes David Howells
2019-02-14 16:20 ` [PATCH 1/4] KEYS: allow reaching the keys quotas exactly David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®