]> git.ipfire.org Git - thirdparty/systemd.git/commit
socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if SO_RCVBUF/SO_SNDBUF fails
authorFranck Bui <fbui@suse.com>
Fri, 14 Sep 2018 07:24:08 +0000 (09:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 Sep 2018 11:00:38 +0000 (13:00 +0200)
commit10ce2e0681ac16e7bb3619b7bb1a72a6f98a2f2c
treee0529075bed75d0a03106d47e8de93d1a8a95b85
parent1327f272d3d33d8f51e9398e53f2faad92c9caf0
socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if SO_RCVBUF/SO_SNDBUF fails

Both SO_SNDBUFFORCE and SO_RCVBUFFORCE requires capability 'net_admin'.

If this capability is not granted to the service the first attempt to increase
the recv/snd buffers (via sd_notify()) with SO_RCVBUFFORCE/SO_SNDBUFFORCE will
fail, even if the requested size is lower than the limit enforced by the
kernel.

If apparmor is used, the DENIED logs for net_admin will show up. These log
entries are seen as red warning light, because they could indicate that a
program has been hacked and tries to compromise the system.

It would be nicer if they can be avoided without giving services (relying on
sd_notify) net_admin capability or dropping DENIED logs for all such services
via their apparmor profile.

I'm not sure if sd_notify really needs to forcibly increase the buffer sizes,
but at least if the requested size is below the kernel limit, the capability
(hence the log entries) should be avoided.

Hence let's first ask politely for increasing the buffers and only if it fails
then ignore the kernel limit if we have sufficient privileges.
src/basic/socket-util.c