]> git.ipfire.org Git - thirdparty/util-linux.git/commit
ipcs: Avoid shmall overflows
authorVasilis Liaskovitis <vliaskovitis@suse.com>
Fri, 15 Jan 2021 14:00:11 +0000 (15:00 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Jan 2021 10:38:58 +0000 (11:38 +0100)
commit7a08784ab053d6aa30db990cbec1fd35b34ed00a
tree260daccb30a9e9f914ab07b4ec116adc9b9407de
parentff21f476f85ac9855452f4aac43a231c3c1e2ebc
ipcs: Avoid shmall overflows

Avoid computing the number of bytes in shmall, by only
computing and printing the number of Kbytes. This avoids
some overflows, e.g.

$ echo "4503599627370496" > /proc/sys/kernel/shmall
$ ipcs -l | grep 'max total shared memory'
Before:
max total shared memory (kbytes) = 18014398509481980
After:
max total shared memory (kbytes) = 18014398509481984

$ echo "99993599627370500" > /proc/sys/kernel/shmall
99993599627370500
$ ipcs -l | grep 'max total shared memory'
Before:
max total shared memory (kbytes) = 18014398509481980
After:
max total shared memory (kbytes) = 399974398509482000

v1->v2:
  Print the non-overflow KB value only for IPC_UNIT_KB and
IPC_UNIT_DEFAULT.
  This way --bytes and --human options will still get an expected
output
  (but not avoiding the overflow).

Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/ipcs.c