vfs: get inode after passing previous check in rw_verify_area()
PATCH v2 1/1 vfs: get inode after passing previous check in rw_verify_area()
From: Lorne Li <[email protected]>
If previous check (pos and overflow check) fails, there's no chance to use local variable inode, initialized by file_inode() in the beginning of rw_verify_area().
So delay getting inode until actually needing it for check.
Signed-off-by Lorne Li <[email protected]>
--- fs/read_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/read_write.c +1 -1
@@ -368,7 +368,6 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_tloff_t pos;int retval = -EINVAL ; - inode =file_inode (file);if (unlikely ((ssize_t ) count <0 ))return retval; pos = *ppos;
@@ -382,6 +381,7 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_treturn retval; } + inode =file_inode (file);if (unlikely (inode->i_flctx &&mandatory_lock (inode))) { retval =locks_mandatory_area (inode, file, pos, pos + count -1 , read_write ==READ ?F_RDLCK :F_WRLCK );
Signature · 1 line
1.8.3.1