cgroup: avoid pointless cred reference count bump

of->file->f_cred already holds a reference count that is stable during
the operation.

Link: https://lore.kernel.org/r/20241125-work-cred-v2-24-68b9d38bb5b2@kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2024-11-25 15:10:20 +01:00
parent 6256d2377e
commit 34ab26fb6b
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -5216,11 +5216,11 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
* permissions using the credentials from file open to protect against
* inherited fd attacks.
*/
saved_cred = override_creds(get_new_cred(of->file->f_cred));
saved_cred = override_creds(of->file->f_cred);
ret = cgroup_attach_permissions(src_cgrp, dst_cgrp,
of->file->f_path.dentry->d_sb,
threadgroup, ctx->ns);
put_cred(revert_creds(saved_cred));
revert_creds(saved_cred);
if (ret)
goto out_finish;