From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C006947799B; Tue, 16 Jun 2026 16:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628113; cv=none; b=QEr5IVjpgIUK6QBSxDA8s5PjObZ0Si2nytP99MmJ6UQFaGagRgYzC0XcIn92m/mz2QLiD9CYlC3PKWshL/InnJ5LTK42/NPpvTV5OujqCksJlZ3YH4h1oivQbJBZgOvrzflZaizVRBFWwDjXCMYChvY7RN7teHwcuas0IsWT5nw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628113; c=relaxed/simple; bh=OwWmUw5lTLcSLpq0SQlZU4+dQc3MtkFR0eiSGmP4ops=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oZVXM/n8oyt04tM4yh1laPwl4MIhJuuxuTUpW/YRm/Vl3LfVLMvW1Sm+h+c/M/z/zocLoCXw3WnFzHq+ctRcCyPhJXJ/ZY/dOehlJopnwzinfy7JVl2cQjoIeTL2khrNCzoIU/wBy8bJPb+wKqx8we6LEgmLDwEbS68MapVpDAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r3jS/3bG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="r3jS/3bG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C27971F000E9; Tue, 16 Jun 2026 16:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781628112; bh=M9qLHsuP217t9rEB+IrybvtTCFq8aaVYXGoq9FKzvI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=r3jS/3bGf5bhPSsZwbmju9fSsRfWsJXHDccQbvuQF1efVFBHvXR1A8/efsOuDUmY0 eYl8TzsIhmF02xTVR/80UFB4f58zjiQEu6yuXVOV5LI9XGfWdoQYM3+heKXfp5Z8Tk 7J1h3zoPx/Cy6uxPQGPNEjHh+YaOP/nQQ5v/2quM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Namjae Jeon , Sergey Senozhatsky , Steve French , Sean Shen , Steve French , Sasha Levin Subject: [PATCH 6.6 033/452] ksmbd: fix FSCTL permission bypass by adding a permission check for FSCTL_SET_SPARSE Date: Tue, 16 Jun 2026 20:24:20 +0530 Message-ID: <20260616145119.661676678@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Shen [ Upstream commit cc57232cae23c0df91b4a59d0f519141ce9b5b02 ] FSCTL_SET_SPARSE in fsctl_set_sparse() modifies the file's sparse attribute and saves it through xattr without any permission checks. This exposes two issues: 1) A client on a read-only share can change the sparse attribute on files it opened, even though the share is read-only. Other FSCTL write operations already check test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE), but FSCTL_SET_SPARSE does not. 2) Even on writable shares, clients without FILE_WRITE_DATA or FILE_WRITE_ATTRIBUTES access should not modify the sparse attribute. Similar handle-level checks exist in other functions but are missing here. Add both share-level writable check and per-handle access check. Use goto out on error to avoid leaking file references. Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: Namjae Jeon Cc: Sergey Senozhatsky Cc: Steve French Signed-off-by: Sean Shen Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 04d4a784deaf98..97b03f76741ef2 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -8067,9 +8067,20 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, int ret = 0; __le32 old_fattr; + if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) { + ksmbd_debug(SMB, "User does not have write permission\n"); + return -EACCES; + } + fp = ksmbd_lookup_fd_fast(work, id); if (!fp) return -ENOENT; + + if (!(fp->daccess & (FILE_WRITE_DATA_LE | FILE_WRITE_ATTRIBUTES_LE))) { + ret = -EACCES; + goto out; + } + idmap = file_mnt_idmap(fp->filp); old_fattr = fp->f_ci->m_fattr; -- 2.53.0