diff mbox series

cred: Fix RCU warnings in override/revert_creds

Message ID Z8QGQGW0IaSklKG7@gondor.apana.org.au (mailing list archive)
State New
Headers show
Series cred: Fix RCU warnings in override/revert_creds | expand

Commit Message

Herbert Xu March 2, 2025, 7:18 a.m. UTC
Fix RCU warnings in override_creds and revert_creds by turning
the RCU pointer into a normal pointer using rcu_replace_pointer.

These warnings were previously private to the cred code, but due
to the move into the header file they are now polluting unrelated
subsystems.

Fixes: 49dffdfde462 ("cred: Add a light version of override/revert_creds()")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Christian Brauner March 2, 2025, 12:01 p.m. UTC | #1
On Sun, 02 Mar 2025 15:18:24 +0800, Herbert Xu wrote:
> Fix RCU warnings in override_creds and revert_creds by turning
> the RCU pointer into a normal pointer using rcu_replace_pointer.
> 
> These warnings were previously private to the cred code, but due
> to the move into the header file they are now polluting unrelated
> subsystems.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] cred: Fix RCU warnings in override/revert_creds
      https://git.kernel.org/vfs/vfs/c/e04918dc5946
diff mbox series

Patch

diff --git a/include/linux/cred.h b/include/linux/cred.h
index 0c3c4b16b469..5658a3bfe803 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -172,18 +172,12 @@  static inline bool cap_ambient_invariant_ok(const struct cred *cred)
 
 static inline const struct cred *override_creds(const struct cred *override_cred)
 {
-	const struct cred *old = current->cred;
-
-	rcu_assign_pointer(current->cred, override_cred);
-	return old;
+	return rcu_replace_pointer(current->cred, override_cred, 1);
 }
 
 static inline const struct cred *revert_creds(const struct cred *revert_cred)
 {
-	const struct cred *override_cred = current->cred;
-
-	rcu_assign_pointer(current->cred, revert_cred);
-	return override_cred;
+	return rcu_replace_pointer(current->cred, revert_cred, 1);
 }
 
 /**