From: golasch18@web.de
To: Jan Kara <jack@suse.com>
Cc: linux-kernel@vger.kernel.org, Lukas Blesser <golasch18@web.de>,
syzbot+de2fef01040748da6822@syzkaller.appspotmail.com
Subject: [PATCH] udf: fix WARN_ON_ONCE in udf_map_block on concurrent expand failure
Date: Sat, 19 Sep 2026 15:44:31 +0200 [thread overview]
Message-ID: <20260919134431.83785-1-golasch18@web.de> (raw)
From: Lukas Blesser <golasch18@web.de>
udf_direct_IO() falls back to buffered I/O for in-ICB files, but it
checks i_alloc_type without holding i_data_sem. If a concurrent write
fails to expand the file, udf_expand_file_adinicb() restores inline
allocation, so udf_map_block() can observe ICBTAG_FLAG_AD_IN_ICB after
the caller checked and hit the WARN_ON_ONCE() for a transient state.
Move the allocation-type check under the down_read() udf_map_block()
already takes on the lookup path and return -EFSCORRUPTED gracefully
instead of warning.
Reported-by: syzbot+de2fef01040748da6822@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=de2fef01040748da6822
Signed-off-by: Lukas Blesser <golasch18@web.de>
---
fs/udf/inode.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index e45e546a7..cea8d5c4d 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -352,9 +352,6 @@ static int udf_map_block(struct inode *inode, struct udf_map_rq *map)
int ret;
struct udf_inode_info *iinfo = UDF_I(inode);
- if (WARN_ON_ONCE(iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB))
- return -EFSCORRUPTED;
-
map->oflags = 0;
if (!(map->iflags & UDF_MAP_CREATE)) {
struct kernel_lb_addr eloc;
@@ -364,6 +361,18 @@ static int udf_map_block(struct inode *inode, struct udf_map_rq *map)
int8_t etype;
down_read(&iinfo->i_data_sem);
+ /*
+ * The allocation type may have changed back to in-ICB
+ * after a caller checked it without holding i_data_sem:
+ * e.g. a concurrent expand failure restores inline
+ * allocation in udf_expand_file_adinicb(). Recheck here
+ * under i_data_sem and fail gracefully instead of
+ * warning about a transient state.
+ */
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+ ret = -EFSCORRUPTED;
+ goto out_read;
+ }
ret = inode_bmap(inode, map->lblk, &epos, &eloc, &elen, &offset,
&etype);
if (ret < 0)
--
2.55.0
reply other threads:[~2026-09-19 13:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260919134431.83785-1-golasch18@web.de \
--to=golasch18@web.de \
--cc=jack@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+de2fef01040748da6822@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®