mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
ovl: port ovl_nlink_start() to cred guard
Use the scoped ovl cred guard. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-28-b31603935724@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
@@ -1147,7 +1147,6 @@ fail:
|
||||
int ovl_nlink_start(struct dentry *dentry)
|
||||
{
|
||||
struct inode *inode = d_inode(dentry);
|
||||
const struct cred *old_cred;
|
||||
int err;
|
||||
|
||||
if (WARN_ON(!inode))
|
||||
@@ -1184,15 +1183,14 @@ int ovl_nlink_start(struct dentry *dentry)
|
||||
if (d_is_dir(dentry) || !ovl_test_flag(OVL_INDEX, inode))
|
||||
return 0;
|
||||
|
||||
old_cred = ovl_override_creds(dentry->d_sb);
|
||||
/*
|
||||
* The overlay inode nlink should be incremented/decremented IFF the
|
||||
* upper operation succeeds, along with nlink change of upper inode.
|
||||
* Therefore, before link/unlink/rename, we store the union nlink
|
||||
* value relative to the upper inode nlink in an upper inode xattr.
|
||||
*/
|
||||
err = ovl_set_nlink_upper(dentry);
|
||||
ovl_revert_creds(old_cred);
|
||||
with_ovl_creds(dentry->d_sb)
|
||||
err = ovl_set_nlink_upper(dentry);
|
||||
if (err)
|
||||
goto out_drop_write;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user