linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cred: Fix RCU warnings in override/revert_creds
@ 2025-03-02  7:18 Herbert Xu
  2025-03-02 12:01 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2025-03-02  7:18 UTC (permalink / raw)
  To: Christian Brauner, Linus Torvalds, Vinicius Costa Gomes,
	Amir Goldstein, Linux Kernel Mailing List, linux-fsdevel

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>

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);
 }
 
 /**
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] cred: Fix RCU warnings in override/revert_creds
  2025-03-02  7:18 [PATCH] cred: Fix RCU warnings in override/revert_creds Herbert Xu
@ 2025-03-02 12:01 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2025-03-02 12:01 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Christian Brauner, Linus Torvalds, Vinicius Costa Gomes,
	Amir Goldstein, Linux Kernel Mailing List, linux-fsdevel

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

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

end of thread, other threads:[~2025-03-02 12:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02  7:18 [PATCH] cred: Fix RCU warnings in override/revert_creds Herbert Xu
2025-03-02 12:01 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).