All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Forbid illegitimate binding via listen(2)
@ 2024-04-08  9:47 Ivanov Mikhail
  2024-04-08  9:47 ` [PATCH 1/2] landlock: Add hook on socket_listen() Ivanov Mikhail
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Ivanov Mikhail @ 2024-04-08  9:47 UTC (permalink / raw)
  To: mic
  Cc: willemdebruijn.kernel, gnoack3000, linux-security-module, netdev,
	netfilter-devel, yusongping, artem.kuzin, konstantin.meskhidze

listen(2) can be called without explicit bind(2) call. For a TCP socket
it would result in assigning random port(in some range) to this socket
by the kernel. If Landlock sandbox supports LANDLOCK_ACCESS_NET_BIND_TCP,
this may lead to implicit access to a prohibited (by Landlock sandbox)
port. Malicious sandboxed process can accidentally impersonate a
legitimate server process (if listen(2) assigns it a server port number).

Patch adds hook on socket_listen() that prevents such scenario by checking
LANDLOCK_ACCESS_NET_BIND_TCP access for port 0.

Few tests were added to cover this case.

Code coverage(gcov):
* security/landlock:
lines......: 94.5% (745 of 788 lines)
functions..: 97.1% (100 of 103 functions)

Ivanov Mikhail (2):
  landlock: Add hook on socket_listen()
  selftests/landlock: Create 'listen_zero', 'deny_listen_zero' tests

 security/landlock/net.c                     | 104 +++++++++++++++++---
 tools/testing/selftests/landlock/net_test.c |  89 +++++++++++++++++
 2 files changed, 177 insertions(+), 16 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-07-02 12:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08  9:47 [PATCH 0/2] Forbid illegitimate binding via listen(2) Ivanov Mikhail
2024-04-08  9:47 ` [PATCH 1/2] landlock: Add hook on socket_listen() Ivanov Mikhail
2024-04-30 13:36   ` Mickaël Salaün
2024-04-30 16:52     ` Mickaël Salaün
2024-05-13 12:15     ` Ivanov Mikhail
2024-05-17 15:22       ` Mickaël Salaün
2024-06-19 19:05       ` Günther Noack
2024-06-20  8:00         ` Mickaël Salaün
2024-06-28 16:51         ` Ivanov Mikhail
2024-07-01 10:16           ` Günther Noack
2024-07-01 13:10             ` Ivanov Mikhail
2024-07-01 15:47               ` Günther Noack
2024-07-02 12:43                 ` Ivanov Mikhail
2024-04-08  9:47 ` [PATCH 2/2] selftests/landlock: Create 'listen_zero', 'deny_listen_zero' tests Ivanov Mikhail
2024-04-30 13:36   ` Mickaël Salaün
2024-05-13 12:18     ` Ivanov Mikhail
2024-06-19 12:20 ` [PATCH 0/2] Forbid illegitimate binding via listen(2) Mickaël Salaün

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.