mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Bastian Krause <bst@pengutronix.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] fs: ext4: fix bogus behavior on failure to read ext4 block
Date: Wed, 24 Mar 2021 13:19:28 +0100	[thread overview]
Message-ID: <20210324121928.7380-1-a.fatoum@pengutronix.de> (raw)

The conversion of blknr from a signed 32-bit to an unsigned 64-type resulted
in the check for error to never return true. Fix this.

Affected configuration would behave incorrectly when served with invalid
blocks. Instead of aborting and having the filesystem bubble up an error
code, it would return invalid data. As there is no ext4 write support,
this wouldn't lead to ext4 data corruption however.

Reported-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/ext4/ext4fs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 54349aad3f3f..344d423fd9c4 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -74,11 +74,11 @@ loff_t ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
 		loff_t blockend = blocksize;
 		loff_t skipfirst = 0;
 
-		blknr = read_allocated_block(node, i);
-		if (blknr < 0)
-			return blknr;
+		ret = read_allocated_block(node, i);
+		if (ret < 0)
+			return ret;
 
-		blknr = blknr << log2blocksize;
+		blknr = ret << log2blocksize;
 
 		/* Last block.  */
 		if (i == blockcnt - 1) {
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-03-24 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 12:19 Ahmad Fatoum [this message]
2021-03-25 13:04 ` Sascha Hauer
2021-03-25 13:14   ` Ahmad Fatoum
2021-03-29  7:47 ` 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=20210324121928.7380-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=bst@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