From: Karel Zak Date: Mon, 18 Jan 2021 15:04:18 +0000 (+0100) Subject: ipcs: fallback for overflow X-Git-Tag: v2.37-rc1~175 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c52d16098c5fbc12a4edd01ba62e5c4cd5d1a336;p=thirdparty%2Futil-linux.git ipcs: fallback for overflow The previous commit 7a08784ab053d6aa30db990cbec1fd35b34ed00a reduced number of situation when we need fallback when kbytes calculated for shmall pages, but there is still possible to see overflows. This patch add fallback also for kbytes. Signed-off-by: Karel Zak --- diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 79a6516e68..6730272221 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -217,9 +217,11 @@ static void do_shm (char format, int unit) _("max seg size"), lim.shmmax, "\n", 0); if (unit == IPC_UNIT_KB || unit == IPC_UNIT_DEFAULT) { - ipc_print_size(IPC_UNIT_DEFAULT, - _("max total shared memory (kbytes)"), (pgsz / 1024) * - (uint64_t) lim.shmall, "\n", 0); + tmp = (uint64_t) lim.shmall * (pgsz / 1024); + if (lim.shmall != 0 && tmp / lim.shmall != pgsz / 1024) + tmp = UINT64_MAX - (UINT64_MAX % (pgsz / 1024)); + + ipc_print_size(IPC_UNIT_DEFAULT, _("max total shared memory (kbytes)"), tmp, "\n", 0); } else { tmp = (uint64_t) lim.shmall * pgsz;