[PATCH 1/2] nstree: reject a non-zero spare2 in the listns() request
From: Nikolai Dokutovich
Date: Sat Nov 28 2026 - 09:06:38 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Nikolai Dokutovich <ndokutovich@xxxxxxxxx>
---
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