All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolai Dokutovich <ndokutovich@gmail.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Jeff Layton <jlayton@kernel.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Nikolai Dokutovich <ndokutovich@gmail.com>
Subject: [PATCH 1/2] nstree: reject a non-zero spare2 in the listns() request
Date: Sat, 28 Nov 2026 17:06:22 +0300	[thread overview]
Message-ID: <20261128140623.19-2-ndokutovich@gmail.com> (raw)
In-Reply-To: <20261128140623.19-1-ndokutovich@gmail.com>

struct ns_id_req documents @spare2 as reserved, and copy_ns_id_req()
already rejects a non-zero @spare.  Reject a non-zero @spare2 the same
way so that both reserved fields are validated consistently and the
field can be given a meaning later without having to keep accepting
callers that filled it with arbitrary bits.

This makes kernels that already have listns() reject a value they used
to accept; no valid caller has a reason to set the field.

Fixes: 76b6f5dfb3fd ("nstree: add listns()")
Cc: stable@vger.kernel.org
Signed-off-by: Nikolai Dokutovich <ndokutovich@gmail.com>
---
 kernel/nstree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/nstree.c b/kernel/nstree.c
index 44e07d0fa8e5..ba5743dd4f17 100644
--- a/kernel/nstree.c
+++ b/kernel/nstree.c
@@ -437,7 +437,7 @@ static int copy_ns_id_req(const struct ns_id_req __user *req,
 	ret = copy_struct_from_user(kreq, sizeof(*kreq), req, usize);
 	if (ret)
 		return ret;
-	if (kreq->spare != 0)
+	if (kreq->spare != 0 || kreq->spare2 != 0)
 		return -EINVAL;
 	if (kreq->ns_type & ~NS_ALL)
 		return -EOPNOTSUPP;
-- 
2.43.0


  reply	other threads:[~2026-11-28 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 14:06 [PATCH 0/2] listns(): validate the reserved spare2 field Nikolai Dokutovich
2026-11-28 14:06 ` Nikolai Dokutovich [this message]
2026-11-30 13:04   ` [PATCH 1/2] nstree: reject a non-zero spare2 in the listns() request Jan Kara
2026-11-28 14:06 ` [PATCH 2/2] selftests/namespaces: check that listns() rejects a non-zero spare2 Nikolai Dokutovich
2026-11-28 15:44 ` [PATCH 0/2] listns(): validate the reserved spare2 field Bradley Morgan
2026-11-28 15:49   ` Bradley Morgan
2026-12-01 13:23 ` Christian Brauner

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=20261128140623.19-2-ndokutovich@gmail.com \
    --to=ndokutovich@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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.