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=1796385948; b=fB+iEfuAjHGPQMwhxBlqBCQfo4Aaeg4h1mEEP0wTycKk+iQ/cYuaMG/tU4niWAVwpSxn iOzOUvUceX+N8SnzcNoH7bdG9/61TRS0fufYzTco6uWd7XHo9E1csvPKZ3qO6l3E47/Ku oYZJINBZJMsOY78H5FrukwlZTySPo/6PoAcXtH7Dl/6I6m4HPbABPpOS1pshfzpLEyHPD yx8kiva8XdGkzfdAHf2nciRNZnQ9E7Y2HaXO45eBo3yXKVhOLU+TXaaR6BXTv4CGR6Xq/ F3aacAVL/FcfYwK/SK8T5Squ0vvdjBIjMlk4mgZDPNMGfNkjcKmgOmv2bcWJAlRhBIw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385948; 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=Rsrqp+p1HgZApGlotH9NjCdCyA5xicUcmEOzZ1k7iis=; b=Z+Sk2XtFUGM42DHK+DA/8ReOqUDZ5U1TarvkDFjeWOMPzhtfPPdalO36JmQUS4TDVMDK z/iAFgrPvxoHAbMToMh1cWxauDCIDJLUdq8tf+EC7vRAD62Ggj6bL2YtyQPoM+REGhpYq jZkzEev9hIFF8nHdpD9VVwH7vUYJQaiPK9dPCygU625whvaT2bkdNMCfY9JHOj4pEbCs+ ysSEycRKMSrfWTwQ6i2pBV77KySBaZJcMRZixjDX/sFjpzN6wo7k26qzpqhMqMeDFbGkw nZgutbgBRi/iXRqTaex58+t2Io9rEYqz6hy5sdYlRu7nMr7SnckpZLkbdpKB3GGLnwg== 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=AmYH2bbZ; 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 2D660606A322; Fri, 4 Dec 2026 12:05:48 +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=AmYH2bbZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C1031F000C2; Fri, 4 Dec 2026 12:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385948; bh=Rsrqp+p1HgZApGlotH9NjCdCyA5xicUcmEOzZ1k7iis=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AmYH2bbZRc3LUlmVwuPfAMjsF0pnDHGnW7qgvyJofX++gZEVM7/yDqQhlWXilXYG2 R5JDpD1LB2rkYscgGLiWmE7VLlIHQ33fK02eWpNAGqtLmbCfE0Gwu/4/UVWsDrwZlN 6ndQh+9BxACJTTDMcGlD5CaZt0RVj7he3cTlK12o= 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.6 0758/1167] ksmbd: refuse to read a handle that is not open for reading Date: Fri, 4 Dec 2026 19:03:05 +0900 Message-ID: <20261204100721.820709212@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: Replaced the fp->is_posix_ctxt check with work->tcon->posix_extensions to match this tree's context. ] 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 54bd3e7012d7b..64178954a54db 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -391,6 +391,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