From: "Günther Noack" <gnoack@google.com>
To: John Ericson <mail@johnericson.me>
Cc: "Günther Noack" <gnoack3000@gmail.com>,
"David Laight" <david.laight.linux@gmail.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>,
"Cong Wang" <cwang@multikernel.io>,
"Simon Horman" <horms@kernel.org>,
"Christian Brauner" <brauner@kernel.org>,
"David Rheinsberg" <david@readahead.eu>,
"Andy Lutomirski" <luto@kernel.org>,
"Sergei Zimmerman" <sergei@zimmerman.foo>,
"network dev" <netdev@vger.kernel.org>,
"Mickaël Salaün" <mic@digikod.net>,
"Paul Moore" <paul@paul-moore.com>,
linux-security-module@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: unix_stream_connect and socket address resolution
Date: Thu, 23 Jul 2026 11:53:17 +0200 [thread overview]
Message-ID: <amHkjcsSM80Hly1I@google.com> (raw)
In-Reply-To: <e4adebd8-181a-47b7-b82b-b6d9baa6b203@app.fastmail.com>
On Wed, Jul 22, 2026 at 12:02:24PM -0400, John Ericson wrote:
> Thanks Günther!
>
> This example makes sense to me. The behavior still feels a little odd to
> me, but I can understand the practical benefit of what you describe, and
> also why changing it would definitely cause breakage.
>
> I have one addendum to ask then which is: what if before the loop we
> pre-resolve the parent directory as a concrete `struct path`, and then
> on each iteration of the loop resolve only the final path component to
> the socket itself? (That is a single-component lookup relative to the
> pre-resolved parent, to be clear.)
I am not sure about that. I think the difficult question here are the
ordering guarantees on file system operations:
The file system can be in a different state in the first and the second
half of the path walk, and I'm not sure whether that wouldn't violate
file system ordering guarantees. If you intend to send such a patch,
I'd recommend to loop in some file system experts (e.g. Christian
Brauner).
What is the underlying problem that such a patch would solve though?
Do you think that the performance on retry is such a concern?
(After all, you'd also have to do a "split" lookup in the happy case,
and it sounds likely that that the retry improvement does not amortize
the happy path penalty?)
(This would have to be explained in the commit message as well, per [1])
[1] https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
> Per your example, a legitimate server restart recreates the socket inode
> in the same directory, so this still picks up the new socket and
> reconnects, while avoiding the effect where a concurrent
> ancestor-directory rename causes a wildly different socket to be
> resolved. Hopefully this preserves the intended use-case.
>
> Note that this does mean recreating the parent directory itself at the
> same path would no longer be followed, and a rename/unlink of the pinned
> parent would cause the lookup to fail rather than resolve elsewhere.
> That seems like the intended, safer direction to me, but flagging it as
> a deliberate semantic change rather than an accident.
>
> If this sounds like an acceptable middle-ground to everyone, I'd be happy to implement it.
—Günther
next prev parent reply other threads:[~2026-07-23 9:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 7:39 [RFC PATCH 0/3] coredump, net: fix layer violation with direct connection John Ericson
2026-07-03 7:39 ` [RFC PATCH 1/3] af_unix: factor out unix_lookup_bsd_path() John Ericson
2026-07-03 7:39 ` [RFC PATCH 2/3] af_unix: factor out kernel_unix_connect_direct() John Ericson
2026-07-18 19:55 ` unix_stream_connect and socket address resolution John Ericson
2026-07-18 20:58 ` David Laight
2026-07-19 15:37 ` John Ericson
2026-07-21 20:37 ` John Ericson
2026-07-22 7:25 ` Günther Noack
2026-07-22 16:02 ` John Ericson
2026-07-23 9:53 ` Günther Noack [this message]
2026-07-22 10:05 ` David Laight
2026-07-03 7:39 ` [RFC PATCH 3/3] coredump, net: remove `SOCK_COREDUMP` John Ericson
2026-07-03 8:11 ` Christian Brauner
2026-07-03 9:08 ` John Ericson
2026-07-03 9:31 ` Christian Brauner
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=amHkjcsSM80Hly1I@google.com \
--to=gnoack@google.com \
--cc=brauner@kernel.org \
--cc=cwang@multikernel.io \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=david@readahead.eu \
--cc=edumazet@google.com \
--cc=gnoack3000@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mail@johnericson.me \
--cc=mic@digikod.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul@paul-moore.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 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.