From: Julian Sun <sunjunchao2870@gmail.com>
To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Cc: chandan.babu@oracle.com, djwong@kernel.org,
stable@vger.kernel.org, Julian Sun <sunjunchao2870@gmail.com>,
syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com,
Dave Chinner <david@fromorbit.com>
Subject: [PATCH 1/3] xfs: Do not unshare ranges beyond EOF
Date: Fri, 20 Sep 2024 20:26:21 +0800 [thread overview]
Message-ID: <20240920122621.215397-1-sunjunchao2870@gmail.com> (raw)
Attempting to unshare extents beyond EOF will trigger
the need zeroing case, which in turn triggers a warning.
Therefore, let's skip the unshare process if extents are
beyond EOF.
Reported-and-tested-by: syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=296b1c84b9cbf306e5a0
Fixes: 32a38a499104 ("iomap: use write_begin to read pages to unshare")
Inspired-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
fs/xfs/xfs_reflink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 6fde6ec8092f..65509ff6aba0 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -3,6 +3,7 @@
* Copyright (C) 2016 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <darrick.wong@oracle.com>
*/
+#include "linux/fs.h"
#include "xfs.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
@@ -1669,6 +1670,9 @@ xfs_reflink_unshare(
if (!xfs_is_reflink_inode(ip))
return 0;
+ /* don't try to unshare any ranges beyond EOF. */
+ if (offset + len > i_size_read(inode))
+ len = i_size_read(inode) - offset;
trace_xfs_reflink_unshare(ip, offset, len);
--
2.39.2
next reply other threads:[~2024-09-20 12:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 12:26 Julian Sun [this message]
2024-09-20 12:28 ` [PATCH 1/3] xfs: Do not unshare ranges beyond EOF kernel test robot
2024-09-20 14:23 ` Christoph Hellwig
2024-09-20 16:17 ` Julian Sun
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=20240920122621.215397-1-sunjunchao2870@gmail.com \
--to=sunjunchao2870@gmail.com \
--cc=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+296b1c84b9cbf306e5a0@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