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 E6D2644AB62; Tue, 21 Jul 2026 21:50:10 +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=1784670612; cv=none; b=ajMup+ICH/zRA6l+YGVo4JqPgHSJnJjYxo/jzplVjkZNGy+49ApDqVv5hNnHFJZU0llzliQPQS2n2oqzVTBqHMN6lyqYYKqmXozTHMp5mKElt35kak8HuivtbiGXQ5Fp0lhCa9MhLyLwLZQMzrYaYbM7XIENtv9lQp0cB6cxzdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670612; c=relaxed/simple; bh=EcXSfBGViuU+TKJEjegxgboDp8QC29ct7hiH+fmAQKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fzAuNOcRHI1q6lyV9Gbyx3IcGHsCveCBpRdBi6ExNgSitQJLYf1qEy7EZGR+gec6t7Tu/s8pYO8mB6CrVV3A1U+OxWkSRb1mJDPWN4Hk0CV1pEl4P/UkN94gdkyuj4uq8JMhh+h3kK2jtn7BDF+d36NBaIonY3OQVO/5d8U11z8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SLFrDsMw; 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="SLFrDsMw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58E611F00A3A; Tue, 21 Jul 2026 21:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670610; bh=SKkE0yh73XNPLATtU5K5nK57ILEAf+vovUWRJjmwwMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SLFrDsMw+2xPBfL/TQO8XiX9+KrWdsny/m1xfwhK/d3mRW5tOSY8lsAHtlfGR9T+c A497LgP4RoTApyuSKJDG1f2okWOP8FE3YT3P6AhIPB3KhR8RxVFQdZtuZy3zd6azuO MUDwOw7eJwTrsMuQ2vLtNRt/0dhCdqQmjVi8rNg8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Musaab Khan , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.1 0998/1067] ksmbd: use opener credentials for FSCTL mutations Date: Tue, 21 Jul 2026 17:26:39 +0200 Message-ID: <20260721152446.886959293@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon [ Upstream commit c6394bcaf254c5baf9aff43376020be5db6d3316 ] SET_SPARSE, SET_ZERO_DATA and SET_COMPRESSION operate on an open SMB handle but call VFS xattr, fallocate or fileattr helpers with the current ksmbd worker credentials. Those helpers can revalidate inode permissions, ownership and LSM policy independently of the SMB handle access mask. Run each operation with the credentials captured in the target file when the handle was opened. Keep credential handling local to these single-file FSCTLs rather than applying session credentials to the complete IOCTL handler, which also contains handle-less and multi-handle operations. Cc: stable@vger.kernel.org Reported-by: Musaab Khan Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/smb2pdu.c | 3 +++ fs/smb/server/vfs.c | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -7739,6 +7739,7 @@ static inline int fsctl_set_sparse(struc if (fp->f_ci->m_fattr != old_fattr && test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) { + const struct cred *saved_cred; struct xattr_dos_attrib da; ret = ksmbd_vfs_get_dos_attrib_xattr(user_ns, @@ -7747,9 +7748,11 @@ static inline int fsctl_set_sparse(struc goto out; da.attr = le32_to_cpu(fp->f_ci->m_fattr); + saved_cred = override_creds(fp->filp->f_cred); ret = ksmbd_vfs_set_dos_attrib_xattr(user_ns, &fp->filp->f_path, &da, true); + revert_creds(saved_cred); if (ret) fp->f_ci->m_fattr = old_fattr; } --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -991,15 +991,21 @@ void ksmbd_vfs_set_fadvise(struct file * int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp, loff_t off, loff_t len) { + const struct cred *saved_cred; + int err; + smb_break_all_levII_oplock(work, fp, 1); + saved_cred = override_creds(fp->filp->f_cred); if (fp->f_ci->m_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE) - return vfs_fallocate(fp->filp, - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - off, len); - - return vfs_fallocate(fp->filp, - FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE, - off, len); + err = vfs_fallocate(fp->filp, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + off, len); + else + err = vfs_fallocate(fp->filp, + FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE, + off, len); + revert_creds(saved_cred); + return err; } int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,