FAILED: patch "[PATCH] ksmbd: use opener credentials for FSCTL mutations" failed to apply to 7.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 7.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.1.y
git checkout FETCH_HEAD
git cherry-pick -x c6394bcaf254c5baf9aff43376020be5db6d3316
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071403-easeful-customary-a1e2@gregkh' --subject-prefix 'PATCH 7.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c6394bcaf254c5baf9aff43376020be5db6d3316 Mon Sep 17 00:00:00 2001
From: Namjae Jeon <[email protected]>
Date: Sat, 13 Jun 2026 22:00:04 +0900
Subject: [PATCH] ksmbd: use opener credentials for FSCTL mutations
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.
fs/smb/server/smb2pdu.c +3 -0
@@ -8387,6 +8387,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,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(idmap,
@@ -8395,9 +8396,11 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, 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 (idmap, &fp->filp->f_path, &da, true); +revert_creds (saved_cred);if (ret) fp->f_ci->m_fattr = old_fattr; }
fs/smb/server/vfs.c +18 -8
@@ -918,15 +918,21 @@ void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option)int ksmbd_vfs_zero_data (struct ksmbd_work *work,struct ksmbd_file *fp,loff_t off,loff_t len) { -smb_break_all_levII_oplock (work, fp,1 ); -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); +const struct cred *saved_cred; +int err; -return vfs_fallocate (fp->filp, -FALLOC_FL_ZERO_RANGE |FALLOC_FL_KEEP_SIZE , - off, len); +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 ) + 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,
@@ -1935,6 +1941,7 @@ int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt)int ksmbd_vfs_set_compression (struct ksmbd_work *work,struct ksmbd_file *fp,u16 fmt) { +const struct cred *saved_cred =NULL ;struct file_kattr fa;struct dentry *dentry = fp->filp->f_path.dentry;struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);
@@ -1947,6 +1954,7 @@ int ksmbd_vfs_set_compression(struct ksmbd_work *work, struct ksmbd_file *fp, u1 goto out; } + saved_cred =override_creds (fp->filp->f_cred); rc =vfs_fileattr_get (dentry, &fa);if (rc) goto out;
@@ -2000,5 +2008,7 @@ int ksmbd_vfs_set_compression(struct ksmbd_work *work, struct ksmbd_file *fp, u1 } out: +if (saved_cred) +revert_creds (saved_cred);return rc; }
Sasha Levin
maintainerPATCH 1/2 smb: move compression definitions into common/fscc.h
From: ChenXiaoSong <[email protected]>
[ Upstream commit 9d357903ec9b0da60cccc4d311f99763ba0924a2 ]
These definitions will also be used by ksmbd, move them into common header file.
Stable-dep-of: c6394bcaf254 ("ksmbd: use opener credentials for FSCTL mutations")
--- fs/smb/client/smb1pdu.h | 5 ----- fs/smb/client/smb2pdu.h | 4 ---- fs/smb/common/fscc.h | 18 ++++++++++++++++++ fs/smb/server/smb2pdu.h | 3 --- 4 files changed, 18 insertions(+), 12 deletions(-)
fs/smb/client/smb1pdu.h +0 -5
@@ -1211,11 +1211,6 @@ typedef struct smb_com_transaction_compr_ioctl_req {__le16 compression_state;/* See below for valid flags */ }__packed TRANSACT_COMPR_IOCTL_REQ ; -/* compression state flags */ -#define COMPRESSION_FORMAT_NONE 0x0000 -#define COMPRESSION_FORMAT_DEFAULT 0x0001 -#define COMPRESSION_FORMAT_LZNT1 0x0002 - typedef struct smb_com_transaction_ioctl_rsp { struct smb_hdr hdr; /* wct = 19 */ __u8 Reserved[3];
fs/smb/client/smb2pdu.h +0 -4
@@ -195,10 +195,6 @@ struct network_resiliency_req {#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ -struct compress_ioctl { -__le16 CompressionState;/* See cifspdu.h for possible flag values */ -} __packed; -/* * Maximum number of iovs we need for an ioctl request. * [0] : struct smb2_ioctl_req
fs/smb/common/fscc.h +18 -0
@@ -100,6 +100,24 @@ struct duplicate_extents_to_file_ex {__le32 Reserved; } __packed; +/* +* compression state flags +* See MS-FSCC 2.3.18 +* MS-FSCC 2.3.67 +* MS-FSCC 2.4.9 +*/ +#define COMPRESSION_FORMAT_NONE 0x0000 +#define COMPRESSION_FORMAT_DEFAULT 0x0001 +#define COMPRESSION_FORMAT_LZNT1 0x0002 + +/* +* See MS-FSCC 2.3.18 +* MS-FSCC 2.3.67 +*/ +struct compress_ioctl { +__le16 CompressionState; +} __packed; +/* See MS-FSCC 2.3.20 */ struct fsctl_get_integrity_information_rsp {__le16 ChecksumAlgorithm;
fs/smb/server/smb2pdu.h +0 -3
@@ -230,9 +230,6 @@ struct smb2_file_mode_info {__le32 Mode; } __packed; -#define COMPRESSION_FORMAT_NONE 0x0000 -#define COMPRESSION_FORMAT_LZNT1 0x0002 -struct smb2_file_comp_info {__le64 CompressedFileSize;__le16 CompressionFormat;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 ksmbd: use opener credentials for FSCTL mutations
From: Namjae Jeon <[email protected]>
[ 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.
--- fs/smb/server/smb2pdu.c | 3 +++ fs/smb/server/vfs.c | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-)
fs/smb/server/smb2pdu.c +3 -0
@@ -8243,6 +8243,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,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(idmap,
@@ -8251,9 +8252,11 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, 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 (idmap, &fp->filp->f_path, &da, true); +revert_creds (saved_cred);if (ret) fp->f_ci->m_fattr = old_fattr; }
fs/smb/server/vfs.c +13 -7
@@ -919,15 +919,21 @@ void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option)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,
Signature · 1 line
2.53.0