llc: Check netns in llc_estab_match() and llc_listener_match().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 18 Jul 2023 17:41:50 +0000 (10:41 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 20 Jul 2023 08:46:28 +0000 (10:46 +0200)
commit97b1d320f48c21e40cc42b4ac033f2520f9ecc5c
tree801f1f2fdf0200d413a7ee741aa7e8a0893345c5
parent9b64e93e83c2145a750e780198b41d612e3dfa5d
llc: Check netns in llc_estab_match() and llc_listener_match().

We will remove this restriction in llc_rcv() in the following patch,
which means that the protocol handler must be aware of netns.

        if (!net_eq(dev_net(dev), &init_net))
                goto drop;

llc_rcv() fetches llc_type_handlers[llc_pdu_type(skb) - 1] and calls it
if not NULL.

If the PDU type is LLC_DEST_CONN, llc_conn_handler() is called to pass
skb to corresponding sockets.  Then, we must look up a proper socket in
the same netns with skb->dev.

llc_conn_handler() calls __llc_lookup() to look up a established or
litening socket by __llc_lookup_established() and llc_lookup_listener().

Both functions iterate on a list and call llc_estab_match() or
llc_listener_match() to check if the socket is the correct destination.
However, these functions do not check netns.

Also, bind() and connect() call llc_establish_connection(), which
finally calls __llc_lookup_established(), to check if there is a
conflicting socket.

Let's test netns in llc_estab_match() and llc_listener_match().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/llc_conn.h
net/llc/af_llc.c
net/llc/llc_conn.c
net/llc/llc_if.c