From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 756D7400DE8; Fri, 4 Sep 2026 06:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788502452; cv=none; b=mnDVWrVk1PY1Q00zWqC1Gdn/XtmRaDrOQuMurk1ehHVxwkC/GqoeIt8b/ZxAtv/bJ6Xxdj8tYJ/gYAZE8WnFd3+QkTqRoc016hFU6+zGFy6V3lrs1yJhDJiJHeeCIT9f3NuKnXXQ/tm/jnC+wHWQuNzux3TOpbKuJDbKBZPlnNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788502452; c=relaxed/simple; bh=3z9DgWMYFzy280wVBfkKE9hCB5ne7zrzlx+m7JAe/fU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BhGsj7iQns1LorNDhm9er4cmRMHhOr70HFSQVDwfQoBeyqDrJNbMqAM7+O32iyZTUONUoc9sz3eqHWi8cmJ5+FjBZdktfIpCpDBjJpv97kRI152E5jZX+4dzq85Nu4buFS4VRP6j0pe/aE6IopFJU2/J2ECQpZ+VHHBd/DND6U0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jrqdl4pJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jrqdl4pJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983EE1F00A3D; Fri, 4 Sep 2026 06:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788502451; bh=JVKpCcRj1OP5SnHunp49qlrn7fCKGdkQxQ8YYzM6tHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jrqdl4pJdpe9QkvdEiBxnCQP6HTx5/M41RFNpUSpwpJM+YWl4mqP99Lx2eKr1ioQ1 AFMikX3MOyr/cz9Hue+F60MQUgkljbkKuTv29c31M0Wf1X3Y/DdCmLXiXY2xc97jB0 1p9Q1iNM+qWa2eH4ouQCFCHRA4dUcfdb35LXXD9A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Jeff Layton , Chuck Lever Subject: [PATCH 6.12 211/403] SUNRPC: reject duplicate CREDS_VALUE options Date: Fri, 4 Sep 2026 07:00:14 +0200 Message-ID: <20260904045739.654582047@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045734.806166532@linuxfoundation.org> References: <20260904045734.806166532@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason commit 2e4ce62385c1b8a887c5370af058ac7b52a8eaf9 upstream. gssx_dec_option_array() walks the wire-supplied option array and, for every entry whose name matches CREDS_VALUE, calls gssx_dec_linux_creds() on the same struct svc_cred. That helper unconditionally installs a fresh groups_alloc() result into creds->cr_group_info without releasing whatever pointer was already there: for (i = 0; i < count; i++) { ... decode name ... if (length == sizeof(CREDS_VALUE) && memcmp(p, CREDS_VALUE, sizeof(CREDS_VALUE)) == 0) { err = gssx_dec_linux_creds(xdr, creds); ... } } A reply that carries two CREDS_VALUE entries therefore overwrites cr_group_info on the second iteration and orphans the group_info allocated by the first call. The earlier free_creds path only releases the last cr_group_info via free_svc_cred(), so the first allocation's refcount stays at one and its kvmalloc-backed storage is leaked. No in-tree caller of gssp_accept_sec_context_upcall() expects more than one CREDS_VALUE per reply. Fix by tracking whether a CREDS_VALUE option has already been decoded and returning -EINVAL on any subsequent match, so the free_creds path releases the single group_info that was installed. Fixes: 1d658336b05f ("SUNRPC: Add RPC based upcall mechanism for RPCGSS auth") Cc: stable@vger.kernel.org Assisted-by: kres (claude-opus-4-7) Signed-off-by: Chris Mason Reviewed-by: Jeff Layton Link: https://patch.msgid.link/20260528-tier2-v1-3-d026a1415e0b@oracle.com Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/auth_gss/gss_rpc_xdr.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c @@ -230,6 +230,7 @@ static int gssx_dec_option_array(struct struct gssx_option_array *oa) { struct svc_cred *creds; + bool creds_decoded = false; u32 count, i; __be32 *p; int err; @@ -280,9 +281,14 @@ static int gssx_dec_option_array(struct if (length == sizeof(CREDS_VALUE) && memcmp(p, CREDS_VALUE, sizeof(CREDS_VALUE)) == 0) { /* We have creds here. parse them */ + if (creds_decoded) { + err = -EINVAL; + goto free_creds; + } err = gssx_dec_linux_creds(xdr, creds); if (err) goto free_creds; + creds_decoded = true; oa->data[0].value.len = 1; /* presence */ } else { /* consume uninteresting buffer */