From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=35.83.148.184 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796155611; b=MX27azabY2SwnO0X30woZciE406EIbtg+2QmiaMCdsvazZzFFqAAr+HghL+U8AJBNiOR QpOVGAHTsoqv/k9+3R0+s41GhHjNIbBqXgJhaqMqUXbv/XnVwUS9MKNN6HlNURZzEoqd5 T3V6aREJfqaRLEEXQQfCLmt3+SUSyGSBLiZ6nAv+SY9kNR3iOdJnis6pYF8LL80uA0bLW TzkSc3evBnz8lXVY8NoewFYSJ6tPyIZz+ebaxJGgzlywySHv/A+T19BxwXQ2hJeNsalJy rB5x/i1dVPsDgCQ/w3y0FmKokw9SDKS8TEynqKeyYtLIVmwwYzbhAJsgmcrDwZuEGXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796155611; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:Received:Received:X-Farcaster-Flow-ID:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; bh=t8JQ8HmwA8gUUTAm1KwvSO5B0lRFwHe1AZxo3Ehksrk=; b=qX4qwWjELd5wOk3hyVwGw44PJ5JjPNxrDhTXa1329Ro3odOo/JViZo6z2VZsaEBOAugD 0mO+2VHvJo4X6Xj1h5y9CohmPiWwx5438CnKXX3TxbJHfG3v04r9pi1g9wPwghXKKfS4B 5w5gjJ5hDHbAgHdP3N8SIxekWkTo1Tcg+7TuLjaeTUqm+iwiwxP5I966vIGTyWN0HhyHs D9d6QFcE6IfAV4dL1uVezIWfIyQT1Em4j0I5Wqr3NNnH2fIz0eJAneHRyp8NUSTJn3lib HRQsHXbkqiDDFio4SbNTEuwLiULU4fQzs968xpHqlbq/zAvwKXn9cFrOBFFAhAnj98Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=ZoEiIlC7; arc=none smtp.remote-ip=35.83.148.184 Received: from pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com [35.83.148.184]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7296F606A31A; Tue, 1 Dec 2026 20:06:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7296F606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=ZoEiIlC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1796155611; x=1827691611; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=t8JQ8HmwA8gUUTAm1KwvSO5B0lRFwHe1AZxo3Ehksrk=; b=ZoEiIlC7QFqM7BlOBw4Q9eyUytf2GwWkPX87LPCW69SI+eJjKA+SroFe kMryba91xma+iyujP7+7DYOBT229e2EosPZAJ7biW2kNjrL9xyvP4ZSdu teTO7Hv407qVkwmf5upKeMjO5DKpAPFRl1kqllCKA8Dp9GXqNvJWxdkqE 46yTPANJZL5b6I78U7BRnEqT/E2gAzuKWvTPjzl4VezOiSjViMGEyUim5 JQuAery+Hpni9PbMFFScki0jdFDivyf684jmzheSYCL/nYNttWIB0C7k6 a6CK16TGJ/mJi6NlQbaKkIPtPFm7GCyrkd+O124YhGN6YJA1nSs4T72/Q A==; X-CSE-ConnectionGUID: YN0Oo1MnRXuYkC8gwfME/w== X-CSE-MsgGUID: dXub9YeoR2SdazEUklrlWA== X-IronPort-AV: E=Sophos;i="6.27,245,1787011200"; d="scan'208";a="35428834" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 20:06:51 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.104:2024] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.37.107:2525] with esmtp (Farcaster) id e364b5fa-04a1-4d14-8b6c-23df5a7df438; Tue, 1 Dec 2026 20:06:50 +0000 (UTC) X-Farcaster-Flow-ID: e364b5fa-04a1-4d14-8b6c-23df5a7df438 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Tue, 1 Dec 2026 20:06:50 +0000 Received: from dev-dsk-mkbund-2b-9ea2efba.us-west-2.amazon.com (10.2.100.138) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Tue, 1 Dec 2026 20:06:50 +0000 From: Mark Bundschuh To: Paulo Alcantara , Namjae Jeon CC: Steve French , Ronnie Sahlberg , Shyam Prasad N , "Tom Talpey" , Bharath SM , David Howells , Diego Oliva , , , , Mark Bundschuh , Subject: [PATCH] smb: client: handle zero DataOffset in CIFSSMBRead() Date: Tue, 1 Dec 2026 20:06:39 +0000 Message-ID: <20261201200639.339917-1-mkbund@amazon.com> X-Mailer: git-send-email 2.50.1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D031UWA004.ant.amazon.com (10.13.139.19) To EX19D001UWA001.ant.amazon.com (10.13.138.214) commit 5be5bdda5863 ("smb: client: reject out-of-bounds DataOffset in CIFSSMBRead()") rejects any reply whose DataOffset points inside the READ_ANDX header, including a DataOffset of 0. Windows sends a DataOffset of 0 for a read at or beyond EOF, which cifs_readv_receive() and SMB2_read() both accept by treating the data as starting right after the header. Handle it the same way in CIFSSMBRead() rather than rejecting it, and keep the check that DataOffset + DataLength lies within the received response. Fixes: 5be5bdda5863 ("smb: client: reject out-of-bounds DataOffset in CIFSSMBRead()") Cc: stable@vger.kernel.org # 6.19.x Signed-off-by: Mark Bundschuh --- Found while backporting 5be5bdda5863 to older kernels that still read through CIFSSMBRead() in ->read_folio. Against a Windows Server 2025 SMB1 share, reading a file whose size is a multiple of the page size then fails with EIO at the read past EOF. On current kernels the SFU and mfsymlinks parsers are the remaining callers of CIFSSMBRead(). A READ response with a DataOffset of 0, which cifs_readv_receive() and SMB2_read() already accept, makes those lookups fail with EIO instead of being parsed. fs/smb/client/cifssmb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index 68f05a52605f..5059967b274b 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -1728,6 +1728,9 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms, data_length += le16_to_cpu(pSMBr->DataLength); *nbytes = data_length; + if (data_offset < sizeof(*pSMBr)) + data_offset = sizeof(*pSMBr); + /*check that DataLength would not go beyond end of SMB */ if ((data_length > CIFSMaxBufSize) || (data_length > count)) { @@ -1736,8 +1739,7 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms, rc = smb_EIO2(smb_eio_trace_read_overlarge, data_length, count); *nbytes = 0; - } else if (data_offset < sizeof(*pSMBr) || - (size_t)data_offset + data_length > rsp_iov.iov_len) { + } else if ((size_t)data_offset + data_length > rsp_iov.iov_len) { /* check that the data lies within the received response */ cifs_dbg(FYI, "%s: bad data offset %u length %u for response of %zu\n", __func__, data_offset, data_length, rsp_iov.iov_len); base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c -- 2.50.1