From: Stefano Brivio <sbrivio@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
wangzijie <wangzijie1@honor.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Christian Brauner <brauner@kernel.org>,
passt-dev@passt.top, Al Viro <viro@zeniv.linux.org.uk>,
Ye Bin <yebin10@huawei.com>, Alexei Starovoitov <ast@kernel.org>,
"Rick P . Edgecombe" <rick.p.edgecombe@intel.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH] proc: Bring back lseek() operations for /proc/net entries
Date: Sat, 23 Aug 2025 10:42:51 +0200 [thread overview]
Message-ID: <20250823104251.49a8caba@elisabeth> (raw)
In-Reply-To: <20250822160904.6c5468bce2200cf8561970d7@linux-foundation.org>
On Fri, 22 Aug 2025 16:09:04 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:
> On Fri, 22 Aug 2025 19:23:35 +0200 Stefano Brivio <sbrivio@redhat.com> wrote:
>
> > Commit ff7ec8dc1b64 ("proc: use the same treatment to check proc_lseek
> > as ones for proc_read_iter et.al") breaks lseek() for all /proc/net
> > entries, as shown for instance by pasta(1), a user-mode network
> > implementation using those entries to scan for bound ports:
> >
> > $ strace -e openat,lseek -e s=none pasta -- true
> > [...]
> > openat(AT_FDCWD, "/proc/net/tcp", O_RDONLY|O_CLOEXEC) = 12
> > openat(AT_FDCWD, "/proc/net/tcp6", O_RDONLY|O_CLOEXEC) = 13
> > lseek(12, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)
> > lseek() failed on /proc/net file: Illegal seek
> > lseek(13, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)
> > lseek() failed on /proc/net file: Illegal seek
> > openat(AT_FDCWD, "/proc/net/udp", O_RDONLY|O_CLOEXEC) = 14
> > openat(AT_FDCWD, "/proc/net/udp6", O_RDONLY|O_CLOEXEC) = 15
> > lseek(14, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)
> > lseek() failed on /proc/net file: Illegal seek
> > lseek(15, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)
> > lseek() failed on /proc/net file: Illegal seek
> > [...]
> >
> > That's because PROC_ENTRY_proc_lseek isn't set for /proc/net entries,
> > and it's now mandatory for lseek(). In fact, flags aren't set at all
> > for those entries because pde_set_flags() isn't called for them.
> >
> > As commit d919b33dafb3 ("proc: faster open/read/close with "permanent"
> > files") introduced flags for procfs directory entries, along with the
> > pde_set_flags() helper, they weren't relevant for /proc/net entries,
> > so the lack of pde_set_flags() calls in proc_create_net_*() functions
> > was harmless.
> >
> > Now that the calls are strictly needed for lseek() functionality,
> > add them.
>
> Thanks. We already have
> https://lkml.kernel.org/r/20250821105806.1453833-1-wangzijie1@honor.com
> - does that look suitable?
Sorry, I didn't spot that one. It sure does!
--
Stefano
next prev parent reply other threads:[~2025-08-23 8:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 17:23 [PATCH] proc: Bring back lseek() operations for /proc/net entries Stefano Brivio
2025-08-22 23:09 ` Andrew Morton
2025-08-23 8:42 ` Stefano Brivio [this message]
2025-08-23 1:53 ` wangzijie
2025-08-23 8:43 ` Stefano Brivio
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=20250823104251.49a8caba@elisabeth \
--to=sbrivio@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=brauner@kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=passt-dev@passt.top \
--cc=rick.p.edgecombe@intel.com \
--cc=viro@zeniv.linux.org.uk \
--cc=wangzijie1@honor.com \
--cc=yebin10@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.