Skip to content

Commit 620d133

Browse files
dhkts1gregkh
authored andcommitted
ksmbd: add permission checks for FSCTL_DUPLICATE_EXTENTS_TO_FILE
commit 388e413 upstream. The FSCTL_DUPLICATE_EXTENTS_TO_FILE arm of smb2_ioctl() overwrites the destination file's data via vfs_clone_file_range() with neither the share-level KSMBD_TREE_CONN_FLAG_WRITABLE check nor a per-handle fp->daccess check that the other write-bearing arms carry. A client can overwrite destination data on a read-only share, or from a handle opened with only FILE_WRITE_ATTRIBUTES (which still yields an FMODE_WRITE filp). FILE_WRITE_ATTRIBUTES-only destination handle overwrote the file's data via the clone. Add both checks, matching the FSCTL_SET_SPARSE permission fix; require FILE_WRITE_DATA since this writes data. Cc: stable@vger.kernel.org Signed-off-by: Gil Portnoy <dddhkts1@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aa37f5f commit 620d133

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8482,6 +8482,17 @@ int smb2_ioctl(struct ksmbd_work *work)
84828482
goto dup_ext_out;
84838483
}
84848484

8485+
if (!test_tree_conn_flag(work->tcon,
8486+
KSMBD_TREE_CONN_FLAG_WRITABLE)) {
8487+
ret = -EACCES;
8488+
goto dup_ext_out;
8489+
}
8490+
8491+
if (!(fp_out->daccess & FILE_WRITE_DATA_LE)) {
8492+
ret = -EACCES;
8493+
goto dup_ext_out;
8494+
}
8495+
84858496
src_off = le64_to_cpu(dup_ext->SourceFileOffset);
84868497
dst_off = le64_to_cpu(dup_ext->TargetFileOffset);
84878498
length = le64_to_cpu(dup_ext->ByteCount);

0 commit comments

Comments
 (0)