Netdev List
 help / color / mirror / Atom feed
From: Jori Koolstra <jkoolstra@xs4all.nl>
To: Christian Brauner <brauner@kernel.org>
Cc: Aleksa Sarai <cyphar@cyphar.com>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 3/3] selftest: Add tests for useful handling of LSM denials on SCM_RIGHTS
Date: Sun, 12 Jul 2026 20:23:52 +0200 (CEST)	[thread overview]
Message-ID: <30383245.772147.1783880632879@kpc.webmail.kpnmail.nl> (raw)
In-Reply-To: <20260707-sinnieren-versichern-heuballen-e86897d216c3@brauner>


> Op 07-07-2026 13:02 CEST schreef Christian Brauner <brauner@kernel.org>:
> 
> > +
> > +TEST_F(scm_rights_denial_bpf, all_allowed)
> > +{
> > +	int slots[NR_FILES], nr_slots, flags, i;
> > +
> > +	ASSERT_EQ(0, set_notrunc(self->sk[SK_RECEIVER]));
> > +	ASSERT_NE(-1, send_fds(self->sk[SK_SENDER], self->files, NR_FILES));
> > +	nr_slots = recv_fd_slots(self->sk[SK_RECEIVER], slots, &flags);
> > +
> > +	ASSERT_EQ(NR_FILES, nr_slots);
> > +	EXPECT_EQ(0, flags & MSG_CTRUNC);
> > +
> > +	for (i = 0; i < NR_FILES; i++) {
> > +		ASSERT_LE(0, slots[i]);
> 
> Why do you assert less-or-equal? You want a valid fd so you should
> expect >= 0?
> 

This says 0 <= slots[i], or equivalently slots[i] >= 0.

> > +
> > +TEST_F(scm_rights_denial_bpf, denied_without_notrunc)
> > +{
> > +	int slots[NR_FILES], nr_slots, flags;
> > +
> > +	/*
> > +	 * Baseline behaviour without SO_RIGHTS_NOTRUNC: the fd array is
> > +	 * truncated at the first denied fd and MSG_CTRUNC is set.
> > +	 */
> > +	ASSERT_EQ(0, deny_inode(self->map_fd, self->inos[1]));
> > +
> > +	ASSERT_NE(-1, send_fds(self->sk[SK_SENDER], self->files, NR_FILES));
> > +	nr_slots = recv_fd_slots(self->sk[SK_RECEIVER], slots, &flags);
> > +
> > +	ASSERT_EQ(1, nr_slots);
> > +	EXPECT_NE(0, flags & MSG_CTRUNC);
> > +
> > +	ASSERT_LE(0, slots[0]);
> 
> Why do you expect less-equal than zero? Don't you need ASSERT_GE()
> because you want slots[0] to be a valid file desscriptor?
> 

Idem.

But I do think ASSERT_GE() read a bit better here, so I have changed it.

> And even the other way around... Zero is a valid file descriptor so on
> failure you must expect ASSERT_LT()?
> 

> -- 
> Christian Brauner <brauner@kernel.org>

Thanks,
Jori.

      reply	other threads:[~2026-07-12 18:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 12:38 [PATCH net-next v4 0/3] net: af_unix: useful handling of LSM denials on SCM_RIGHTS Jori Koolstra
2026-07-05 12:38 ` [PATCH net-next v4 1/3] net: scm: move scm_detach_fds() from common path to scm_recv_unix() Jori Koolstra
2026-07-06 18:20   ` Kuniyuki Iwashima
2026-07-05 12:38 ` [PATCH net-next v4 2/3] net: af_unix: useful handling of LSM denials on SCM_RIGHTS Jori Koolstra
2026-07-07 11:02   ` Christian Brauner
2026-07-05 12:38 ` [PATCH net-next v4 3/3] selftest: Add tests for " Jori Koolstra
2026-07-06 23:17   ` Kuniyuki Iwashima
2026-07-07 11:02   ` Christian Brauner
2026-07-12 18:23     ` Jori Koolstra [this message]

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=30383245.772147.1783880632879@kpc.webmail.kpnmail.nl \
    --to=jkoolstra@xs4all.nl \
    --cc=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox