From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Cc: Jonathan Bar Or <jonathanbaror@gmail.com>
Subject: Re: [PATCH 1/5] CVE-2025-26722: fs: squashfs: Ensure positive inode length
Date: Wed, 19 Feb 2025 17:49:05 +0100 [thread overview]
Message-ID: <61270515-e726-4447-b924-b9c1f919cf74@pengutronix.de> (raw)
In-Reply-To: <20250219141844.1912413-2-s.hauer@pengutronix.de>
On 19.02.25 15:18, Sascha Hauer wrote:
> In squashfs_get_link() we have:
>
> int length = min_t(int, i_size_read(inode), PAGE_SIZE);
>
> The inode size is a 64bit number directly read from the device which
> is interpreted as a 32bit signed number above. An inode size with the
> lower 32bits set to 0xffffffff results in length being -1. Later we
> do a:
>
> symlink = malloc(length + 1);
>
> With length being -1 this results in allocating a zero size buffer which
> is then overwritten by following code.
>
> Fix this by first making sure that the inode length is positive.
> Afterwards limit the length to the desired range, explicitly using
> loff_t as the type to compare to make sure we do not truncate the
> original data type during comparison.
>
> Reported-by: Jonathan Bar Or <jonathanbaror@gmail.com>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> fs/squashfs/symlink.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/squashfs/symlink.c b/fs/squashfs/symlink.c
> index 40b9bdcc8b..cb14eb20a5 100644
> --- a/fs/squashfs/symlink.c
> +++ b/fs/squashfs/symlink.c
> @@ -43,16 +43,20 @@
> static const char *squashfs_get_link(struct dentry *dentry, struct inode *inode)
> {
> struct super_block *sb = inode->i_sb;
> - int index = 0;
> u64 block = squashfs_i(inode)->start;
> int offset = squashfs_i(inode)->offset;
> - int length = min_t(int, i_size_read(inode) - index, PAGE_SIZE);
> + size_t length;
> int bytes;
> unsigned char *symlink;
>
> TRACE("Entered squashfs_symlink_readpage, start block "
> "%llx, offset %x\n", block, offset);
>
> + if (i_size_read(inode) < 0)
> + return NULL;
> +
> + length = min_t(loff_t, i_size_read(inode), PAGE_SIZE);
> +
> symlink = malloc(length + 1);
> if (!symlink)
> return NULL;
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-02-19 16:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 14:18 [PATCH 0/5] Filesystem memory corruption fixes Sascha Hauer
2025-02-19 14:18 ` [PATCH 1/5] CVE-2025-26722: fs: squashfs: Ensure positive inode length Sascha Hauer
2025-02-19 16:49 ` Ahmad Fatoum [this message]
2025-02-19 14:18 ` [PATCH 2/5] CVE-2025-26724: fs: cramfs: fix malloc(size + constant) buffer overflow issues Sascha Hauer
2025-02-19 16:50 ` Ahmad Fatoum
2025-02-19 14:18 ` [PATCH 3/5] CVE-2025-26723: fs: ext4: " Sascha Hauer
2025-02-19 16:51 ` Ahmad Fatoum
2025-02-19 14:18 ` [PATCH 4/5] CVE-2025-26725: fs: jffs2: " Sascha Hauer
2025-02-19 16:54 ` Ahmad Fatoum
2025-02-19 14:18 ` [PATCH 5/5] CVE-2025-26721: fs: pstore: " Sascha Hauer
2025-02-19 16:54 ` Ahmad Fatoum
2025-02-19 16:47 ` [PATCH 0/5] Filesystem memory corruption fixes Ahmad Fatoum
2025-02-21 7:33 ` Sascha Hauer
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=61270515-e726-4447-b924-b9c1f919cf74@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jonathanbaror@gmail.com \
--cc=s.hauer@pengutronix.de \
/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