Skip to content

Commit 6b65522

Browse files
committed
Merge tag 'erofs-for-6.7-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: - Tidy up erofs_read_inode() for simplicity - Fix broken fscache mode due to NULL dereference of dif->bdev_handle - Add the EROFS webpage to MAINTAINERS, documentation, and Kconfig * tag 'erofs-for-6.7-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: MAINTAINERS: erofs: add EROFS webpage erofs: fix NULL dereference of dif->bdev_handle in fscache mode erofs: simplify erofs_read_inode()
2 parents 98b1cc8 + 62b241e commit 6b65522

File tree

5 files changed

+44
-66
lines changed

5 files changed

+44
-66
lines changed

Documentation/filesystems/erofs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ compatibility checking tool (fsck.erofs), and a debugging tool (dump.erofs):
9191

9292
- git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
9393

94+
For more information, please also refer to the documentation site:
95+
96+
- https://erofs.docs.kernel.org
97+
9498
Bugs and patches are welcome, please kindly help us and send to the following
9599
linux-erofs mailing list:
96100

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7855,6 +7855,7 @@ R: Yue Hu <[email protected]>
78557855
R: Jeffle Xu <[email protected]>
78567856
78577857
S: Maintained
7858+
W: https://erofs.docs.kernel.org
78587859
T: git git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
78597860
F: Documentation/ABI/testing/sysfs-fs-erofs
78607861
F: Documentation/filesystems/erofs.rst

fs/erofs/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ config EROFS_FS
2121
performance under extremely memory pressure without extra cost.
2222

2323
See the documentation at <file:Documentation/filesystems/erofs.rst>
24-
for more details.
24+
and the web pages at <https://erofs.docs.kernel.org> for more details.
2525

2626
If unsure, say N.
2727

fs/erofs/data.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
220220
up_read(&devs->rwsem);
221221
return 0;
222222
}
223-
map->m_bdev = dif->bdev_handle->bdev;
223+
map->m_bdev = dif->bdev_handle ? dif->bdev_handle->bdev : NULL;
224224
map->m_daxdev = dif->dax_dev;
225225
map->m_dax_part_off = dif->dax_part_off;
226226
map->m_fscache = dif->fscache;
@@ -238,7 +238,8 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
238238
if (map->m_pa >= startoff &&
239239
map->m_pa < startoff + length) {
240240
map->m_pa -= startoff;
241-
map->m_bdev = dif->bdev_handle->bdev;
241+
map->m_bdev = dif->bdev_handle ?
242+
dif->bdev_handle->bdev : NULL;
242243
map->m_daxdev = dif->dax_dev;
243244
map->m_dax_part_off = dif->dax_part_off;
244245
map->m_fscache = dif->fscache;

fs/erofs/inode.c

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ static void *erofs_read_inode(struct erofs_buf *buf,
1515
struct erofs_sb_info *sbi = EROFS_SB(sb);
1616
struct erofs_inode *vi = EROFS_I(inode);
1717
const erofs_off_t inode_loc = erofs_iloc(inode);
18-
1918
erofs_blk_t blkaddr, nblks = 0;
2019
void *kaddr;
2120
struct erofs_inode_compact *dic;
2221
struct erofs_inode_extended *die, *copied = NULL;
22+
union erofs_inode_i_u iu;
2323
unsigned int ifmt;
2424
int err;
2525

@@ -35,17 +35,16 @@ static void *erofs_read_inode(struct erofs_buf *buf,
3535

3636
dic = kaddr + *ofs;
3737
ifmt = le16_to_cpu(dic->i_format);
38-
3938
if (ifmt & ~EROFS_I_ALL) {
40-
erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu",
39+
erofs_err(sb, "unsupported i_format %u of nid %llu",
4140
ifmt, vi->nid);
4241
err = -EOPNOTSUPP;
4342
goto err_out;
4443
}
4544

4645
vi->datalayout = erofs_inode_datalayout(ifmt);
4746
if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
48-
erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
47+
erofs_err(sb, "unsupported datalayout %u of nid %llu",
4948
vi->datalayout, vi->nid);
5049
err = -EOPNOTSUPP;
5150
goto err_out;
@@ -82,40 +81,15 @@ static void *erofs_read_inode(struct erofs_buf *buf,
8281
vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount);
8382

8483
inode->i_mode = le16_to_cpu(die->i_mode);
85-
switch (inode->i_mode & S_IFMT) {
86-
case S_IFREG:
87-
case S_IFDIR:
88-
case S_IFLNK:
89-
vi->raw_blkaddr = le32_to_cpu(die->i_u.raw_blkaddr);
90-
break;
91-
case S_IFCHR:
92-
case S_IFBLK:
93-
inode->i_rdev =
94-
new_decode_dev(le32_to_cpu(die->i_u.rdev));
95-
break;
96-
case S_IFIFO:
97-
case S_IFSOCK:
98-
inode->i_rdev = 0;
99-
break;
100-
default:
101-
goto bogusimode;
102-
}
84+
iu = die->i_u;
10385
i_uid_write(inode, le32_to_cpu(die->i_uid));
10486
i_gid_write(inode, le32_to_cpu(die->i_gid));
10587
set_nlink(inode, le32_to_cpu(die->i_nlink));
106-
107-
/* extended inode has its own timestamp */
88+
/* each extended inode has its own timestamp */
10889
inode_set_ctime(inode, le64_to_cpu(die->i_mtime),
10990
le32_to_cpu(die->i_mtime_nsec));
11091

11192
inode->i_size = le64_to_cpu(die->i_size);
112-
113-
/* total blocks for compressed files */
114-
if (erofs_inode_is_data_compressed(vi->datalayout))
115-
nblks = le32_to_cpu(die->i_u.compressed_blocks);
116-
else if (vi->datalayout == EROFS_INODE_CHUNK_BASED)
117-
/* fill chunked inode summary info */
118-
vi->chunkformat = le16_to_cpu(die->i_u.c.format);
11993
kfree(copied);
12094
copied = NULL;
12195
break;
@@ -125,49 +99,51 @@ static void *erofs_read_inode(struct erofs_buf *buf,
12599
vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount);
126100

127101
inode->i_mode = le16_to_cpu(dic->i_mode);
128-
switch (inode->i_mode & S_IFMT) {
129-
case S_IFREG:
130-
case S_IFDIR:
131-
case S_IFLNK:
132-
vi->raw_blkaddr = le32_to_cpu(dic->i_u.raw_blkaddr);
133-
break;
134-
case S_IFCHR:
135-
case S_IFBLK:
136-
inode->i_rdev =
137-
new_decode_dev(le32_to_cpu(dic->i_u.rdev));
138-
break;
139-
case S_IFIFO:
140-
case S_IFSOCK:
141-
inode->i_rdev = 0;
142-
break;
143-
default:
144-
goto bogusimode;
145-
}
102+
iu = dic->i_u;
146103
i_uid_write(inode, le16_to_cpu(dic->i_uid));
147104
i_gid_write(inode, le16_to_cpu(dic->i_gid));
148105
set_nlink(inode, le16_to_cpu(dic->i_nlink));
149-
150106
/* use build time for compact inodes */
151107
inode_set_ctime(inode, sbi->build_time, sbi->build_time_nsec);
152108

153109
inode->i_size = le32_to_cpu(dic->i_size);
154-
if (erofs_inode_is_data_compressed(vi->datalayout))
155-
nblks = le32_to_cpu(dic->i_u.compressed_blocks);
156-
else if (vi->datalayout == EROFS_INODE_CHUNK_BASED)
157-
vi->chunkformat = le16_to_cpu(dic->i_u.c.format);
158110
break;
159111
default:
160-
erofs_err(inode->i_sb,
161-
"unsupported on-disk inode version %u of nid %llu",
112+
erofs_err(sb, "unsupported on-disk inode version %u of nid %llu",
162113
erofs_inode_version(ifmt), vi->nid);
163114
err = -EOPNOTSUPP;
164115
goto err_out;
165116
}
166117

167-
if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
118+
switch (inode->i_mode & S_IFMT) {
119+
case S_IFREG:
120+
case S_IFDIR:
121+
case S_IFLNK:
122+
vi->raw_blkaddr = le32_to_cpu(iu.raw_blkaddr);
123+
break;
124+
case S_IFCHR:
125+
case S_IFBLK:
126+
inode->i_rdev = new_decode_dev(le32_to_cpu(iu.rdev));
127+
break;
128+
case S_IFIFO:
129+
case S_IFSOCK:
130+
inode->i_rdev = 0;
131+
break;
132+
default:
133+
erofs_err(sb, "bogus i_mode (%o) @ nid %llu", inode->i_mode,
134+
vi->nid);
135+
err = -EFSCORRUPTED;
136+
goto err_out;
137+
}
138+
139+
/* total blocks for compressed files */
140+
if (erofs_inode_is_data_compressed(vi->datalayout)) {
141+
nblks = le32_to_cpu(iu.compressed_blocks);
142+
} else if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
143+
/* fill chunked inode summary info */
144+
vi->chunkformat = le16_to_cpu(iu.c.format);
168145
if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) {
169-
erofs_err(inode->i_sb,
170-
"unsupported chunk format %x of nid %llu",
146+
erofs_err(sb, "unsupported chunk format %x of nid %llu",
171147
vi->chunkformat, vi->nid);
172148
err = -EOPNOTSUPP;
173149
goto err_out;
@@ -191,10 +167,6 @@ static void *erofs_read_inode(struct erofs_buf *buf,
191167
inode->i_blocks = nblks << (sb->s_blocksize_bits - 9);
192168
return kaddr;
193169

194-
bogusimode:
195-
erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu",
196-
inode->i_mode, vi->nid);
197-
err = -EFSCORRUPTED;
198170
err_out:
199171
DBG_BUGON(1);
200172
kfree(copied);

0 commit comments

Comments
 (0)