Skip to contentSkip to conversation

fs: ext4: fix symlink read function

PATCH In review Gary Bisson 3 participants 5 messages Sep 7, 2015 – Sep 12, 2015 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: ext4: fix symlink read function

Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read.

---
Hi all,

Switching from an old v2014.07 to v2015.07 we've noticed that we couldn't read symlinks any more. This is due to the API changes made to ext4fs_read_file (commit 9f12cd0).

This patch makes the read symlink check both for errors (status < 0) and actual read length.

Regards,
Gary

---
 fs/ext4/ext4_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4_common.c +1 -1
index cab5465..e2ab145 100644
@@ -2040,7 +2040,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
 		status = ext4fs_read_file(diro, 0,
 					   __le32_to_cpu(diro->inode.size),
 					   symlink, &actread);
-		if (status == 0) {
+		if ((status < 0) || (actread == 0)) {
 			free(symlink);
 			return 0;
 		}
Signature · 1 line
2.5.1
#1 lore raw

PATCH 1/1 fs: ext4: fix symlink read function

Hi Gary,

Quoted 11 lines · Gary Bisson

Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read.

---
Hi all,

Switching from an old v2014.07 to v2015.07 we've noticed that we couldn't read symlinks any more. This is due to the API changes made to ext4fs_read_file (commit 9f12cd0).

Quoted 5 lines

This patch makes the read symlink check both for errors (status < 0) and actual read length.

Regards,
Gary

Thanks for fixing this. Does the filesystem test (test/fs-test.sh) show this error? How could we enhance the test to detect this?

Quoted 18 lines
---
 fs/ext4/ext4_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4_common.c +1 -2
index cab5465..e2ab145 100644
@@ -2040,7 +2040,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
                status = ext4fs_read_file(diro, 0,
                                           __le32_to_cpu(diro->inode.size),
                                           symlink, &actread);
-               if (status == 0) {
+               if ((status < 0) || (actread == 0)) {
                        free(symlink);
                        return 0;
                }
--
Quoted 2 lines

2.5.1

Regards,
Simon

#2 lore raw

PATCH 1/1 fs: ext4: fix symlink read function

Hi Simon,

Quoted 15 lines · Simon Glass

Hi Gary,

Quoted 11 lines · Gary Bisson

Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read.

---
Hi all,

Switching from an old v2014.07 to v2015.07 we've noticed that we couldn't read symlinks any more. This is due to the API changes made to ext4fs_read_file (commit 9f12cd0).

Quoted 8 lines
Quoted 5 lines

This patch makes the read symlink check both for errors (status < 0) and actual read length.

Regards,
Gary

Thanks for fixing this. Does the filesystem test (test/fs-test.sh) show this error? How could we enhance the test to detect this?

I wasn't aware of this testing script, a quick look at it makes me think it doesn't check anything symlink-related. I guess it would require to add SYMLINK_FILE that points to either SMALL_FILE or BIG_FILE, read it and check the md5sum.

Regards,
Gary

#3 lore raw

PATCH 1/1 fs: ext4: fix symlink read function

Hi Gary,

Quoted 25 lines · Gary Bisson

Hi Simon,

Quoted 21 lines · Simon Glass

Hi Gary,

Quoted 16 lines · Gary Bisson

Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read.

---
Hi all,

Switching from an old v2014.07 to v2015.07 we've noticed that we couldn't read symlinks any more. This is due to the API changes made to ext4fs_read_file (commit 9f12cd0).

This patch makes the read symlink check both for errors (status < 0) and actual read length.

Regards,
Gary

Quoted 7 lines
Quoted 2 lines

Thanks for fixing this. Does the filesystem test (test/fs-test.sh) show this error? How could we enhance the test to detect this?

I wasn't aware of this testing script, a quick look at it makes me think it doesn't check anything symlink-related. I guess it would require to add SYMLINK_FILE that points to either SMALL_FILE or BIG_FILE, read it and check the md5sum.

Yes I think that will work. Are you going to take a look?

Regards,
Simon

Quoted 2 lines
#4 lore raw
In reply to Gary Bisson
Quoted 4 lines · Gary Bisson

Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/feaa83a1/attachment.sig>