Skip to content

Commit 955a355

Browse files
amir73ilgregkh
authored andcommitted
ovl: pass realinode to ovl_encode_real_fh() instead of realdentry
commit 07aeefa upstream. We want to be able to encode an fid from an inode with no alias. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20250105162404.357058-2-amir73il@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org> Stable-dep-of: c45beeb ("ovl: support encoding fid from inode with no alias") Signed-off-by: Sasha Levin <sashal@kernel.org> [re-applied over v6.6.71 with conflict resolved] Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ec3e32d commit 955a355

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

fs/overlayfs/copy_up.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upperdentry,
371371
return err;
372372
}
373373

374-
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
374+
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
375375
bool is_upper)
376376
{
377377
struct ovl_fh *fh;
378378
int fh_type, dwords;
379379
int buflen = MAX_HANDLE_SZ;
380-
uuid_t *uuid = &real->d_sb->s_uuid;
380+
uuid_t *uuid = &realinode->i_sb->s_uuid;
381381
int err;
382382

383383
/* Make sure the real fid stays 32bit aligned */
@@ -394,7 +394,8 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
394394
* the price or reconnecting the dentry.
395395
*/
396396
dwords = buflen >> 2;
397-
fh_type = exportfs_encode_fh(real, (void *)fh->fb.fid, &dwords, 0);
397+
fh_type = exportfs_encode_inode_fh(realinode, (void *)fh->fb.fid,
398+
&dwords, NULL, 0);
398399
buflen = (dwords << 2);
399400

400401
err = -EIO;
@@ -438,7 +439,7 @@ int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower,
438439
* up and a pure upper inode.
439440
*/
440441
if (ovl_can_decode_fh(lower->d_sb)) {
441-
fh = ovl_encode_real_fh(ofs, lower, false);
442+
fh = ovl_encode_real_fh(ofs, d_inode(lower), false);
442443
if (IS_ERR(fh))
443444
return PTR_ERR(fh);
444445
}
@@ -461,7 +462,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
461462
const struct ovl_fh *fh;
462463
int err;
463464

464-
fh = ovl_encode_real_fh(ofs, upper, true);
465+
fh = ovl_encode_real_fh(ofs, d_inode(upper), true);
465466
if (IS_ERR(fh))
466467
return PTR_ERR(fh);
467468

fs/overlayfs/export.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ static int ovl_check_encode_origin(struct dentry *dentry)
228228
static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
229229
u32 *fid, int buflen)
230230
{
231+
struct inode *inode = d_inode(dentry);
231232
struct ovl_fh *fh = NULL;
232233
int err, enc_lower;
233234
int len;
@@ -241,8 +242,8 @@ static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
241242
goto fail;
242243

243244
/* Encode an upper or lower file handle */
244-
fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) :
245-
ovl_dentry_upper(dentry), !enc_lower);
245+
fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_inode_lower(inode) :
246+
ovl_inode_upper(inode), !enc_lower);
246247
if (IS_ERR(fh))
247248
return PTR_ERR(fh);
248249

fs/overlayfs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
523523
struct ovl_fh *fh;
524524
int err;
525525

526-
fh = ovl_encode_real_fh(ofs, real, is_upper);
526+
fh = ovl_encode_real_fh(ofs, d_inode(real), is_upper);
527527
err = PTR_ERR(fh);
528528
if (IS_ERR(fh)) {
529529
fh = NULL;
@@ -720,7 +720,7 @@ int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
720720
struct ovl_fh *fh;
721721
int err;
722722

723-
fh = ovl_encode_real_fh(ofs, origin, false);
723+
fh = ovl_encode_real_fh(ofs, d_inode(origin), false);
724724
if (IS_ERR(fh))
725725
return PTR_ERR(fh);
726726

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ int ovl_copy_up_with_data(struct dentry *dentry);
821821
int ovl_maybe_copy_up(struct dentry *dentry, int flags);
822822
int ovl_copy_xattr(struct super_block *sb, const struct path *path, struct dentry *new);
823823
int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upper, struct kstat *stat);
824-
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
824+
struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
825825
bool is_upper);
826826
int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower,
827827
struct dentry *upper);

0 commit comments

Comments
 (0)