* [PATCH v2] vfs: get inode after passing previous check in rw_verify_area()
@ 2018-06-25 6:50 lorneli.cs
0 siblings, 0 replies; only message in thread
From: lorneli.cs @ 2018-06-25 6:50 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, axboe, hch, jmorris, Lorne Li
From: Lorne Li <lorneli.cs@gmail.com>
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 <lorneli.cs@gmail.com>
---
fs/read_write.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 153f8f6..ab63e87 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -368,7 +368,6 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
loff_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_t
return 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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-06-25 6:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25 6:50 [PATCH v2] vfs: get inode after passing previous check in rw_verify_area() lorneli.cs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).