From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, "linux-erofs@lists.ozlabs.org,
LKML" <linux-kernel@vger.kernel.org>,
Colin Walters <walters@verbum.org>,
Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH 6.1 658/798] erofs: fix incorrect symlink detection in fast symlink
Date: Mon, 14 Oct 2024 16:20:12 +0200 [thread overview]
Message-ID: <20241014141243.902543910@linuxfoundation.org> (raw)
In-Reply-To: <20241014141217.941104064@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <hsiangkao@linux.alibaba.com>
commit 9ed50b8231e37b1ae863f5dec8153b98d9f389b4 upstream.
Fast symlink can be used if the on-disk symlink data is stored
in the same block as the on-disk inode, so we don’t need to trigger
another I/O for symlink data. However, currently fs correction could be
reported _incorrectly_ if inode xattrs are too large.
In fact, these should be valid images although they cannot be handled as
fast symlinks.
Many thanks to Colin for reporting this!
Reported-by: Colin Walters <walters@verbum.org>
Reported-by: https://honggfuzz.dev/
Link: https://lore.kernel.org/r/bb2dd430-7de0-47da-ae5b-82ab2dd4d945@app.fastmail.com
Fixes: 431339ba9042 ("staging: erofs: add inode operations")
[ Note that it's a runtime misbehavior instead of a security issue. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240909031911.1174718-1-hsiangkao@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/erofs/inode.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -212,12 +212,14 @@ static int erofs_fill_symlink(struct ino
unsigned int m_pofs)
{
struct erofs_inode *vi = EROFS_I(inode);
- unsigned int bsz = i_blocksize(inode);
+ loff_t off;
char *lnk;
- /* if it cannot be handled with fast symlink scheme */
- if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
- inode->i_size >= bsz || inode->i_size < 0) {
+ m_pofs += vi->xattr_isize;
+ /* check if it cannot be handled with fast symlink scheme */
+ if (vi->datalayout != EROFS_INODE_FLAT_INLINE || inode->i_size < 0 ||
+ check_add_overflow(m_pofs, inode->i_size, &off) ||
+ off > i_blocksize(inode)) {
inode->i_op = &erofs_symlink_iops;
return 0;
}
@@ -226,16 +228,6 @@ static int erofs_fill_symlink(struct ino
if (!lnk)
return -ENOMEM;
- m_pofs += vi->xattr_isize;
- /* inline symlink data shouldn't cross block boundary */
- if (m_pofs + inode->i_size > bsz) {
- kfree(lnk);
- erofs_err(inode->i_sb,
- "inline data cross block boundary @ nid %llu",
- vi->nid);
- DBG_BUGON(1);
- return -EFSCORRUPTED;
- }
memcpy(lnk, kaddr + m_pofs, inode->i_size);
lnk[inode->i_size] = '\0';
next prev parent reply other threads:[~2024-10-14 15:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 14:09 [PATCH 6.1 000/798] 6.1.113-rc1 review Greg Kroah-Hartman
2024-10-14 14:19 ` [PATCH 6.1 624/798] arm64: Add Cortex-715 CPU part definition Greg Kroah-Hartman
2024-10-14 14:20 ` [PATCH 6.1 654/798] erofs: get rid of erofs_inode_datablocks() Greg Kroah-Hartman
2024-10-14 14:20 ` [PATCH 6.1 655/798] erofs: get rid of z_erofs_do_map_blocks() forward declaration Greg Kroah-Hartman
2024-10-14 14:20 ` [PATCH 6.1 656/798] erofs: avoid hardcoded blocksize for subpage block support Greg Kroah-Hartman
2024-10-14 14:20 ` [PATCH 6.1 657/798] erofs: set block size to the on-disk block size Greg Kroah-Hartman
2024-10-14 14:20 ` Greg Kroah-Hartman [this message]
2024-10-14 14:20 ` [PATCH 6.1 672/798] perf lock: Dynamically allocate lockhash_table Greg Kroah-Hartman
2024-10-14 20:35 ` [PATCH 6.1 000/798] 6.1.113-rc1 review Florian Fainelli
2024-10-15 3:43 ` Peter Schneider
2024-10-15 5:31 ` Jon Hunter
2024-10-15 5:50 ` Jon Hunter
2024-10-15 11:18 ` Greg Kroah-Hartman
2024-10-15 6:29 ` Pavel Machek
2024-10-15 7:06 ` Geert Uytterhoeven
2024-10-15 7:07 ` Geert Uytterhoeven
2024-10-15 9:38 ` Oleksij Rempel
2024-10-15 7:47 ` Naresh Kamboju
2024-10-15 8:53 ` Naresh Kamboju
2024-10-15 9:50 ` Heiko Carstens
2024-10-15 11:14 ` Greg Kroah-Hartman
2024-10-15 14:40 ` Shuah Khan
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=20241014141243.902543910@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=walters@verbum.org \
/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