ROMFS: romfs_lookup() shouldn't be doing a partial name comparison
PATCH 1/2 ROMFS: romfs_lookup() shouldn't be doing a partial name comparison
romfs_lookup() should be using a routine akin to strcmp() on the backing store, rather than one akin to strncmp(). If it uses the latter, it's liable to match /bin/shutdown when looking up /bin/sh.
Signed-off-by David Howells <[email protected]>
Tested-by Michal Simek <[email protected]>
---
fs/romfs/internal.h | 4 ++- fs/romfs/storage.c | 67 +++++++++++++++++++++++++++++++++++++-------------- fs/romfs/super.c | 4 ++- 3 files changed, 53 insertions(+), 22 deletions(-)
fs/romfs/internal.h +2 -2
@@ -43,5 +43,5 @@ extern int romfs_dev_read(struct super_block *sb, unsigned long pos, void *buf, size_t buflen);extern ssize_t romfs_dev_strnlen (struct super_block *sb,unsigned long pos,size_t maxlen); -extern int romfs_dev_strncmp (struct super_block *sb,unsigned long pos, -const char *str,size_t size); +extern int romfs_dev_strcmp (struct super_block *sb,unsigned long pos, +const char *str,size_t size);
fs/romfs/storage.c +49 -18
129 lines not on this page · raw message
fs/romfs/super.c +2 -2
@@ -240,8 +240,8 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry, goto error;/* try to match the first 16 bytes of name */ - ret =romfs_dev_strncmp (dir->i_sb, offset +ROMFH_SIZE , name, - len); + ret =romfs_dev_strcmp (dir->i_sb, offset +ROMFH_SIZE , name, + len);if (ret <0 ) goto error;if (ret ==1 )
PATCH 2/2 ROMFS: Advance destination buffer pointer when reading from a blockdev
RomFS should advance the destination buffer pointer when reading data from a blockdev source (the data may be split over multiple blocks, each requiring its own sb_read() call). Without this, all the data is copied to the beginning of the output buffer.
Signed-off-by David Howells <[email protected]>
Tested-by Michal Simek <[email protected]>
---
fs/romfs/storage.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
fs/romfs/storage.c +1 -0
@@ -120,6 +120,7 @@ static int romfs_blk_read(struct super_block *sb, unsigned long pos,return -EIO ;memcpy (buf, bh->b_data + offset, segment);brelse (bh); + buf += segment; buflen -= segment; pos += segment; }