From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B26FB20A5C4 for ; Fri, 13 Feb 2026 01:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770945574; cv=none; b=h3vbgu60eo6xI2uwq7HcwewItUszPx91CEXni1jL9qzjN6fHj/lo23zd4BU7DOvdH7vDZri5yyJnt59nCBRKSvkVDlV6BdMp6fa12IOrm5JJqasvnpsrPU/HHQDogKrD36abPsPrr6ULLXb8n0Z9pSnp/7sFo8dDdDwId3+z5gk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770945574; c=relaxed/simple; bh=pOqP7VM+mApaVUNM4EB88815+w4SRLILG/EjieeLe+4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CgPoZAVnjpKYFIULmWnkrnsktA4yIwgPH9/a4cHD4amPPaUDfG1x8M7uDggpgiCifbN7g/hd4qLNLE6z0RfMOxrM7Usux9rK//nu7w6IFBG2YyykQTKCX2jlXHWEmb0VFRHn6/OVfWqLc2K2PjzJPGT6G17tPcqs8+Q0OIsgqFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LBEQBN/v; arc=none smtp.client-ip=74.125.224.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LBEQBN/v" Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-64ad2a2851cso460282d50.0 for ; Thu, 12 Feb 2026 17:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770945573; x=1771550373; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DdSR/hkZOakiS24NkJpFojfOy/j7sfQd+s+nYYhJiVE=; b=LBEQBN/veD4tconAj8h01XARaD7uW5xZ3Zy9/r9tNe9kYfNiJegbZW495L7ufV85wK HK1WL87VKwBHOuVTJYc5we1LcqHmhkdUCMlhDXFv2TwKIEHcs4Dcsg63kjoFs1xSs6aH elY4VW9ZR7zcyWHHMDj5n8ylLpQ6M84RJ0A8XPs5LntFbQiO95Ibqw8bBZXA02Hc8UIw +2Pah0EIKpzcDpXxX9bwoIsDOy7SKSmp0MPggj+uEl+r4HDSfcF4i/DRhcRjTIZmdArK N7aXoau6MO2VVqDa+/V2HaSp3VH+E2kPaFg53dG18Ef+24qOYl7kfYk3+HT/QGbDHI7W NWuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770945573; x=1771550373; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DdSR/hkZOakiS24NkJpFojfOy/j7sfQd+s+nYYhJiVE=; b=XWiNgpCz2EHtQz5CrozUyuja068TIT2vlXTd+0YP5jpR0LCjhTTIMRYWX5aU0S7cOX pZeKd2cYUKSsS08ZwB2D1W5HepPyoVyzBr93phFwN7avS7i7E4hWPfFMS9urmOwSCfpE PyhGQE+aMWlQApSpvtkx62KXlhH75lgWQeLVVvKL+bjoO5/g+X0l/jyGSLZj+tw2PzWd K8L6RJcvwORlQ4Iuwko+sbuFykhll0jmXkW/0e+IppW43EhsNXa8M8UTuZfALeEkUqQW batmPrc86IBzX6HNuP29y7jVqub7g2tCCVq21ZY5jq79JB6YQSEv/8noPrKgiCcVOr0u QngQ== X-Forwarded-Encrypted: i=1; AJvYcCVQBAAf7c7noI7FMjvfWsNj2+g2P34m55YzF6qpW8KDe2fX6MVxi0crcZ3PF01ym5KMo/AyjPFlxMj/YNA=@vger.kernel.org X-Gm-Message-State: AOJu0YzrSVtSpReJn88823276PmCLdcsQZs6O4a1vnFlwOQ3TmHf1CSA ctATBrVcPraIrZ0tj7bI4zjCxaAlPbW1dWngDWgvhze/XSwdEpdTIsYu X-Gm-Gg: AZuq6aLNERUUr2laIhjX4+Q36wPFI1R1SCF3Gu0RDR2bYeL0aDiyld3OalntEoD6HLg S0Fo2Q1HjB1KI1C82VjcrEpUzK0N+LGvf4GeUQjI3/CwDKZxikjC746FUaXYKlUx0jTT0k2ynZ7 lNqv4A7o/5nKZMmlNQ4++pqye9PEXA+zLzitYr/vm6CmMfR8MO0efVn+wolbpgzi3pUIW1UKMmN gopzDl+tkcreffCdH34Tc+FRK+gb/MOXsFOVwZgAclCJ4mHEzYOWlI18PLIUZCXTZUVLCs4ckYY NchGRSin+zTCsgCIepdeozvIaUXO56BC6+4RFnxrApnZxUmSKuCY5DPg1Fn28f4ib2tqSKz4Q5B pISAh+0mLoc4PImgf8oL31XoqOiMNm8R4JoLPR/zBkZ3tsKHQMi5eo5PsBLAd6Up0cUThZu+Ysf IgQDArlXKeVQf+i68oQEgHDtkWKuzXrUxyirWswOn4VLVK6zc= X-Received: by 2002:a05:690e:4304:b0:64a:d1bd:8c65 with SMTP id 956f58d0204a3-64c19b63848mr65513d50.95.1770945572751; Thu, 12 Feb 2026 17:19:32 -0800 (PST) Received: from devvm11784.nha0.facebook.com ([2a03:2880:25ff:4a::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64afc95acabsm6061484d50.13.2026.02.12.17.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 17:19:32 -0800 (PST) Date: Thu, 12 Feb 2026 17:19:31 -0800 From: Bobby Eshleman To: Stefano Garzarella Cc: netdev@vger.kernel.org, Eric Dumazet , linux-kernel@vger.kernel.org, Bobby Eshleman , Jakub Kicinski , virtualization@lists.linux.dev, Paolo Abeni , "Michael S. Tsirkin" , Simon Horman , "David S. Miller" Subject: Re: [PATCH net 2/2] vsock: prevent child netns mode switch from local to global Message-ID: References: <20260212205916.97533-1-sgarzare@redhat.com> <20260212205916.97533-3-sgarzare@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260212205916.97533-3-sgarzare@redhat.com> On Thu, Feb 12, 2026 at 09:59:16PM +0100, Stefano Garzarella wrote: > From: Stefano Garzarella > > A "local" namespace can change its `child_ns_mode` sysctl to "global", > allowing nested namespaces to access global CIDs. This can be exploited > by an unprivileged user who gained CAP_NET_ADMIN through a user > namespace. > > Prevent this by rejecting writes that attempt to set `child_ns_mode` to > "global" when the current namespace's mode is "local". > > Fixes: eafb64f40ca4 ("vsock: add netns to vsock core") > Cc: bobbyeshleman@meta.com > Signed-off-by: Stefano Garzarella > --- > net/vmw_vsock/af_vsock.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > index 3b629b4a0359..9880756d9eff 100644 > --- a/net/vmw_vsock/af_vsock.c > +++ b/net/vmw_vsock/af_vsock.c > @@ -95,8 +95,9 @@ > * the namespace's own ns_mode. > * > * Changing child_ns_mode only affects newly created namespaces, not the > - * current namespace or existing children. At namespace creation, ns_mode > - * is inherited from the parent's child_ns_mode. > + * current namespace or existing children. A "local" namespace cannot set > + * child_ns_mode to "global". At namespace creation, ns_mode is inherited > + * from the parent's child_ns_mode. > * > * The init_net mode is "global" and cannot be modified. > * > @@ -2844,8 +2845,16 @@ static int vsock_net_child_mode_string(const struct ctl_table *table, int write, > if (ret) > return ret; > > - if (write) > + if (write) { > + /* Prevent a "local" namespace from escalating to "global", > + * which would give nested namespaces access to global CIDs. > + */ > + if (vsock_net_mode(net) == VSOCK_NET_MODE_LOCAL && > + new_mode == VSOCK_NET_MODE_GLOBAL) > + return -EPERM; > + > vsock_net_set_child_mode(net, new_mode); > + } > > return 0; > } > -- > 2.53.0 > Thanks for the fix! Reviewed-by: Bobby Eshleman