* [PATCH] ceph: fix overflow check in build_snap_context()
@ 2012-02-29 4:56 Alex Elder
0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2012-02-29 4:56 UTC (permalink / raw)
To: ceph-devel
The overflow check for a + n * b should be (n > (ULONG_MAX - a) / b),
rather than (n > ULONG_MAX / b - a).
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Sage Weil <sage@newdream.net>
---
fs/ceph/snap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index a559c80..f04c096 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -331,7 +331,7 @@ static int build_snap_context(struct ceph_snap_realm
*realm)
/* alloc new snap context */
err = -ENOMEM;
- if (num > ULONG_MAX / sizeof(u64) - sizeof(*snapc))
+ if (num > (ULONG_MAX - sizeof(*snapc)) / sizeof(u64))
goto fail;
snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS);
if (!snapc)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] ceph: fix overflow check in build_snap_context()
@ 2012-02-16 16:56 Xi Wang
0 siblings, 0 replies; 2+ messages in thread
From: Xi Wang @ 2012-02-16 16:56 UTC (permalink / raw)
To: Sage Weil; +Cc: ceph-devel, linux-kernel, Xi Wang
The overflow check for a + n * b should be (n > (ULONG_MAX - a) / b),
rather than (n > ULONG_MAX / b - a).
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
fs/ceph/snap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index a559c80..f04c096 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -331,7 +331,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
/* alloc new snap context */
err = -ENOMEM;
- if (num > ULONG_MAX / sizeof(u64) - sizeof(*snapc))
+ if (num > (ULONG_MAX - sizeof(*snapc)) / sizeof(u64))
goto fail;
snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS);
if (!snapc)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-29 4:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29 4:56 [PATCH] ceph: fix overflow check in build_snap_context() Alex Elder
-- strict thread matches above, loose matches on Subject: below --
2012-02-16 16:56 Xi Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.