From: "John Ericson" <mail@johnericson.me>
To: "Jakub Kicinski" <kuba@kernel.org>,
"John Ericson" <John.Ericson@obsidian.systems>
Cc: "Kuniyuki Iwashima" <kuniyu@google.com>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Christian Brauner" <brauner@kernel.org>,
"David Rheinsberg" <david@readahead.eu>,
"Cong Wang" <cwang@multikernel.io>,
"Sergei Zimmerman" <sergei@zimmerman.foo>,
"network dev" <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net v3 1/2] af_unix: fix listen() succeeding on sockets in the wrong state
Date: Thu, 23 Jul 2026 16:58:16 -0400 [thread overview]
Message-ID: <acb8cc56-6473-4910-9367-8c3c0d75be78@app.fastmail.com> (raw)
In-Reply-To: <20260723091248.6acaa173@kernel.org>
On Thu, Jul 23, 2026, at 12:12 PM, Jakub Kicinski wrote:
> On Sat, 18 Jul 2026 14:29:01 -0400 John Ericson wrote:
> > Commit fd0a109a0f6b ("net, pidfs: prepare for handing out pidfds for
> > reaped sk->sk_peer_pid") inserted a prepare_peercred() call between err
> > = -EINVAL and the socket-state check in unix_listen(). Since
> > prepare_peercred() leaves err at 0 on success, listen() on an AF_UNIX
> > socket that is not in TCP_CLOSE or TCP_LISTEN state (e.g. one that is
> > already connected) now silently returns success without doing anything,
> > instead of failing with EINVAL as it did before.
>
> As the bug proves this
>
> err = x
> if (cond)
> goto bla;
>
> is a fragile pattern. People do this to avoid the extra braces AFAIU
> but it's not worth it. Can you move the error setting before the jumps
> please?
>
> if (cond) {
> err = x;
> goto bla;
> }
> --
> pw-bot: cr
>
Ahahaha. I had the exact same thought!
The original revision of this [1] indeed had the error handling reworked
like that, but Kuniyuki Iwashima asked me to submit the simple 1-line
patch to "net" first, and only submit the cleanup to "net-next" later,
so that is what I was doing.
Is that OK with you, too, I hope?
John
[1]: https://lore.kernel.org/all/20260702202018.2280336-1-John.Ericson@Obsidian.Systems/
next prev parent reply other threads:[~2026-07-23 20:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 18:29 John Ericson
2026-07-18 18:29 ` [PATCH net v3 2/2] selftests/net/af_unix: test listen() rejects wrong socket states John Ericson
2026-07-23 16:12 ` [PATCH net v3 1/2] af_unix: fix listen() succeeding on sockets in the wrong state Jakub Kicinski
2026-07-23 20:58 ` John Ericson [this message]
2026-07-24 22:09 ` Jakub Kicinski
2026-07-25 21:11 ` John Ericson
2026-07-24 22:20 ` patchwork-bot+netdevbpf
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=acb8cc56-6473-4910-9367-8c3c0d75be78@app.fastmail.com \
--to=mail@johnericson.me \
--cc=John.Ericson@obsidian.systems \
--cc=brauner@kernel.org \
--cc=cwang@multikernel.io \
--cc=davem@davemloft.net \
--cc=david@readahead.eu \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sergei@zimmerman.foo \
/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
all inboxes | Powered by JetHome®