From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388586; b=ZaXQu5bQTltNrgt7Faac5alNjuVZ1ujI8orBGiOdkOKeoKgojsOUu+6PKB7QT9GcchAG BYFkjC6gqHB8pB1jeGb4TIUgqINrCG+i7Kwh8M9ALL699Rb/04zOjZ3iwipK7R/Vh2h9o WfxQgNGXkfYfAGfQre/FqU3DwBHHnqlbgXcLpxpWi0187yaHfpxElXjRcqXLiXAHdqnCy PGcwfwP8YwunIRLzeB9XUm+FaTHLypZu1U5z7oAMWUDacu/TI77Bb9nk31/pYd/v5h7FB 0LxEdqsfrO4Z3Rd6tJPE7LKC4Gz01eIXJg2B4ffm9F53xZqep1nlwyxsEyYovm38grA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388586; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=qwciOL1Gebx4z92hHWhnkMwf6sGtxUCNdT5Kz+bX1Pw=; b=oYik/3QmgmZW28k9t0+F1XWh5wRkIXI4Ot965BgIoMIhb1qpOpmBxSYWD3cs8QJWq6IK VQZTuc8H4/ZuAnFPZvT6JV215ujIBQRoAszwV6EMoeoeszMhQAYCIchEc8iW1bTk3w2TL O0bGDQjdESJc8ldW7j3qSpI+wtx7nnyjHqasD7X0edueRKbRt3y2xYoXmjDjjJUWD/ToD Wloo5KTP2QOZpo/Mc4S14aXmOkY9aLWvgS4P9zjuC/YfbHZOEV7pUaOv47V7sI1dq+nob 8j45KQFni6FrCw3nEfKTNWmBpjN7dZr3nkrD2mPt82v01uaOmiSQdMU74Ss2sgwzVFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=r+3jATMA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1730E606A322; Fri, 4 Dec 2026 12:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=r+3jATMA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 330671F00934; Fri, 4 Dec 2026 12:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388585; bh=qwciOL1Gebx4z92hHWhnkMwf6sGtxUCNdT5Kz+bX1Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=r+3jATMAx6x8UtYHmYD0ROcapjAtwPAfpR51GdGfLZfWzbpGRTWdXwnByv10xXLVG AIPXmiNYCJKmfERozqtcYmErAwuBHQaBTAGuLoZlTM6SWHHRFt9a4L3wlNRzaSZfO2 c+oA6b158ycktKpXNzJqtnzIXJPa99ZFAeN/JGtA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wahid Khan , Ian Bridges , Namjae Jeon , Sasha Levin Subject: [PATCH 6.1 0677/1059] ksmbd: refuse to read a handle that is not open for reading Date: Fri, 4 Dec 2026 19:03:28 +0900 Message-ID: <20261204100701.551839124@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wahid Khan [ Upstream commit 2fd145f8865bb1a6c38a3dc68fa44290008789d8 ] smb2_create_open_flags() picks the open mode from the read and write bits of the desired access. FILE_EXECUTE and FILE_READ_ATTRIBUTES select neither, so a request for FILE_WRITE_DATA | FILE_EXECUTE | FILE_READ_ATTRIBUTES opens the file O_WRONLY. smb2_read() accepts FILE_READ_ATTRIBUTES and ksmbd_vfs_read() accepts FILE_EXECUTE, so a later READ on that handle passes both checks and reaches __kernel_read() on a file that has no FMODE_READ: WARNING: fs/read_write.c:518 at __kernel_read __kernel_read ksmbd_vfs_read smb2_read handle_ksmbd_work Any client that can open a file with write access on a share, including a guest session, can trigger it; with panic_on_warn it takes the machine down. Return STATUS_ACCESS_DENIED when the file is not readable. Fixes: f44158485826 ("cifsd: add file operations") Cc: stable@vger.kernel.org Signed-off-by: Wahid Khan Reviewed-by: Ian Bridges Tested-by: Ian Bridges Signed-off-by: Namjae Jeon [ sashal: Adapted the posix check to the older !work->tcon->posix_extensions condition instead of !fp->is_posix_ctxt. ] Signed-off-by: Sasha Levin --- fs/smb/server/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index 892ca634d1d66..1524454ef6de9 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -394,6 +394,10 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count, if (ksmbd_stream_fd(fp)) return ksmbd_vfs_stream_read(fp, rbuf, pos, count); + /* The access granted on open can include FILE_EXECUTE for a write-only file */ + if (!(filp->f_mode & FMODE_READ)) + return -EACCES; + if (!work->tcon->posix_extensions) { int ret; -- 2.53.0