security, keys: convert key_user.usage from atomic_t to refcount_t
refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental refcounter overflows that might lead to use-after-free situations. Signed-off-by: Elena Reshetova <elena.reshetova@intel.com> Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David Windsor <dwindsor@gmail.com> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
This commit is contained in:

committed by
James Morris

parent
fff292914d
commit
ddb99e118e
@@ -17,6 +17,7 @@
|
||||
#include <linux/key-type.h>
|
||||
#include <linux/task_work.h>
|
||||
#include <linux/keyctl.h>
|
||||
#include <linux/refcount.h>
|
||||
|
||||
struct iovec;
|
||||
|
||||
@@ -53,7 +54,7 @@ struct key_user {
|
||||
struct rb_node node;
|
||||
struct mutex cons_lock; /* construction initiation lock */
|
||||
spinlock_t lock;
|
||||
atomic_t usage; /* for accessing qnkeys & qnbytes */
|
||||
refcount_t usage; /* for accessing qnkeys & qnbytes */
|
||||
atomic_t nkeys; /* number of keys */
|
||||
atomic_t nikeys; /* number of instantiated keys */
|
||||
kuid_t uid;
|
||||
|
Reference in New Issue
Block a user