All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack3000@gmail.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 v2 00/12] Socket type control for Landlock
Date: Tue, 4 Jun 2024 22:22:44 +0200	[thread overview]
Message-ID: <20240604.c18387da7a0e@gnoack.org> (raw)
In-Reply-To: <20240524093015.2402952-1-ivanov.mikhail1@huawei-partners.com>

On Fri, May 24, 2024 at 05:30:03PM +0800, Mikhail Ivanov wrote:
> Hello! This is v2 RFC patch dedicated to socket protocols restriction.
> 
> It is based on the landlock's mic-next branch on top of v6.9 kernel
> version.

Hello Mikhail!

I patched in your patchset and tried to use the feature with a small
demo tool, but I ran into what I think is a bug -- do you happen to
know what this might be?

I used 6.10-rc1 as a base and patched your patches on top.

The code is a small tool called "nonet", which does the following:

  - Disable socket creation with a Landlock ruleset with the following
    attributes:
  
    struct landlock_ruleset_attr attr = {
      .handled_access_socket = LANDLOCK_ACCESS_SOCKET_CREATE,
    };

  - open("/dev/null", O_WRONLY)

Expected result:

  - open() should work

Observed result:

  - open() fails with EACCES.

I traced this with perf, and found that the open() gets rejected from
Landlock's hook_file_open, whereas hook_socket_create does not get
invoked.  This is surprising to me -- Enabling a policy for socket
creation should not influence the outcome of opening files!

Tracing commands:

  sudo perf probe hook_socket_create '$params'
  sudo perf probe 'hook_file_open%return $retval'
  sudo perf record -e 'probe:*' -g -- ./nonet
  sudo perf report
 
You can find the tool in my landlock-examples repo in the nonet_bug branch:
https://github.com/gnoack/landlock-examples/blob/nonet_bug/nonet.c

Landlock is enabled like this:
https://github.com/gnoack/landlock-examples/blob/nonet_bug/sandbox_socket.c

Do you have a hunch what might be going on?

Thanks,
–Günther


  parent reply	other threads:[~2024-06-04 20:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24  9:30 [RFC PATCH v2 00/12] Socket type control for Landlock Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 01/12] landlock: Support socket access-control Mikhail Ivanov
2024-05-27  9:57   ` Günther Noack
2024-05-30 12:05     ` Mikhail Ivanov
2024-06-05 17:04       ` Günther Noack
2024-06-07 13:34         ` Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 02/12] landlock: Add hook on socket creation Mikhail Ivanov
2024-05-27  8:48   ` Günther Noack
2024-05-30 12:20     ` Mikhail Ivanov
2024-06-05 17:27       ` Günther Noack
2024-06-07 14:45         ` Mikhail Ivanov
2024-09-25 18:31           ` Mickaël Salaün
2024-05-24  9:30 ` [RFC PATCH v2 03/12] selftests/landlock: Add protocol.create to socket tests Mikhail Ivanov
2024-05-27 15:27   ` Günther Noack
2024-05-30 12:50     ` Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 04/12] selftests/landlock: Add protocol.socket_access_rights " Mikhail Ivanov
2024-05-27 20:52   ` Günther Noack
2024-05-30 14:35     ` Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 05/12] selftests/landlock: Add protocol.rule_with_unknown_access " Mikhail Ivanov
2024-05-27 21:11   ` Günther Noack
2024-05-24  9:30 ` [RFC PATCH v2 06/12] selftests/landlock: Add protocol.rule_with_unhandled_access " Mikhail Ivanov
2024-05-27 21:15   ` Günther Noack
2024-05-24  9:30 ` [RFC PATCH v2 07/12] selftests/landlock: Add protocol.inval " Mikhail Ivanov
2024-05-27 21:27   ` Günther Noack
2024-05-30 15:28     ` Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 08/12] selftests/landlock: Add tcp_layers.ruleset_overlap " Mikhail Ivanov
2024-05-27 21:09   ` Günther Noack
2024-05-30 15:08     ` Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 09/12] selftests/landlock: Add mini.ruleset_with_unknown_access " Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 10/12] selftests/landlock: Add mini.socket_overflow " Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 11/12] selftests/landlock: Add mini.socket_invalid_type " Mikhail Ivanov
2024-05-24  9:30 ` [RFC PATCH v2 12/12] samples/landlock: Support socket protocol restrictions Mikhail Ivanov
2024-06-04 20:22 ` Günther Noack [this message]
2024-06-06 11:44   ` [RFC PATCH v2 00/12] Socket type control for Landlock Mikhail Ivanov
2024-06-06 13:32     ` Günther Noack
2024-06-06 19:32       ` Günther Noack
2024-06-07 13:58       ` Mikhail Ivanov
2024-06-10  8:03     ` Günther Noack
2024-06-10  8:21       ` [PATCH] landlock: Use bit-fields for storing handled layer access masks Günther Noack
2024-06-13 21:20         ` Mickaël Salaün
2024-06-14 12:06           ` Günther Noack
2024-06-15 15:08             ` Mickaël Salaün
2024-06-11 11:35       ` [RFC PATCH v2 00/12] Socket type control for Landlock Mikhail Ivanov

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=20240604.c18387da7a0e@gnoack.org \
    --to=gnoack3000@gmail.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.