From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Jk9elqOy; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) by passt.top (Postfix) with ESMTPS id 32E4E5A0279 for ; Sat, 23 Aug 2025 01:09:08 +0200 (CEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id B4D3D44D1A; Fri, 22 Aug 2025 23:09:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24C94C4CEED; Fri, 22 Aug 2025 23:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1755904145; bh=Y/LG1VX/onM7A0Oh2oxuLnFg//L67w0I1JNhEOqetSE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Jk9elqOy/ZJR+vn9xxaYbWRdWcp7qtpqqZYGD/R7lwnXvzCqMaP8d/Sb2QKbvLSLE VGYmk8jojSeY7B3uONS9XdhAVY4I5JoGh8zHItajT5LFaEYKTJ8mZCfTt2ikXQswrW IhrPG726tFTDgjsKIZnqNm228OqBziQTdqbapasQ= Date: Fri, 22 Aug 2025 16:09:04 -0700 From: Andrew Morton To: Stefano Brivio Subject: Re: [PATCH] proc: Bring back lseek() operations for /proc/net entries Message-Id: <20250822160904.6c5468bce2200cf8561970d7@linux-foundation.org> In-Reply-To: <20250822172335.3187858-1-sbrivio@redhat.com> References: <20250822172335.3187858-1-sbrivio@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-MailFrom: akpm@linux-foundation.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: VELVH4BASATCQUYHKT5EODFIJV2WRYYQ X-Message-ID-Hash: VELVH4BASATCQUYHKT5EODFIJV2WRYYQ X-Mailman-Approved-At: Sat, 23 Aug 2025 10:24:00 +0200 CC: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, wangzijie , Alexey Dobriyan , Christian Brauner , passt-dev@passt.top, Al Viro , Ye Bin , Alexei Starovoitov , "Rick P . Edgecombe" , "Kirill A . Shutemov" X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 22 Aug 2025 19:23:35 +0200 Stefano Brivio 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?