kernel bug - allocating memory under 2.1.116

Russell Coker (russell@coker.com.au)
Thu, 20 Aug 1998 15:44:51 +1000


--Boundary-=_XrJmOWFrxsjyBldbEFSArCBynEcd
Content-Type: text/plain
Content-Transfer-Encoding: 8bit

To try and test out new memory in my laptop I wrote a program to allocate a
large amount of memory and then access it all (the source to this program is
attached). Now when running this program if I have RAM set to more than
about 90% of the physical RAM in the machine the program crashes with SIGCORE.
In tests on my desktop machine (64meg of RAM and 256meg swap) if I have RAM
set to 40 I can run 1 copy of the program, but the second copy crashes after
reaching 7meg used, so it seems that I can only run 47meg of test program on
top of the normal load of a personal mail server/web server/etc. NB At the
time this program crashed there was over 240megs of free swap, the hard drive
made no sound of thrashing.
I've just done another test on my laptop (96 meg RAM, 127meg swap). My
laptop is running KDE, kmail, and a kernel build in the background (not
really a great load for such a machine). When my test program reaches 54M it
crashes.

I have checked ulimit etc and found no limit that should have any affect.
Also if I run one copy of the program as a regular user then I can prevent
root from successfully running a copy of the same program (root can run it
when the regular user stops).

My initial thought was that this problem was related to ulimit, or maybe some
hard-coded limit in the kernel to try and prevent DOS attacks. But when I
saw a process running as a regular user stop root processes it became aparent
that something more severe was happening. I believe this to be a kernel bug
in memory management.

NB The problem occurs when writing to the memory not when doing malloc(). So
we can allocate the address space, but copying from the zero page is
apparently the problem.

PS Please CC replies to this address as I am not currently subscribed to
linux-kernel.

--
This is what they pay me for.

--Boundary-=_XrJmOWFrxsjyBldbEFSArCBynEcd
Content-Type: text/x-c;
name="testmem.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testmem.cpp"

I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgUkFNIDkwCgpp
bnQgbWFpbigpCnsKICBjb25zdCBpbnQgYnVmX3NpemUgPSAoUkFNIDw8IDIwKSAvIDQ7CiAgY29u
c3QgaW50IGJlbG93X21lZyA9ICgxIDw8IDE4KSAtIDE7CgogIGludCAqYnVmID0gKGludCAqKW1h
bGxvYyhidWZfc2l6ZSAqIDQpOwoKICBpZighYnVmKQogIHsKICAgIHByaW50ZigiQ2FuJ3QgbWFs
bG9jIG1lbW9yeSFcbiIpOwogICAgcmV0dXJuIDE7CiAgfQogIGZvcihpbnQgaSA9IDA7IGkgPCBi
dWZfc2l6ZTsgaSsrKQogIHsKICAgIGlmKChpICYgYmVsb3dfbWVnKSA9PSAwKQogICAgICBwcmlu
dGYoInVwIHRvICVkTVxuIiwgKGkgPj4gMTgpKTsKICAgIGJ1ZltpXSA9IGk7CiAgfQogIHByaW50
ZigiU2V0IG1lbW9yeVxuIik7CiAgd2hpbGUoMSkKICB7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwg
YnVmX3NpemU7IGkrKykKICAgIHsKICAgICAgaWYoYnVmW2ldICE9IGkpCiAgICAgIHsKICAgICAg
ICBwcmludGYoIm1lbW9yeSBjb3JydXB0IGF0ICVkIVxuIiwgaSk7CiAgICAgICAgcmV0dXJuIDI7
CiAgICAgIH0KICAgIH0KICAgIHByaW50ZigiQ2hlY2tlZFxuIik7CiAgfQogIHJldHVybiAwOwp9
Cg==

--Boundary-=_XrJmOWFrxsjyBldbEFSArCBynEcd--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html