[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250823104251.49a8caba@elisabeth>
Date: Sat, 23 Aug 2025 10:42:51 +0200
From: Stefano Brivio <sbrivio@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, wangzijie
<wangzijie1@...or.com>, Alexey Dobriyan <adobriyan@...il.com>, Christian
Brauner <brauner@...nel.org>, passt-dev@...st.top, Al Viro
<viro@...iv.linux.org.uk>, Ye Bin <yebin10@...wei.com>, Alexei Starovoitov
<ast@...nel.org>, "Rick P . Edgecombe" <rick.p.edgecombe@...el.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH] proc: Bring back lseek() operations for /proc/net
entries
On Fri, 22 Aug 2025 16:09:04 -0700
Andrew Morton <akpm@...ux-foundation.org> wrote:
> On Fri, 22 Aug 2025 19:23:35 +0200 Stefano Brivio <sbrivio@...hat.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
Powered by blists - more mailing lists