netsniff-ng: mlock: only lock current and future pages when root
commit0cdcd1d1ad8ec4c107cc09850456d44eea9f3d20
authorDaniel Borkmann <dborkman@redhat.com>
Thu, 11 Apr 2013 13:37:33 +0000 (11 15:37 +0200)
committerDaniel Borkmann <dborkman@redhat.com>
Thu, 11 Apr 2013 13:37:33 +0000 (11 15:37 +0200)
tree9d51981f25c2f23cbf551473fa7e9dc5d6605fcd
parent2bce4249a8e90c67a24e096f91047795f92ab548
netsniff-ng: mlock: only lock current and future pages when root

When we're still root, we tell the kernel to lock/protect all current
and future pages in memory so that they will not be swapped out in
case the system uses up too much. Now when we do xzmalloc_aligned(),
it calls internally posix_memalign() that can call mmap(2), thus we
will get an EAGAIN as errno, since we're not root anymore and since
we wanted to touch sth. that belongs to root. Nasty. Fix this up by
only protecting these pages when we do not use -u/-g.

Reported-by: Doug Burks <doug.burks@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
netsniff-ng.c