mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Sascha Hauer" <s.hauer@pengutronix.de>
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 1/4] fs: cramfs: don't ignore decompression errors
Date: Mon, 02 Nov 2026 09:34:21 +0000	[thread overview]
Message-ID: <96a1f3e2-93fc-41bb-ae89-fb7b4c33299b@pengutronix.de> (raw)
In-Reply-To: <20261102-fs-getlink-fixes-v2-1-37df92e4d0d3@pengutronix.de>

On 2026-11-02 10:31, Sascha Hauer wrote:
> cramfs_uncompress_block() returns -EIO when a block fails to
> decompress, but cramfs_read_file() stores that in a size_t, so its
> check for an error, curr_block_len <= 0, only catches empty blocks.
> The error becomes a block length of nearly SIZE_MAX: the read copies
> whatever priv->buf holds, the previous block or nothing that was ever
> written, returns it as success, and keeps it cached as the content of
> the failed block.
> 
> Store the length in an int, so that the error ends the read.
> 
> Fixes: b42f481fa4 ("reactivate cramfs")
> Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>


> ---
>  fs/cramfs/cramfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
> index d66cce8df8..fcb9aeeab8 100644
> --- a/fs/cramfs/cramfs.c
> +++ b/fs/cramfs/cramfs.c
> @@ -46,7 +46,7 @@ struct cramfs_priv {
>  	struct cramfs_super super;
>  	int curr_base;
>  	char buf[4096];
> -	size_t curr_block_len;
> +	int curr_block_len;
>  	struct cdev *cdev;
>  };
>  
> @@ -149,7 +149,7 @@ static int cramfs_read_file(struct inode *inode, unsigned long offset,
>  			priv->curr_base = base;
>  		}
>  
> -		copy = min(priv->curr_block_len, size);
> +		copy = min_t(size_t, priv->curr_block_len, size);
>  
>  		memcpy(buf, priv->buf + ofs, copy);
>  		ofs = 0;
> 
> -- 
> 2.47.3
> 

-- 
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 |




  reply	other threads:[~2026-11-02  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  9:31 [PATCH v2 0/4] fs: return error pointers from ->get_link() on failure Sascha Hauer
2026-11-02  9:31 ` [PATCH v2 1/4] fs: cramfs: don't ignore decompression errors Sascha Hauer
2026-11-02  9:34   ` Sascha Hauer [this message]
2026-11-02  9:31 ` [PATCH v2 2/4] fs: cramfs: return an error pointer from cramfs_get_link() Sascha Hauer
2026-11-02  9:31 ` [PATCH v2 3/4] fs: ext4: return an error pointer from ext_get_link() Sascha Hauer
2026-11-02  9:31 ` [PATCH v2 4/4] fs: legacy: return an error pointer from legacy_get_link() Sascha Hauer
2026-11-02 13:25 ` [PATCH v2 0/4] fs: return error pointers from ->get_link() on failure 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=96a1f3e2-93fc-41bb-ae89-fb7b4c33299b@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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