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 B18652931F5; Fri, 9 Oct 2026 14:15:47 +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=1791555350; cv=none; b=Neu440ezhSTovSrVWAEafg9iTjOUZeifdSfNSmTe/Lt/9Hfc1zwmMUPBjNEjH9lLHSFQuhOAjYnIDHvBx9X/KBEat2cdcBUo9km7qCfY0WIyxQKg4Wka75rGiFijCCYcyQ6war20ujtmw/ujx/nZsfDk5D+2RVoO9hlNABosgzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555350; c=relaxed/simple; bh=pFUJfLDi9/TBkuVcHbyFFBubsVZMwjcXDMTwvf29ylQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rN8zZwtsOFjtLYzGS1RBLPRailTQjuPXPNwdInuMKNRd7y5tz1ihweQxqcw/aFJ5tjBW9YqfRrXz0Yz2ESkVw9BbBnPf8SKadrYU3jwoQQpeqGqV77jDpL3b+QSJbGFZQ17swK9qwHpt/IE8Eg69oCfMm2KphewIvs75HhQxEJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ed/ijna2; 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="Ed/ijna2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 152A51F00898; Fri, 9 Oct 2026 14:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555347; bh=/qYEahMPHHlNWGlKqYfcECJRf+u5q1rQoA5p/G434Bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ed/ijna21KEm/fBHijyeQkodQLjaJnB7eA9dCA8ThctJ2EMYob1THTuP69HGhb97y /ZV/DA8rU5eundI945KNzfD9ZbaVG31EFvbPA8gItxKQca8LGl7/xidWLH3XpVNv8R w8hgnSlU4pSK8s6A1/mUGBrvEtsA42qf+2VbOupU= 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.18 016/403] smb: client: close handle after create-context parsing failure Date: Fri, 9 Oct 2026 16:06:17 +0200 Message-ID: <20261009140952.498815567@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140952.119038291@linuxfoundation.org> References: <20261009140952.119038291@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.18-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 bca0d5e85a9e7..14ee2ecdf362b 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -3318,6 +3318,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