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 C6F603F1AA4; Wed, 20 May 2026 18:25:46 +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=1779301548; cv=none; b=cdsZQPRX7qNKU8pDFBb4igOO6osxh/kTTVQnmY1H+2hA0IkCdijKt6HRs7D4wEXCO4w6OSB0mUcAJByVPreYSYKN7I1T3CUwXxarJiPPNlIcUl/hd/tQ/JOnVv64QRdEMxYSjc6Z4HHgzMDbJlihgbSO/mmNrnbVMueHV95E0fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779301548; c=relaxed/simple; bh=u/UOSU9nyVOjWe2A9ug1KWuu29xeZK4z8u5ehJkUV90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KYPPNVf7MRJya3D3X6QBNlcE2gKS4Vig7140kWjyR+9UvoZ1L9PNlpHOSBnn545iTxABVKt8hAX5ecyMwwyfGOIBplh5VbNHQy9qLw+uZFpJKrn5+oy8DmZVCbiFpP6XnHzZ4Kq0iyHl2ocxnOPhOy9I5jwYRfHPmb0su57u8Yg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=spMfUeqi; 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="spMfUeqi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39C471F000E9; Wed, 20 May 2026 18:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779301546; bh=3kTeMAtvUfvKmwe/I81tJkKwVJBvL5ScCLcdW3DGawU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=spMfUeqivPV3rpsAuWO01XdJQpS/zicBgZ+XEmcN2rcZKX33V4TWg2kflrMOetok/ +ohtolWkZgefTs0xVPfAc/oJzOC3V0jBeXPBlxosK/omG81eyGPV1r9DYXS+aHM0oy dd+YfRabg5g/YBqfTzAWCdjV96Cg8MJHd14mR5Sc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liang Jie , Tom Talpey , Steve French , Alva Lan , Sasha Levin Subject: [PATCH 6.12 595/666] smb: client: correctly handle ErrorContextData as a flexible array Date: Wed, 20 May 2026 18:23:26 +0200 Message-ID: <20260520162124.160669657@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Liang Jie [ Upstream commit 215b7f9ecb8d7c14d56febdcdd246f3579c32aba ] The `smb2_symlink_err_rsp` structure was previously defined with `ErrorContextData` as a single `__u8` byte. However, the `ErrorContextData` field is intended to be a variable-length array based on `ErrorDataLength`. This mismatch leads to incorrect pointer arithmetic and potential memory access issues when processing error contexts. Updates the `ErrorContextData` field to be a flexible array (`__u8 ErrorContextData[]`). Additionally, it modifies the corresponding casts in the `symlink_data()` function to properly handle the flexible array, ensuring correct memory calculations and data handling. These changes improve the robustness of SMB2 symlink error processing. Signed-off-by: Liang Jie Suggested-by: Tom Talpey Signed-off-by: Steve French Signed-off-by: Alva Lan Signed-off-by: Sasha Levin --- fs/smb/client/smb2file.c | 4 ++-- fs/smb/client/smb2pdu.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c index b7ab18d4bedca..35d2933982d31 100644 --- a/fs/smb/client/smb2file.c +++ b/fs/smb/client/smb2file.c @@ -42,14 +42,14 @@ static struct smb2_symlink_err_rsp *symlink_data(const struct kvec *iov) end = (struct smb2_error_context_rsp *)((u8 *)err + iov->iov_len); do { if (le32_to_cpu(p->ErrorId) == SMB2_ERROR_ID_DEFAULT) { - sym = (struct smb2_symlink_err_rsp *)&p->ErrorContextData; + sym = (struct smb2_symlink_err_rsp *)p->ErrorContextData; break; } cifs_dbg(FYI, "%s: skipping unhandled error context: 0x%x\n", __func__, le32_to_cpu(p->ErrorId)); len = ALIGN(le32_to_cpu(p->ErrorDataLength), 8); - p = (struct smb2_error_context_rsp *)((u8 *)&p->ErrorContextData + len); + p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len); } while (p < end); } else if (le32_to_cpu(err->ByteCount) >= sizeof(*sym) && iov->iov_len >= SMB2_SYMLINK_STRUCT_SIZE) { diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h index 076d9e83e1a04..3c09a58dfd073 100644 --- a/fs/smb/client/smb2pdu.h +++ b/fs/smb/client/smb2pdu.h @@ -79,7 +79,7 @@ struct smb2_symlink_err_rsp { struct smb2_error_context_rsp { __le32 ErrorDataLength; __le32 ErrorId; - __u8 ErrorContextData; /* ErrorDataLength long array */ + __u8 ErrorContextData[] __counted_by_le(ErrorDataLength); } __packed; /* ErrorId values */ -- 2.53.0