summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-24 13:19:28 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-29 09:47:01 +0200
commit610720857348a147fad3e330180b1fdf63453f25 (patch)
tree889fada16b82d18aa7518ee3e4af235048080921
parent532864c6676439d12dd159dc33aeb584f7fcedbc (diff)
downloadbarebox-610720857348a147fad3e330180b1fdf63453f25.tar.gz
barebox-610720857348a147fad3e330180b1fdf63453f25.tar.xz
fs: ext4: fix bogus behavior on failure to read ext4 block
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--fs/ext4/ext4fs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 54349aad3f..344d423fd9 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) {