Repository navigation
Commit 39be79c
vfs: iov_iter: have iov_iter_advance decrement nr_segs appropriately
Currently, when you call iov_iter_advance, then the pointer to the iovec
array can be incremented, but it does not decrement the nr_segs value in
the iov_iter struct. The result is a iov_iter struct with a nr_segs
value that goes beyond the end of the array.
While I'm not aware of anything that's specifically broken by this, it
seems odd and a bit dangerous not to decrement that value. If someone
were to trust the nr_segs value to be correct, then they could end up
walking off the end of the array.
Changing this might also provide some micro-optimization when dealing
with the last iovec in an array. Many of the other routines that deal
with iov_iter have optimized codepaths when nr_segs == 1.
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>1 parent c3b92c8 commit 39be79c
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2115 | 2115 | | |
2116 | 2116 | | |
2117 | 2117 | | |
| 2118 | + | |
2118 | 2119 | | |
2119 | 2120 | | |
2120 | 2121 | | |
| |||
2130 | 2131 | | |
2131 | 2132 | | |
2132 | 2133 | | |
| 2134 | + | |
2133 | 2135 | | |
2134 | 2136 | | |
2135 | 2137 | | |
2136 | 2138 | | |
2137 | 2139 | | |
| 2140 | + | |
2138 | 2141 | | |
2139 | 2142 | | |
2140 | 2143 | | |
| |||
0 commit comments