All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack@google.com>
To: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com>
Cc: mic@digikod.net, willemdebruijn.kernel@gmail.com,
	 linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
	 netfilter-devel@vger.kernel.org, yusongping@huawei.com,
	 artem.kuzin@huawei.com, konstantin.meskhidze@huawei.com
Subject: Re: [RFC PATCH v1 1/2] landlock: Fix non-TCP sockets restriction
Date: Thu, 3 Oct 2024 17:57:01 +0200	[thread overview]
Message-ID: <Zv6-zacowieEo2mq@google.com> (raw)
In-Reply-To: <20241003143932.2431249-2-ivanov.mikhail1@huawei-partners.com>

On Thu, Oct 03, 2024 at 10:39:31PM +0800, Mikhail Ivanov wrote:
> Do not check TCP access right if socket protocol is not IPPROTO_TCP.
> LANDLOCK_ACCESS_NET_BIND_TCP and LANDLOCK_ACCESS_NET_CONNECT_TCP
> should not restrict bind(2) and connect(2) for non-TCP protocols
> (SCTP, MPTCP, SMC).
> 
> Closes: https://github.com/landlock-lsm/linux/issues/40
> Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
> Signed-off-by: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com>
> ---
>  security/landlock/net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/landlock/net.c b/security/landlock/net.c
> index bc3d943a7118..6f59dd98bb13 100644
> --- a/security/landlock/net.c
> +++ b/security/landlock/net.c
> @@ -68,7 +68,7 @@ static int current_check_access_socket(struct socket *const sock,
>  		return -EACCES;
>  
>  	/* Checks if it's a (potential) TCP socket. */
> -	if (sock->type != SOCK_STREAM)
> +	if (sock->type != SOCK_STREAM || sock->sk->sk_protocol != IPPROTO_TCP)
>  		return 0;
>  
>  	/* Checks for minimal header length to safely read sa_family. */
> -- 
> 2.34.1
> 

Thank you! Good catch!

Reviewed-by: Günther Noack <gnoack@google.com>

  reply	other threads:[~2024-10-03 15:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 14:39 [RFC PATCH v1 0/2] Fix non-TCP sockets restriction Mikhail Ivanov
2024-10-03 14:39 ` [RFC PATCH v1 1/2] landlock: " Mikhail Ivanov
2024-10-03 15:57   ` Günther Noack [this message]
2024-10-03 17:45   ` Mickaël Salaün
2024-10-03 21:30     ` Mikhail Ivanov
2024-10-04 10:13       ` Mickaël Salaün
2024-10-04 18:16         ` Mikhail Ivanov
2024-10-05 15:49           ` Mickaël Salaün
2024-10-05 15:55             ` Mickaël Salaün
2024-10-07 11:06             ` Mikhail Ivanov
2024-10-07 11:58               ` Mikhail Ivanov
2024-10-07 13:35                 ` Mickaël Salaün
2024-10-03 21:48     ` Mikhail Ivanov
2024-10-03 14:39 ` [RFC PATCH v1 2/2] selftests/landlock: Test non-TCP INET connection-based protocols Mikhail Ivanov
2024-10-03 15:59   ` Günther Noack
2024-10-03 17:45   ` Mickaël Salaün
2024-10-03 21:22     ` Mikhail Ivanov
2024-10-04 10:14       ` Mickaël Salaün

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zv6-zacowieEo2mq@google.com \
    --to=gnoack@google.com \
    --cc=artem.kuzin@huawei.com \
    --cc=ivanov.mikhail1@huawei-partners.com \
    --cc=konstantin.meskhidze@huawei.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=yusongping@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.