Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integer overflow in ipcs.c, do_shm() #51

Open
rudimeier opened this issue Mar 6, 2014 · 2 comments
Open

integer overflow in ipcs.c, do_shm() #51

rudimeier opened this issue Mar 6, 2014 · 2 comments

Comments

@rudimeier
Copy link
Contributor

/proc/sys/kernel/shmall gives a count of pages as size_t. This overflows when multiplying by pagesize:

ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : unit,
               _("max total shared memory"),
               lim.shmall * getpagesize(), "\n", 0);

That's why ./tests/ts/ipcs/limits2 fails on systems where shmall is large enough.
The problem got a bit worse since 56692a6.

Don't know how this should be fixed. I guess the only real fix would be to use large integer arithmetics.

karelzak added a commit that referenced this issue Mar 11, 2014
Addresses: #51
Signed-off-by: Karel Zak <kzak@redhat.com>
@rudimeier
Copy link
Contributor Author

Thanks, but this fix still not works on x86_64 where size_t and unit64_t are the same.
For example on my system I have per default

$ cat /proc/sys/kernel/shmall
1152921504606846720 

which is 4611686018427386880 KB and greater than 2^64 bytes
so ipcs can't do it correctly:

$ ./ipcs -ml | grep "max total"
max total shared memory (kbytes) = 18014398509480960

rudimeier added a commit to rudimeier/util-linux that referenced this issue May 13, 2014
See github issue util-linux#51, comment 2
util-linux#51

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
rudimeier added a commit to rudimeier/util-linux that referenced this issue May 13, 2014
See github issue util-linux#51, comment 2
util-linux#51

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
rudimeier added a commit to rudimeier/util-linux that referenced this issue May 13, 2014
See github issue util-linux#51, comment 2
util-linux#51

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
rudimeier added a commit to rudimeier/util-linux that referenced this issue May 13, 2014
See github issue util-linux#51, comment 2
util-linux#51

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
@karelzak karelzak reopened this Aug 26, 2014
@DerDakon
Copy link

I think I have hit the same thing on hppa with 2.36.2. The ipcs/limits2 test fails for me.

# cat limits2
check for difference between kernel and IPC
/proc/sys/kernel/shmmni kernel=, ipcs=4096
/proc/sys/kernel/shmall kernel=, ipcs=18014398509481980
/proc/sys/kernel/shmmax kernel=, ipcs=18014398509465599
#  cat /proc/sys/kernel/shmmni /proc/sys/kernel/shmall /proc/sys/kernel/shmmax
4096
18446744073692774399
18446744073692774399
# ipcs -ml
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18014398509481980
min seg size (bytes) = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants