Skip to content

Commit 708c871

Browse files
Dan Carpenteridryomov
authored andcommitted
ceph: fix off by one bugs in unsafe_request_wait()
The "> max" tests should be ">= max" to prevent an out of bounds access on the next lines. Fixes: e1a4541 ("ceph: flush the mdlog before waiting on unsafe reqs") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent e4e737b commit 708c871

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/ceph/caps.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ static int unsafe_request_wait(struct inode *inode)
22632263
list_for_each_entry(req, &ci->i_unsafe_dirops,
22642264
r_unsafe_dir_item) {
22652265
s = req->r_session;
2266-
if (unlikely(s->s_mds > max)) {
2266+
if (unlikely(s->s_mds >= max)) {
22672267
spin_unlock(&ci->i_unsafe_lock);
22682268
goto retry;
22692269
}
@@ -2277,7 +2277,7 @@ static int unsafe_request_wait(struct inode *inode)
22772277
list_for_each_entry(req, &ci->i_unsafe_iops,
22782278
r_unsafe_target_item) {
22792279
s = req->r_session;
2280-
if (unlikely(s->s_mds > max)) {
2280+
if (unlikely(s->s_mds >= max)) {
22812281
spin_unlock(&ci->i_unsafe_lock);
22822282
goto retry;
22832283
}

0 commit comments

Comments
 (0)