summaryrefslogtreecommitdiff
path: root/fs/udf/directory.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-02-09 12:33:09 +0300
committerJan Kara <jack@suse.cz>2023-02-09 12:37:12 +0300
commitdf97f64dfa317a5485daf247b6c043a584ef95f9 (patch)
treec1b7fd9247e7e24e6964bb8008ce3ab03c11428f /fs/udf/directory.c
parent51e38c92bed26f648ec187c4400fa7512fcd8067 (diff)
downloadlinux-df97f64dfa317a5485daf247b6c043a584ef95f9.tar.xz
udf: Avoid directory type conversion failure due to ENOMEM
When converting directory from in-ICB to normal format, the last iteration through the directory fixing up directory enteries can fail due to ENOMEM. We do not expect this iteration to fail since the directory is already verified to be correct and it is difficult to undo the conversion at this point. So just use GFP_NOFAIL to make sure the small allocation cannot fail. Reported-by: syzbot+111eaa994ff74f8d440f@syzkaller.appspotmail.com Fixes: 0aba4860b0d0 ("udf: Allocate name buffer in directory iterator on heap") Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/directory.c')
-rw-r--r--fs/udf/directory.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index e0bb73d414dd..654536d2b609 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -251,9 +251,12 @@ int udf_fiiter_init(struct udf_fileident_iter *iter, struct inode *dir,
iter->elen = 0;
iter->epos.bh = NULL;
iter->name = NULL;
- iter->namebuf = kmalloc(UDF_NAME_LEN_CS0, GFP_KERNEL);
- if (!iter->namebuf)
- return -ENOMEM;
+ /*
+ * When directory is verified, we don't expect directory iteration to
+ * fail and it can be difficult to undo without corrupting filesystem.
+ * So just do not allow memory allocation failures here.
+ */
+ iter->namebuf = kmalloc(UDF_NAME_LEN_CS0, GFP_KERNEL | __GFP_NOFAIL);
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
err = udf_copy_fi(iter);