From nobody Tue Dec 16 22:10:51 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F70B230BD0 for ; Fri, 30 May 2025 20:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635405; cv=none; b=nRyu9KBHDFPkTXYQVCTuf2sIpnKdNQRJN66NgQt2IJolbBw+fcge2c99xeTqgm1zSdO9UoGfs1hcZRw2joy9jJn3kspH9LhzKOpPCd7Uf/V1MUhIPfTEEXAm4tjdKGozZ3b47wGK/hO/tKAAHG7rQ38oTYaS0VPzgHLF3ii7DcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635405; c=relaxed/simple; bh=bNUPz70hUdTY/+4NoZbAa1PY+jtSHeygov0tPSZlKSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kKAOH/aMJwA5jlSu9DUOqCeWHtWQ2+NDLW2TRxx0Gg2WHF+NJ0DLzF1Ds5LLXPgQmSVvdHUH2MsnBZHct/odPqp2eZ1FUuSk0SC7z9PfBwg/AbpyyoEfTgHHEeP4CE6vHTCmg2+9TnGrbp+cIw3fkliFcl/wgtt3YMxx63/kA1o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XoxBXffC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XoxBXffC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748635403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ji8vBXxmUlH3SByGHyn62HMLhQDFaED7+XduPIJj2Yw=; b=XoxBXffCSAOoJhnLjddR5pWuR/ysqMbtTnBRsOCwpoi7LPRnTGigP9l/L3qSF9TLMxDqw5 WyYKgRElFL91Z20fDVEheqZcVenYz7VxDvtImn6vxt6idrSdggl3kMtxCf0fkTC34GjyTt y/U67jYF1Rbucwav0UVjmW07oRcyzbE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-9c4XJIs3Pkmj00gu8Gl0Sw-1; Fri, 30 May 2025 16:03:21 -0400 X-MC-Unique: 9c4XJIs3Pkmj00gu8Gl0Sw-1 X-Mimecast-MFC-AGG-ID: 9c4XJIs3Pkmj00gu8Gl0Sw_1748635400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D821195608A; Fri, 30 May 2025 20:03:20 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.162]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C50171954191; Fri, 30 May 2025 20:03:18 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Christian Brauner , Al Viro Subject: [PATCH 1/3] kernel/nsproxy: remove unnecessary guard in validate_nsset() Date: Fri, 30 May 2025 16:03:04 -0400 Message-ID: <20250530200305.85319-3-jsavitz@redhat.com> In-Reply-To: <20250530200305.85319-2-jsavitz@redhat.com> References: <20250530200305.85319-2-jsavitz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" By the same logic as commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards"), remove the guard around put_pid_ns() in validate_nsset() as put_pid_ns() already performs the NULL check. Signed-off-by: Joel Savitz --- kernel/nsproxy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 5f31fdff8a38..be89e006e6aa 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -481,8 +481,7 @@ static int validate_nsset(struct nsset *nsset, struct p= id *pid) #endif =20 out: - if (pid_ns) - put_pid_ns(pid_ns); + put_pid_ns(pid_ns); if (nsp) put_nsproxy(nsp); put_user_ns(user_ns); --=20 2.45.2 From nobody Tue Dec 16 22:10:51 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BF17283127 for ; Fri, 30 May 2025 20:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635409; cv=none; b=udGjIodvcf7DsyXTHC19Htgom5V4OQiXt4pfEcG8I4vz6xqu7/6dmlAt1qWjl6lhd+14CnhDDCCOLtSD+44WVrgsMe93Bj3+dmdZ9bbWKmkW33mEBM+BjTvXJVLhGacgVT2eknIfFGIl96Gsi5taCLHDM/FmLRntEjcbG/4uQ1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635409; c=relaxed/simple; bh=+DvTVLIgxCdD0+qE3FDPaQibTJm/38OE1Jgc2d29iHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eYUC/xmrSbWQwcnwJ4wXtI3tnM+ZG798uLZ1wSnYjWehScXy2UIl/yiHscIKhQUhyW6LeEFRVRXqOqgJsBCFfo7thc/mwOnue87IWSQ42CLAcbnt4eFhy/JBXXmnwRKafWpHPV/Mf576hmY8S8JGeyf8MSRbme/OhTuKp7s09GM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eJcmVygN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eJcmVygN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748635406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O1ZCbee+sOx6d3QL5Ei8/lRxn7El3Q5KErcrq9MgA4Q=; b=eJcmVygNUipTyB45FdA9iFQ8SSrEYOHPsmSG6rRakMuzr0NZvnOWZ03aO8856OcBjm035U yOrjuUrpXiz2Q2riytORu3gn2+dd9wi9erL7T9I167VT9kowoE5+1N9J1vS9nOK23BEAqk j3vLzB6vPBrCu+ukhTkDlE3tWFNbE/8= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-zUBnLtoiOfKXV0hBRSvwMg-1; Fri, 30 May 2025 16:03:23 -0400 X-MC-Unique: zUBnLtoiOfKXV0hBRSvwMg-1 X-Mimecast-MFC-AGG-ID: zUBnLtoiOfKXV0hBRSvwMg_1748635402 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB29F1800873; Fri, 30 May 2025 20:03:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.162]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 65D371954191; Fri, 30 May 2025 20:03:20 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Christian Brauner , Al Viro Subject: [PATCH 2/3] kernel/nsproxy: fix put_*() call ordering in validate_nsset() Date: Fri, 30 May 2025 16:03:05 -0400 Message-ID: <20250530200305.85319-4-jsavitz@redhat.com> In-Reply-To: <20250530200305.85319-2-jsavitz@redhat.com> References: <20250530200305.85319-2-jsavitz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" The calls to get_nsproxy(), get_pid_ns(), and get_user_ns() happen in that order, so call their respective put_*() functions in the reverse order. Signed-off-by: Joel Savitz --- kernel/nsproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index be89e006e6aa..20b07120dbfd 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -481,10 +481,10 @@ static int validate_nsset(struct nsset *nsset, struct= pid *pid) #endif =20 out: + put_user_ns(user_ns); put_pid_ns(pid_ns); if (nsp) put_nsproxy(nsp); - put_user_ns(user_ns); =20 return ret; } --=20 2.45.2 From nobody Tue Dec 16 22:10:51 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC09E2836A3 for ; Fri, 30 May 2025 20:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635410; cv=none; b=ocM8NgHqYuLfzZ7lFNZvZZuRgAZ0d54tYJaJYxCEnUnOJKx9gY9w+qQk2HSc4con1gPyzbWSpgFJFauC9vjP+XPGasB6lm2a8w0QWVZINxNj/n3yAS/4Myde9L/ecOsHDV4pSBHETywNbVC9/vdg1vcot3U1GseISAh919DAi4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748635410; c=relaxed/simple; bh=XRQdsbpohIJQx39lQd5ufvr9OER85OhmOTqmMz0Mvsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8q8/we5oITG05v8px9EUEpVegYZErp+Stk0FCCpe7AXFiko+zU5hEibgULUcjC1fExCMa1ysotLaTMl21XONBPam/O0SAisGCdXfgs+aSuf0UdDhTRyyuJrc2HdHANXHPPBuhFXb62m9TbPqqDvbX91gu87jxzHgB/0VKm9fxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iLXdVc6C; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iLXdVc6C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748635407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v4pwi3lxjSBtkiKQkrg6DQ1FECfBbO4dmGW/XGDv6cM=; b=iLXdVc6CTPDwQYCavHkSIvbavdAjKpsFO+pcCY3tStUsC1OBJ80M9OYD0QvYagx05thShX /0/kURRdNGQE+2T/1mXe/fQS6VSBFhx5h4C4OP+7bNbKivZj6VZk8j+C9RhlMydQgcn5CL 5AQ4IlcI0j9X20If59pWCUKLdMVrIKY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-dgOqtYwOMrGnYxKkT_HQ2g-1; Fri, 30 May 2025 16:03:24 -0400 X-MC-Unique: dgOqtYwOMrGnYxKkT_HQ2g-1 X-Mimecast-MFC-AGG-ID: dgOqtYwOMrGnYxKkT_HQ2g_1748635403 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F27F81956046; Fri, 30 May 2025 20:03:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.162]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D85EE1954195; Fri, 30 May 2025 20:03:21 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Christian Brauner , Al Viro Subject: [PATCH 3/3] kernel/nsproxy: utilize cleanup helper for nsproxy references Date: Fri, 30 May 2025 16:03:06 -0400 Message-ID: <20250530200305.85319-5-jsavitz@redhat.com> In-Reply-To: <20250530200305.85319-2-jsavitz@redhat.com> References: <20250530200305.85319-2-jsavitz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" A cleanup helper for nsproxy references was added by commit d057c108155a ("nsproxy: add a cleanup helper for nsproxy") however it is only used in commit 5b08bd408534 ("pidfs: allow retrieval of namespace file descriptors"). Simplify nsproxy code by using this cleanup helper. Signed-off-by: Joel Savitz --- kernel/nsproxy.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 20b07120dbfd..c623e9ce3c2a 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -228,7 +228,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_fl= ags, =20 void switch_task_namespaces(struct task_struct *p, struct nsproxy *new) { - struct nsproxy *ns; + struct nsproxy *ns __free(put_nsproxy) =3D NULL; =20 might_sleep(); =20 @@ -236,9 +236,6 @@ void switch_task_namespaces(struct task_struct *p, stru= ct nsproxy *new) ns =3D p->nsproxy; p->nsproxy =3D new; task_unlock(p); - - if (ns) - put_nsproxy(ns); } =20 void exit_task_namespaces(struct task_struct *p) @@ -368,7 +365,7 @@ static int validate_nsset(struct nsset *nsset, struct p= id *pid) unsigned flags =3D nsset->flags; struct user_namespace *user_ns =3D NULL; struct pid_namespace *pid_ns =3D NULL; - struct nsproxy *nsp; + struct nsproxy *nsp __free(put_nsproxy) =3D NULL; struct task_struct *tsk; =20 /* Take a "snapshot" of the target task's namespaces. */ @@ -483,8 +480,6 @@ static int validate_nsset(struct nsset *nsset, struct p= id *pid) out: put_user_ns(user_ns); put_pid_ns(pid_ns); - if (nsp) - put_nsproxy(nsp); =20 return ret; } --=20 2.45.2