From: Dan Carpenter Date: Mon, 6 Sep 2021 09:43:01 +0000 (+0300) Subject: ceph: fix off by one bugs in unsafe_request_wait() X-Git-Tag: baikal/aarch64/sdk6.1~5684^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=2a5145be62277aadec96922f9b5462d250b08f42;p=kernel.git 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: 3b0c748833c7 ("ceph: flush the mdlog before waiting on unsafe reqs") Signed-off-by: Dan Carpenter Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov --- diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 6c0e52fd0743e..3e42d0466521f 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2263,7 +2263,7 @@ retry: list_for_each_entry(req, &ci->i_unsafe_dirops, r_unsafe_dir_item) { s = req->r_session; - if (unlikely(s->s_mds > max)) { + if (unlikely(s->s_mds >= max)) { spin_unlock(&ci->i_unsafe_lock); goto retry; } @@ -2277,7 +2277,7 @@ retry: list_for_each_entry(req, &ci->i_unsafe_iops, r_unsafe_target_item) { s = req->r_session; - if (unlikely(s->s_mds > max)) { + if (unlikely(s->s_mds >= max)) { spin_unlock(&ci->i_unsafe_lock); goto retry; }