summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-12-15 13:24:10 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-20 15:38:01 +0100
commit123e44b9a49a42ff5313ec65256f1540d7c52fa0 (patch)
treeae2e919e5a7a554a804e343e2ee02e556ec1a6f9 /include/linux
parent7023ef19d984a202e052404bd24da3f0823ff906 (diff)
cred: switch to using atomic_long_t
commit f8fa5d76925991976b3e7076f9d1052515ec1fca upstream. There are multiple ways to grab references to credentials, and the only protection we have against overflowing it is the memory required to do so. With memory sizes only moving in one direction, let's bump the reference count to 64-bit and move it outside the realm of feasibly overflowing. Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cred.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 4b081e4911c8..62509a19ea08 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -114,7 +114,7 @@ static inline int groups_search(const struct group_info *group_info, kgid_t grp)
* same context as task->real_cred.
*/
struct cred {
- atomic_t usage;
+ atomic_long_t usage;
#ifdef CONFIG_DEBUG_CREDENTIALS
atomic_t subscribers; /* number of processes subscribed */
void *put_addr;
@@ -231,7 +231,7 @@ static inline bool cap_ambient_invariant_ok(const struct cred *cred)
*/
static inline struct cred *get_new_cred(struct cred *cred)
{
- atomic_inc(&cred->usage);
+ atomic_long_inc(&cred->usage);
return cred;
}
@@ -275,7 +275,7 @@ static inline void put_cred(const struct cred *_cred)
if (cred) {
validate_creds(cred);
- if (atomic_dec_and_test(&(cred)->usage))
+ if (atomic_long_dec_and_test(&(cred)->usage))
__put_cred(cred);
}
}