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 A80FC399372; Tue, 13 Oct 2026 12:31:05 +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=1791894667; cv=none; b=V4Jw+RUQZrJyBKDzSqWMdBdCY90LcE4FXKYzrT9rYP8RIZV7qzgGe06UuUvB9CTBmXsA9rZuWi1Pxr/lNy007KJ85JsW9VTJFxpaYG81sl4jENwk2z8i5BFuqODaFE8X0MtXhO8Rad04ZWMhawSl3bzD6VMC+sCg5dJoWqaYsVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894667; c=relaxed/simple; bh=Y1rws8Jq6SO4GgHZIfi6dkoyE+++o5PKLJNYXqYTOvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ucqg53mhiA1n2UYL0b56zusf20PyoCvmfGiTl7fqOJt2pDZT/zTMwexUPSDlGvt3GWVlLS3/+MhzQUQtM0Sgl22uesh2wN8CJ0X4Zyj73R+uelU0wVZZXyM5ztK5AII+1Um7FLHTkIy4FojgU5u2FWPwO2zm50Jbu/pdgUS59ks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NWxIgv2s; 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="NWxIgv2s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABD771F00893; Tue, 13 Oct 2026 12:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791894665; bh=0v7n+wPcOKyMXfnX5d85ay6MfEeyx4VTBSYJ9OTFZ1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NWxIgv2sjlBukw5F8cPLA9NmXGT4/bGy0pU0FCWTSCTWl7+ultP+VQoRCrd+FGMuD amNZ/xKQK/MKaXflYe4+rDLVwXNiwGPACXQPzgoo+NWRspjOeEFl0g3lEs+2v8x5ca L4enXVVWmbg7w3C7HSA7GLRPWyXpLYszPWeP6hJc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Luxing Yin , Zihan Xi , Frank Sorenson , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.12 016/497] smb: client: close handle after create-context parsing failure Date: Tue, 13 Oct 2026 13:33:03 +0200 Message-ID: <20261013112908.264550761@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@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: Zihan Xi [ Upstream commit 566820af017e81497fb5e9d3ad6e7ffe2828bc8b ] SMB2_open() accounts a successful CREATE response as a remote open before parsing its create contexts. If smb2_parse_contexts() rejects malformed context data, SMB2_open() returns without closing the handle, leaving the server-side handle open and num_remote_opens elevated. Close the handle after a post-CREATE context parsing failure so the error path releases the remote resource and balances the open count. Fixes: af1689a9b770 ("smb: client: fix potential OOBs in smb2_parse_contexts()") Cc: stable@vger.kernel.org Reported-by: Vega Assisted-by: LLM Co-developed-by: Luxing Yin Signed-off-by: Luxing Yin Signed-off-by: Zihan Xi Tested-by: Frank Sorenson Signed-off-by: Paulo Alcantara Signed-off-by: Sasha Levin --- fs/smb/client/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 31b427d5702e5..1dbf8d28bdf76 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -3320,6 +3320,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, rc = smb2_parse_contexts(server, &rsp_iov, &oparms->fid->epoch, oparms->fid->lease_key, oplock, file_info, posix); + if (rc) + SMB2_close(xid, tcon, oparms->fid->persistent_fid, + oparms->fid->volatile_fid); trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid, oparms->create_options, oparms->desired_access, -- 2.53.0