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=1796379821; b=s8ThYvpTy25GVW0zJPPH2KebHTQjThE3oFAY63N7YzJ3fZcR0yZOWoC5aQTuO7T/axHe gfCyW6hZGoAiMuftzxYUYqOnt+0iAq002ZlEnbw1cJmBqXmmn8WlO59g4sL1jhzwapp/C kjzHNnFZ1vUqghevZXb9vUPlRrfHc4UOY35u1LxFWXTKFtpV4upSPQm7Kl7At78z6lmM8 F4WXc/V53TbqZpMkIEGpSyV435X7HK5LxPyqbFVoTnWp6oKaxMhbM4yyD2IIB34dC137W uq1BxKCsJK5msehRPMyqZ7WknYj7K+SXAbLPzfgzF/CXXnC8Pr/xVg82ig/Q8t5KS7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379821; 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=L0ID+PB6nCR6049sIB9CMtHO9W9SLzkQ9vSWlURFN0E=; b=ytWukCG1K5ob2FTO0whRt4GHVfLC3/6IQflc32VFSnIcruRe+uen0iIccjgzfFOZ3JQB l9jDrsthEPASpD+IfSFuFXtspYPErz/W3v2+7iWfRLpDAv7ucrOjjQGzHmzqG1aFz5J1i 7P1Lqxn1tNn4dgsIak0WKRjkbyd8GFVA42As8tM+R4ZgHo/RsIMs2XexhDh5YE7bDpkuX FAIBoqIhuzoDRnf0XxE4XJlC03c/t3+nPNPj+6itfSRzfDy8F3jjLfkYEimGI2VZo8ysd aQOlbWd0B6Ucr3/hFHOn5bgjt8av99fLn7kpCm/yX4MQTDdBybEbt5VzB7Y+9tnd+KA== 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=C2WFSLod; 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 211E9606A322; Fri, 4 Dec 2026 10:23:41 +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=C2WFSLod Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88D2B1F000C2; Fri, 4 Dec 2026 10:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379821; bh=L0ID+PB6nCR6049sIB9CMtHO9W9SLzkQ9vSWlURFN0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C2WFSLodEO2asnWih0tH3D3YvYlD/69Uam9UsiVhRkN0yvvoPrfiK/+D1zCuzl5oz VpXSGMVdaOpsihpqwujXZQV2cmz5jZERzfmJr/SQbvr33LzB6pOWFJyNbXhySRyxJp T4JUzil52ZvaCYjUDeVbrDotATMIrS3hK/CdWINQ= 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.12 049/555] ksmbd: refuse to read a handle that is not open for reading Date: Fri, 4 Dec 2026 19:01:32 +0900 Message-ID: <20261204100608.052600910@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 9aee0214e8fdc..732cb489efd90 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -390,6 +390,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