ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: fix off by one bugs in unsafe_request_wait()
@ 2021-09-06  9:43 Dan Carpenter
  2021-09-06 18:03 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-09-06  9:43 UTC (permalink / raw)
  To: Jeff Layton, Xiubo Li; +Cc: Ilya Dryomov, ceph-devel, kernel-janitors

The "> max" tests should be ">= max" to prevent an out of bounds access
on the next lines.

Fixes: e1a4541ec0b9 ("ceph: flush the mdlog before waiting on unsafe reqs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/ceph/caps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 26c5029629a4..ebbad9080422 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2260,7 +2260,7 @@ static int unsafe_request_wait(struct inode *inode)
 			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;
 				}
@@ -2274,7 +2274,7 @@ static int unsafe_request_wait(struct inode *inode)
 			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;
 				}
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: fix off by one bugs in unsafe_request_wait()
  2021-09-06  9:43 [PATCH] ceph: fix off by one bugs in unsafe_request_wait() Dan Carpenter
@ 2021-09-06 18:03 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2021-09-06 18:03 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jeff Layton, Xiubo Li, Ceph Development, kernel-janitors

On Mon, Sep 6, 2021 at 11:43 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The "> max" tests should be ">= max" to prevent an out of bounds access
> on the next lines.
>
> Fixes: e1a4541ec0b9 ("ceph: flush the mdlog before waiting on unsafe reqs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/ceph/caps.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 26c5029629a4..ebbad9080422 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -2260,7 +2260,7 @@ static int unsafe_request_wait(struct inode *inode)
>                         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;
>                                 }
> @@ -2274,7 +2274,7 @@ static int unsafe_request_wait(struct inode *inode)
>                         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;
>                                 }
> --
> 2.20.1
>

Applied.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-06 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  9:43 [PATCH] ceph: fix off by one bugs in unsafe_request_wait() Dan Carpenter
2021-09-06 18:03 ` Ilya Dryomov

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).