summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-12-19 12:29:13 -0500
committerTheodore Ts'o <tytso@mit.edu>2018-12-19 12:29:13 -0500
commit8a363970d1dc38c4ec4ad575c862f776f468d057 (patch)
tree4c2f7788f568c974552b1b1a158a0423dbe84f04 /fs/ext4/ext4.h
parenta805622a757b6d7f65def4141d29317d8e37b8a1 (diff)
ext4: avoid declaring fs inconsistent due to invalid file handles
If we receive a file handle, either from NFS or open_by_handle_at(2), and it points at an inode which has not been initialized, and the file system has metadata checksums enabled, we shouldn't try to get the inode, discover the checksum is invalid, and then declare the file system as being inconsistent. This can be reproduced by creating a test file system via "mke2fs -t ext4 -O metadata_csum /tmp/foo.img 8M", mounting it, cd'ing into that directory, and then running the following program. #define _GNU_SOURCE #include <fcntl.h> struct handle { struct file_handle fh; unsigned char fid[MAX_HANDLE_SZ]; }; int main(int argc, char **argv) { struct handle h = {{8, 1 }, { 12, }}; open_by_handle_at(AT_FDCWD, &h.fh, O_RDONLY); return 0; } Google-Bug-Id: 120690101 Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r--fs/ext4/ext4.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b4621277e259..185a05d3257e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2454,8 +2454,19 @@ int do_journal_get_write_access(handle_t *handle,
2454#define FALL_BACK_TO_NONDELALLOC 1 2454#define FALL_BACK_TO_NONDELALLOC 1
2455#define CONVERT_INLINE_DATA 2 2455#define CONVERT_INLINE_DATA 2
2456 2456
2457extern struct inode *ext4_iget(struct super_block *, unsigned long); 2457typedef enum {
2458extern struct inode *ext4_iget_normal(struct super_block *, unsigned long); 2458 EXT4_IGET_NORMAL = 0,
2459 EXT4_IGET_SPECIAL = 0x0001, /* OK to iget a system inode */
2460 EXT4_IGET_HANDLE = 0x0002 /* Inode # is from a handle */
2461} ext4_iget_flags;
2462
2463extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
2464 ext4_iget_flags flags, const char *function,
2465 unsigned int line);
2466
2467#define ext4_iget(sb, ino, flags) \
2468 __ext4_iget((sb), (ino), (flags), __func__, __LINE__)
2469
2459extern int ext4_write_inode(struct inode *, struct writeback_control *); 2470extern int ext4_write_inode(struct inode *, struct writeback_control *);
2460extern int ext4_setattr(struct dentry *, struct iattr *); 2471extern int ext4_setattr(struct dentry *, struct iattr *);
2461extern int ext4_getattr(const struct path *, struct kstat *, u32, unsigned int); 2472extern int ext4_getattr(const struct path *, struct kstat *, u32, unsigned int);