Skip to content

Commit 0260b0a

Browse files
committed
Merge tag 'exfat-for-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat
Pull exfat updates from Namjae Jeon: - Fix deadlock issue reported by syzbot - Handle idmapped mounts * tag 'exfat-for-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat: exfat: fix potential deadlock on __exfat_get_dentry_set exfat: handle idmapped mounts
2 parents a1b547f + 89fc548 commit 0260b0a

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

fs/exfat/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es,
813813

814814
num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb);
815815
if (num_bh > ARRAY_SIZE(es->__bh)) {
816-
es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_KERNEL);
816+
es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_NOFS);
817817
if (!es->bh) {
818818
brelse(bh);
819819
return -ENOMEM;

fs/exfat/file.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
8989
return -EIO;
9090
}
9191

92-
static bool exfat_allow_set_time(struct exfat_sb_info *sbi, struct inode *inode)
92+
static bool exfat_allow_set_time(struct mnt_idmap *idmap,
93+
struct exfat_sb_info *sbi, struct inode *inode)
9394
{
9495
mode_t allow_utime = sbi->options.allow_utime;
9596

96-
if (!uid_eq(current_fsuid(), inode->i_uid)) {
97-
if (in_group_p(inode->i_gid))
97+
if (!vfsuid_eq_kuid(i_uid_into_vfsuid(idmap, inode),
98+
current_fsuid())) {
99+
if (vfsgid_in_group_p(i_gid_into_vfsgid(idmap, inode)))
98100
allow_utime >>= 3;
99101
if (allow_utime & MAY_WRITE)
100102
return true;
@@ -283,7 +285,7 @@ int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
283285
struct inode *inode = d_backing_inode(path->dentry);
284286
struct exfat_inode_info *ei = EXFAT_I(inode);
285287

286-
generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
288+
generic_fillattr(idmap, request_mask, inode, stat);
287289
exfat_truncate_atime(&stat->atime);
288290
stat->result_mask |= STATX_BTIME;
289291
stat->btime.tv_sec = ei->i_crtime.tv_sec;
@@ -311,20 +313,22 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
311313
/* Check for setting the inode time. */
312314
ia_valid = attr->ia_valid;
313315
if ((ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) &&
314-
exfat_allow_set_time(sbi, inode)) {
316+
exfat_allow_set_time(idmap, sbi, inode)) {
315317
attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET |
316318
ATTR_TIMES_SET);
317319
}
318320

319-
error = setattr_prepare(&nop_mnt_idmap, dentry, attr);
321+
error = setattr_prepare(idmap, dentry, attr);
320322
attr->ia_valid = ia_valid;
321323
if (error)
322324
goto out;
323325

324326
if (((attr->ia_valid & ATTR_UID) &&
325-
!uid_eq(attr->ia_uid, sbi->options.fs_uid)) ||
327+
(!uid_eq(from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid),
328+
sbi->options.fs_uid))) ||
326329
((attr->ia_valid & ATTR_GID) &&
327-
!gid_eq(attr->ia_gid, sbi->options.fs_gid)) ||
330+
(!gid_eq(from_vfsgid(idmap, i_user_ns(inode), attr->ia_vfsgid),
331+
sbi->options.fs_gid))) ||
328332
((attr->ia_valid & ATTR_MODE) &&
329333
(attr->ia_mode & ~(S_IFREG | S_IFLNK | S_IFDIR | 0777)))) {
330334
error = -EPERM;
@@ -343,7 +347,7 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
343347
if (attr->ia_valid & ATTR_SIZE)
344348
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
345349

346-
setattr_copy(&nop_mnt_idmap, inode, attr);
350+
setattr_copy(idmap, inode, attr);
347351
exfat_truncate_inode_atime(inode);
348352

349353
if (attr->ia_valid & ATTR_SIZE) {

fs/exfat/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ static struct file_system_type exfat_fs_type = {
788788
.init_fs_context = exfat_init_fs_context,
789789
.parameters = exfat_parameters,
790790
.kill_sb = exfat_kill_sb,
791-
.fs_flags = FS_REQUIRES_DEV,
791+
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
792792
};
793793

794794
static void exfat_inode_init_once(void *foo)

0 commit comments

Comments
 (0)