From patchwork Sat Jun 24 10:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13291630 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2783C001B1 for ; Sat, 24 Jun 2023 10:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbjFXKbI (ORCPT ); Sat, 24 Jun 2023 06:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232879AbjFXKbG (ORCPT ); Sat, 24 Jun 2023 06:31:06 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BAE710F5; Sat, 24 Jun 2023 03:31:05 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1687602663; bh=hzizDE0ofd3T5vSSD4XlksVV4PJv55T5z7/2M1lRIzg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=s736ziZIOYjSRE+ah/C5l268BQPA45kdL1qrax+pxBfF+O7My/Q6C+a14kXoky8vd YD0T5fapsmdqU7/11Y2mxLLX8GEhHfH0afuNV9akfrNn7cs69o9wmwfopXqDBOuSmm 5N0JpQv4GcnWJyxfOmMl/njB2v8Q++EXPaz9O8XA= Date: Sat, 24 Jun 2023 12:30:46 +0200 Subject: [PATCH 1/2] selftests/nolibc: drop test chmod_net MIME-Version: 1.0 Message-Id: <20230624-proc-net-setattr-v1-1-73176812adee@weissschuh.net> References: <20230624-proc-net-setattr-v1-0-73176812adee@weissschuh.net> In-Reply-To: <20230624-proc-net-setattr-v1-0-73176812adee@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Zhangjin Wu , Arnd Bergmann , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1687602663; l=1385; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=hzizDE0ofd3T5vSSD4XlksVV4PJv55T5z7/2M1lRIzg=; b=DF/vX9Kb4oDrP3HJyxHWbLrQCz+jWOTPWYigChKBgenfVT0teCpk23ZpjtVERScZTkb2ojuco R0JddflQm3cANkMb6S0BW1K7oDY/9Vp863E3rP4pbXqXGkRt2TgfmL1 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The test relies on /proc/$PID/net to allow chmod() operations. It is the only file or directory in /proc/$PID/ to allow this and a bug. That bug will be fixed in the next patch in the series and therefore the test would start failing. Link: https://lore.kernel.org/lkml/d0d111ef-edae-4760-83fb-36db84278da1@t-8ch.de/ Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 21bacc928bf7..7e649814a241 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -512,7 +512,6 @@ int run_syscall(int min, int max) CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); break; CASE_TEST(chdir_dot); EXPECT_SYSZR(1, chdir(".")); break; CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT); break; - CASE_TEST(chmod_net); EXPECT_SYSZR(proc, chmod("/proc/self/net", 0555)); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 0555), -1, EPERM); break; CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break; From patchwork Sat Jun 24 10:30:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13291631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F088CC001DD for ; Sat, 24 Jun 2023 10:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbjFXKbK (ORCPT ); Sat, 24 Jun 2023 06:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbjFXKbH (ORCPT ); Sat, 24 Jun 2023 06:31:07 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71F51BC1; Sat, 24 Jun 2023 03:31:05 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1687602663; bh=Hv07IQfpUi17QmNQC9s2OoEvXVUFS7E+TFWplvGmRyw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PLpwolsw7ZlHoPEmIDUplUBmlSCa8ZaqedGFxQZIe0KHkvGBuIEYCQ8fghPvWEHzT SKEHwbl8Fn4kDf3E4tFrHvu9hHBDkBN4yeBxd0MteqcfvTu6IpSN0ofP8O6i0eeDPm ILi84B1HpjuS8Gb3Jcx1a0ZocYvInkSZ5kH1WKmI= Date: Sat, 24 Jun 2023 12:30:47 +0200 Subject: [PATCH 2/2] proc: use generic setattr() for /proc/$PID/net MIME-Version: 1.0 Message-Id: <20230624-proc-net-setattr-v1-2-73176812adee@weissschuh.net> References: <20230624-proc-net-setattr-v1-0-73176812adee@weissschuh.net> In-Reply-To: <20230624-proc-net-setattr-v1-0-73176812adee@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Zhangjin Wu , Arnd Bergmann , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1687602663; l=1087; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Hv07IQfpUi17QmNQC9s2OoEvXVUFS7E+TFWplvGmRyw=; b=sydRcATQix4hEhnx962ZvNEbCLjg3XbDnJu/cS4rm0AFbOauHU1aZOpDDZuLyUmH8xsoEiR6s ZKxXc2ZQni9DLO1vq0PQMim7IYCgXab/zowgtqGT8vwCFxon9fdZPdW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org All other files in /proc/$PID/ use proc_setattr(). Not using it allows the usage of chmod() on /proc/$PID/net, even on other processes owned by the same user. The same would probably also be true for other attributes to be changed. As this technically represents an ABI change it is not marked for stable so any unlikely regressions are caught during a full release cycle. Fixes: e9720acd728a ("[NET]: Make /proc/net a symlink on /proc/self/net (v3)") Signed-off-by: Thomas Weißschuh --- fs/proc/proc_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index a0c0419872e3..78f9e6b469c0 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c @@ -321,6 +321,7 @@ static int proc_tgid_net_getattr(struct mnt_idmap *idmap, const struct inode_operations proc_net_inode_operations = { .lookup = proc_tgid_net_lookup, .getattr = proc_tgid_net_getattr, + .setattr = proc_setattr, }; static int proc_tgid_net_readdir(struct file *file, struct dir_context *ctx)