From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E254F606A684 for ; Sat, 21 Nov 2026 00:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hCUdNbCW Received: by kanga.kvack.org (Postfix) id E6F5A6B05CD; Fri, 20 Nov 2026 19:10:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF9046B05CF; Fri, 20 Nov 2026 19:10:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C72D06B05D1; Fri, 20 Nov 2026 19:10:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 959916B05CD for ; Fri, 20 Nov 2026 19:10:20 -0500 (EST) Received: from smtpin14.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2CF2B14024A for ; Sat, 21 Nov 2026 00:10:20 +0000 (UTC) X-FDA: 85457194200.14.67E5FC7 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf18.hostedemail.com (Postfix) with ESMTP id 8033E1C0002 for ; Sat, 21 Nov 2026 00:10:18 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=hCUdNbCW; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of jarkko@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1795219818; b=eyxs9BQ4OpUjpz1ktlgkoRZFGbKuMqUTBJUgPe2p5NgCisIQPxneGFbcbrMcsLpWgpy01t BROrISZ6YLQr9w+6h+2p3EiPN8yPvqCWtX6xtCxz5lQN4uRWN7KyrxVS5545qo5MOe9zre xcCj5bA07FcKa8PKQHBQiTA08Fn7qqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1795219818; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=keQHOqhbQzKnskPEephNWpQJ2+gEr/C+/pBH6fJD4Uk=; b=CKnYx5KLU0mmn7EmnoaaZ/ZcIi2gXQ7ZsQzunDPMdcnYgnHnE0ZqaJOyo9P4jSthWJcR3p RziqQazJJ4RrBndQGRm61RT9iDVKVcep7QN77GNFGukheJ3SmMWY3BBEzTmlMT23pPiKX7 LLAQ0xr+w4IIY0w24It6uvFvHvyAMKo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=hCUdNbCW; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of jarkko@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=jarkko@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with UTF8SMTP id 22133623A3; Sat, 21 Nov 2026 00:10:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id EC7FC1F000D2; Sat, 21 Nov 2026 00:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795219817; bh=keQHOqhbQzKnskPEephNWpQJ2+gEr/C+/pBH6fJD4Uk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hCUdNbCWHBgRryTU5nu551za3xRW0gezc5OnTNZCeYNqM9wRJ/NsAbAG+VMQ80fFc uoQohgRLiSlksCc/Z8OXAbokvEzSj2xFDa8SHwHcHhFa9Mn4xhv1Gww7/2oW4JGL/D I/qlCZrwdXviGnAWdDkBva0/NKmT2NxDqQbqnlGKCmc2i86RdFVhnvMh9gbxbtOdja oyVx0Mgr/BwtKtQ0XfHqiIFV9uqT7kXGDt1GJ6f5Y1qpPeuWjr4cktfc+tNAvXZLSo ArIrP3F4dln8owvw8NahPBsy34x8S7IbeE6gBha8FZ0lmJqFEy+A5PAviI8Yv13P4v viHdX3QpRHJkw== From: Jarkko Sakkinen To: linux-fsdevel@vger.kernel.org Cc: Jarkko Sakkinen , linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, Alexander Mikhalitsyn , Alexander Viro , Andy Lutomirski , Christian Brauner , David Howells , Jan Kara , Jonathan Corbet , Josef Bacik , Kees Cook , Neal Gompa , Paul Moore , Serge Hallyn , Zygmunt Krynicki Subject: [RFC PATCH v5 19/25] ipc/mqueue: Implement ->set_rootns() fs_context operation Date: Sat, 21 Nov 2026 02:08:38 +0200 Message-ID: <20261121000844.1863324-20-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261121000844.1863324-1-jarkko@kernel.org> References: <20261121000844.1863324-1-jarkko@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8033E1C0002 X-Rspam-User: X-Stat-Signature: 3c9ua9mx7cnaapcdz5dqwxpwohzcwpju X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X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86JSPOIRmj/jPLaPcvzO8HUj64fLnPGRqZMJea0wLkk62NHVIU9c9P3bruJydHs/wBwekmP31rKUNxkOSKhPr5rzqpVFwhiAQoEAwoX1ka5MOUqsRvJMcDB7VH26L+NciOL74kaNdGoGz8ic6zPkpHRSUUyBMxQqDy2LlmBOYmCI4bKz58RFAnbjp0HiinFodk9drKo8eF9EChG0AhaYkrYopfRpkWCr6Hp8sO5hfcsDn+ZnZZUW0xNwG0tEp8ixmOuf98qtGzkT8JRrpFNPBQVTObuaPGkwYFkEdr6fzHdp1yQFyCqkYzQlABlIWo9kPnpkiDiEivy1BcxekU2RPVbZlWSUefSQWvQALhqCYqU+Tqemc07f/+SSZMGsJc/tgce5m/ZxL4Vgbg9g9dqMRhEe/hs0BisEolKVRVyLvgdj4tJU/X5iTIiph2saFkhA= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 mqueue_init_fs_context() captures current->nsproxy->ipc_ns and resets fc->user_ns to ctx->ipc_ns->user_ns, overriding the user namespace delegated by FSCONFIG_SET_ROOTNS and leaving the context bound to the caller's IPC namespace. Wire up mqueue_set_rootns() to switch ctx->ipc_ns to the target root namespace's IPC namespace and update fc->user_ns to match. Co-developed-by: David Howells Signed-off-by: David Howells Signed-off-by: Jarkko Sakkinen --- ipc/mqueue.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 322c3dd98c44..f94e9b566bd0 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -400,6 +401,17 @@ static struct inode *mqueue_get_inode(struct super_block *sb, return ERR_PTR(ret); } +static int mqueue_set_rootns(struct fs_context *fc, struct rootns *rootns) +{ + struct mqueue_fs_context *ctx = fc->fs_private; + + put_ipc_ns(ctx->ipc_ns); + ctx->ipc_ns = get_ipc_ns(rootns->ns->ipc_ns); + put_user_ns(fc->user_ns); + fc->user_ns = get_user_ns(ctx->ipc_ns->user_ns); + return 0; +} + static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc) { struct inode *inode; @@ -1613,6 +1625,7 @@ static const struct super_operations mqueue_super_ops = { static const struct fs_context_operations mqueue_fs_context_ops = { .free = mqueue_fs_context_free, + .set_rootns = mqueue_set_rootns, .get_tree = mqueue_get_tree, }; -- 2.47.3