From: Greg Kroah-Hartman Date: Tue, 5 Oct 2021 06:43:12 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.4.286~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87900a8a2e9b9c349e72950b5eb6e0b5958e9965;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: cred-allow-get_cred-and-put_cred-to-be-given-null.patch --- diff --git a/queue-4.14/cred-allow-get_cred-and-put_cred-to-be-given-null.patch b/queue-4.14/cred-allow-get_cred-and-put_cred-to-be-given-null.patch new file mode 100644 index 00000000000..ba61aac83ce --- /dev/null +++ b/queue-4.14/cred-allow-get_cred-and-put_cred-to-be-given-null.patch @@ -0,0 +1,67 @@ +From f06bc03339ad4c1baa964a5f0606247ac1c3c50b Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Mon, 3 Dec 2018 11:30:30 +1100 +Subject: cred: allow get_cred() and put_cred() to be given NULL. + +From: NeilBrown + +commit f06bc03339ad4c1baa964a5f0606247ac1c3c50b upstream. + +It is common practice for helpers like this to silently, +accept a NULL pointer. +get_rpccred() and put_rpccred() used by NFS act this way +and using the same interface will ease the conversion +for NFS, and simplify the resulting code. + +Signed-off-by: NeilBrown +Signed-off-by: Anna Schumaker +Cc: Eric Dumazet +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/cred.h | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +--- a/include/linux/cred.h ++++ b/include/linux/cred.h +@@ -235,7 +235,7 @@ static inline struct cred *get_new_cred( + * @cred: The credentials to reference + * + * Get a reference on the specified set of credentials. The caller must +- * release the reference. ++ * release the reference. If %NULL is passed, it is returned with no action. + * + * This is used to deal with a committed set of credentials. Although the + * pointer is const, this will temporarily discard the const and increment the +@@ -246,6 +246,8 @@ static inline struct cred *get_new_cred( + static inline const struct cred *get_cred(const struct cred *cred) + { + struct cred *nonconst_cred = (struct cred *) cred; ++ if (!cred) ++ return cred; + validate_creds(cred); + nonconst_cred->non_rcu = 0; + return get_new_cred(nonconst_cred); +@@ -256,7 +258,7 @@ static inline const struct cred *get_cre + * @cred: The credentials to release + * + * Release a reference to a set of credentials, deleting them when the last ref +- * is released. ++ * is released. If %NULL is passed, nothing is done. + * + * This takes a const pointer to a set of credentials because the credentials + * on task_struct are attached by const pointers to prevent accidental +@@ -266,9 +268,11 @@ static inline void put_cred(const struct + { + struct cred *cred = (struct cred *) _cred; + +- validate_creds(cred); +- if (atomic_dec_and_test(&(cred)->usage)) +- __put_cred(cred); ++ if (cred) { ++ validate_creds(cred); ++ if (atomic_dec_and_test(&(cred)->usage)) ++ __put_cred(cred); ++ } + } + + /** diff --git a/queue-4.14/series b/queue-4.14/series index 2de42db4c69..816efbe1f04 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -73,3 +73,4 @@ hid-betop-fix-slab-out-of-bounds-write-in-betop_probe.patch netfilter-ipset-fix-oversized-kvmalloc-calls.patch hid-usbhid-free-raw_report-buffers-in-usbhid_stop.patch net-mdiobus-fix-memory-leak-in-__mdiobus_register.patch +cred-allow-get_cred-and-put_cred-to-be-given-null.patch