* [PATCH] staging: erofs: refuse to mount images with malformed volume name
@ 2019-08-18 10:28 Gao Xiang
2019-08-18 12:18 ` kbuild test robot
2019-08-18 13:17 ` Chao Yu
0 siblings, 2 replies; 3+ messages in thread
From: Gao Xiang @ 2019-08-18 10:28 UTC (permalink / raw)
To: Chao Yu, Richard Weinberger, Greg Kroah-Hartman, devel, linux-fsdevel
Cc: LKML, linux-erofs, Chao Yu, Miao Xie, Fang Wei, Gao Xiang
From: Gao Xiang <gaoxiang25@huawei.com>
As Richard reminder [1], A valid volume name should be
ended in NIL terminator within the length of volume_name.
Since this field currently isn't really used, let's fix
it to avoid potential bugs in the future.
[1] https://lore.kernel.org/r/1133002215.69049.1566119033047.JavaMail.zimbra@nod.at/
Reported-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
drivers/staging/erofs/super.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index f65a1ff9f42f..2da471010a86 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -131,9 +131,14 @@ static int superblock_read(struct super_block *sb)
sbi->build_time_nsec = le32_to_cpu(layout->build_time_nsec);
memcpy(&sb->s_uuid, layout->uuid, sizeof(layout->uuid));
- memcpy(sbi->volume_name, layout->volume_name,
- sizeof(layout->volume_name));
+ ret = strscpy(sbi->volume_name, layout->volume_name,
+ sizeof(layout->volume_name));
+ if (ret < 0) { /* -E2BIG */
+ errln("bad volume name without NIL terminator");
+ ret = -EFSCORRUPTED;
+ goto out;
+ }
ret = 0;
out:
brelse(bh);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: erofs: refuse to mount images with malformed volume name
2019-08-18 10:28 [PATCH] staging: erofs: refuse to mount images with malformed volume name Gao Xiang
@ 2019-08-18 12:18 ` kbuild test robot
2019-08-18 13:17 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2019-08-18 12:18 UTC (permalink / raw)
To: Gao Xiang
Cc: kbuild-all, Chao Yu, Richard Weinberger, Greg Kroah-Hartman,
devel, linux-fsdevel, linux-erofs, Chao Yu, LKML, Fang Wei,
Miao Xie
[-- Attachment #1: Type: text/plain, Size: 2134 bytes --]
Hi Gao,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc4 next-20190816]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gao-Xiang/staging-erofs-refuse-to-mount-images-with-malformed-volume-name/20190818-193037
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/staging/erofs/super.c: In function 'superblock_read':
>> drivers/staging/erofs/super.c:153:10: error: 'EFSCORRUPTED' undeclared (first use in this function); did you mean 'FS_NRSUPER'?
ret = -EFSCORRUPTED;
^~~~~~~~~~~~
FS_NRSUPER
drivers/staging/erofs/super.c:153:10: note: each undeclared identifier is reported only once for each function it appears in
vim +153 drivers/staging/erofs/super.c
140
141 sbi->root_nid = le16_to_cpu(layout->root_nid);
142 sbi->inos = le64_to_cpu(layout->inos);
143
144 sbi->build_time = le64_to_cpu(layout->build_time);
145 sbi->build_time_nsec = le32_to_cpu(layout->build_time_nsec);
146
147 memcpy(&sb->s_uuid, layout->uuid, sizeof(layout->uuid));
148
149 ret = strscpy(sbi->volume_name, layout->volume_name,
150 sizeof(layout->volume_name));
151 if (ret < 0) { /* -E2BIG */
152 errln("bad volume name without NIL terminator");
> 153 ret = -EFSCORRUPTED;
154 goto out;
155 }
156 ret = 0;
157 out:
158 brelse(bh);
159 return ret;
160 }
161
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 58668 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: erofs: refuse to mount images with malformed volume name
2019-08-18 10:28 [PATCH] staging: erofs: refuse to mount images with malformed volume name Gao Xiang
2019-08-18 12:18 ` kbuild test robot
@ 2019-08-18 13:17 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2019-08-18 13:17 UTC (permalink / raw)
To: Gao Xiang, Chao Yu, Richard Weinberger, Greg Kroah-Hartman,
devel, linux-fsdevel
Cc: LKML, linux-erofs, Miao Xie, Fang Wei, Gao Xiang
On 2019-8-18 18:28, Gao Xiang wrote:
> From: Gao Xiang <gaoxiang25@huawei.com>
>
> As Richard reminder [1], A valid volume name should be
> ended in NIL terminator within the length of volume_name.
>
> Since this field currently isn't really used, let's fix
> it to avoid potential bugs in the future.
>
> [1] https://lore.kernel.org/r/1133002215.69049.1566119033047.JavaMail.zimbra@nod.at/
>
> Reported-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-18 13:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-18 10:28 [PATCH] staging: erofs: refuse to mount images with malformed volume name Gao Xiang
2019-08-18 12:18 ` kbuild test robot
2019-08-18 13:17 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).