mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 10:29:37 +00:00
ceph: fix overflow check in build_snap_context()
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>
This commit is contained in:
parent
6448669777
commit
80834312a4
1 changed files with 1 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue