Skip to content
Snippets Groups Projects
Commit d59577b6 authored by Vincent Bernat's avatar Vincent Bernat Committed by David S. Miller
Browse files

sk-filter: Add ability to lock a socket filter program


While a privileged program can open a raw socket, attach some
restrictive filter and drop its privileges (or send the socket to an
unprivileged program through some Unix socket), the filter can still
be removed or modified by the unprivileged program. This commit adds a
socket option to lock the filter (SO_LOCK_FILTER) preventing any
modification of a socket filter program.

This is similar to OpenBSD BIOCLOCK ioctl on bpf sockets, except even
root is not allowed change/drop the filter.

The state of the lock can be read with getsockopt(). No error is
triggered if the state is not changed. -EPERM is returned when a user
tries to remove the lock or to change/remove the filter while the lock
is active. The check is done directly in sk_attach_filter() and
sk_detach_filter() and does not affect only setsockopt() syscall.

Signed-off-by: default avatarVincent Bernat <bernat@luffy.cx>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5bd30d39
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 2 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment