Re: [PATCH 1/2] nstree: reject a non-zero spare2 in the listns() request

From: Jan Kara

Date: Mon Nov 30 2026 - 08:06:16 EST


On Sat 28-11-26 17:06:22, Nikolai Dokutovich wrote:
> 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>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> 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
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR