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=1796379358; b=FSDTmPahgjnqzUNutWBnJA0M+oMdWXRwK/mMvpuHndxdDzmr4RDuBa8hl0+9+73hLUW7 0BgH/GDAiFGC3Wc9uFkAz0FQJ/RfKVchHWh0mGnNlUioqqNR5WjPXuW5aNBk9Eo1GSLCP uqRLjxW5/rXiSIyVazJbwHH9qslHs5/nA7dulw3zI8o/Pov7z9FaJT/QNlJGr9AhZVzgO tudLWm0VJeuxyNqtEI+9s8xYML66vsSvIMm1F/6H2qCev5mrxAEO17mwB6ipLwD5zPjCT iRkHGdDdGljPOqnizudziFtBlYLdWuk4doLc6IgsYdFNsVtfLFKrlD31kDajiS6hHuQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379358; 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=G7TUsDw2e42lfWuY2Ghxv6aNjCNmcukSoT4tiMZdMgQ=; b=nyX8gXbFI5Pjh200wLpDzWXX3fLDi53fJiIBdwp/O6Nrqp6gD20sAMKDCteKdw2vv/QF fI154ixiG/LuRmkoyOXJBSisVSkpnOHJLfvo7VsGPoz/A0LxPfmAeU9wLBa0p4diYCPP1 hjxZCJ963lmOweJL2ZZ8Lm33lV4WDWzvHf/FgTOd2/FCm54w2zsfqi9zdHjmrqpUeRxMr zMDE6l7hfqeYOwVOdcfUap36XnZ2ctabU+SurVw/I3PwLzT/5qdGdIRE9sWxNK0Jk9KVF W3c1enhtAgESD1P/VoEAjHX+GEKTDkqfRZwK/kVdxqOSUkecEwfb9ZCWxGFkD7M5tuQ== 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=RC+iVK8O; 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 0271E606A322; Fri, 4 Dec 2026 10:15:57 +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=RC+iVK8O Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3631E1F000C2; Fri, 4 Dec 2026 10:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379357; bh=G7TUsDw2e42lfWuY2Ghxv6aNjCNmcukSoT4tiMZdMgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RC+iVK8OwgNR3fDtlTpAPkXOou5zYSj2/PLVFLTDA5cY9eJkm6A0UK+Ojb0BnfgRh B6wIwTesaaiOIgg45OuKiYNJ/pvKE3JofiszLhK8iE08Zlv4469WnnEA5myXMVV/87 o7oBo7T7Bx4GSeF1E+gKE+iFG5cUh2knD5cfTfZQ= 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.18 026/703] ksmbd: refuse to read a handle that is not open for reading Date: Fri, 4 Dec 2026 18:58:45 +0900 Message-ID: <20261204100628.263183389@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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 6.18-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: adjusted context: the new FMODE_READ check is inserted before this tree's if (!work->tcon->posix_extensions) { line instead of upstream's if (!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 466a0853dc486..96ec655d61900 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -393,6 +393,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