fs/udf/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The KASAN report is:
[ 1922.586560] BUG: KASAN: slab-out-of-bounds in udf_readdir+0xe00/0x19e0
[ 1922.586922] Write of size 89 at addr ffff888000cd9ea6 by task rm/18493
udf_readdir() tries to write file name out of allocated memory
buffer bounds. The UDF_NAME_LEN_CS0 (255) is used as max length
for file name in udf_put_filename(). But UDF_NAME_LEN (254) is
used as the size for buffer allocation in udf_readdir(). As the
result out-of-bounds write happened.
Found by Linux Verification Center (linuxtesting.org) with xfstests
Fixes: 066b9cded00b ("udf: Use separate buffer for copying split names")
Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru>
---
fs/udf/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index be640f4b2f2c..b95607c42ad4 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -169,7 +169,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
} else {
if (!copy_name) {
- copy_name = kmalloc(UDF_NAME_LEN,
+ copy_name = kmalloc(UDF_NAME_LEN_CS0,
GFP_NOFS);
if (!copy_name) {
ret = -ENOMEM;
--
2.34.1
On Mon 06-02-23 19:22:06, Vladislav Efanov wrote: > The KASAN report is: > [ 1922.586560] BUG: KASAN: slab-out-of-bounds in udf_readdir+0xe00/0x19e0 > [ 1922.586922] Write of size 89 at addr ffff888000cd9ea6 by task rm/18493 > > udf_readdir() tries to write file name out of allocated memory > buffer bounds. The UDF_NAME_LEN_CS0 (255) is used as max length > for file name in udf_put_filename(). But UDF_NAME_LEN (254) is > used as the size for buffer allocation in udf_readdir(). As the > result out-of-bounds write happened. > > Found by Linux Verification Center (linuxtesting.org) with xfstests > > Fixes: 066b9cded00b ("udf: Use separate buffer for copying split names") > Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru> Thanks for the fix Vladislav! But this code is not there anymore in current version of UDF code. It got fixed as part of the directory code rewrite - you can check current code state in my tree: git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git for_next Honza > --- > fs/udf/dir.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/udf/dir.c b/fs/udf/dir.c > index be640f4b2f2c..b95607c42ad4 100644 > --- a/fs/udf/dir.c > +++ b/fs/udf/dir.c > @@ -169,7 +169,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) > nameptr = (char *)(fibh.ebh->b_data + poffset - lfi); > } else { > if (!copy_name) { > - copy_name = kmalloc(UDF_NAME_LEN, > + copy_name = kmalloc(UDF_NAME_LEN_CS0, > GFP_NOFS); > if (!copy_name) { > ret = -ENOMEM; > -- > 2.34.1 > -- Jan Kara <jack@suse.com> SUSE Labs, CR
Thank you for the information. Will check this repository in the future. Vlad. On 07.02.2023 15:44, Jan Kara wrote: > On Mon 06-02-23 19:22:06, Vladislav Efanov wrote: >> The KASAN report is: >> [ 1922.586560] BUG: KASAN: slab-out-of-bounds in udf_readdir+0xe00/0x19e0 >> [ 1922.586922] Write of size 89 at addr ffff888000cd9ea6 by task rm/18493 >> >> udf_readdir() tries to write file name out of allocated memory >> buffer bounds. The UDF_NAME_LEN_CS0 (255) is used as max length >> for file name in udf_put_filename(). But UDF_NAME_LEN (254) is >> used as the size for buffer allocation in udf_readdir(). As the >> result out-of-bounds write happened. >> >> Found by Linux Verification Center (linuxtesting.org) with xfstests >> >> Fixes: 066b9cded00b ("udf: Use separate buffer for copying split names") >> Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru> > Thanks for the fix Vladislav! But this code is not there anymore in current > version of UDF code. It got fixed as part of the directory code rewrite - > you can check current code state in my tree: > > git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git for_next > > Honza > >> --- >> fs/udf/dir.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/udf/dir.c b/fs/udf/dir.c >> index be640f4b2f2c..b95607c42ad4 100644 >> --- a/fs/udf/dir.c >> +++ b/fs/udf/dir.c >> @@ -169,7 +169,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) >> nameptr = (char *)(fibh.ebh->b_data + poffset - lfi); >> } else { >> if (!copy_name) { >> - copy_name = kmalloc(UDF_NAME_LEN, >> + copy_name = kmalloc(UDF_NAME_LEN_CS0, >> GFP_NOFS); >> if (!copy_name) { >> ret = -ENOMEM; >> -- >> 2.34.1 >>
© 2016 - 2025 Red Hat, Inc.