1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2016 Namjae Jeon <linkinjeon@kernel.org>
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
7 #include <linux/kernel.h>
9 #include <linux/filelock.h>
10 #include <linux/uaccess.h>
11 #include <linux/backing-dev.h>
12 #include <linux/writeback.h>
13 #include <linux/xattr.h>
14 #include <linux/falloc.h>
15 #include <linux/fsnotify.h>
16 #include <linux/dcache.h>
17 #include <linux/slab.h>
18 #include <linux/vmalloc.h>
19 #include <linux/sched/xacct.h>
20 #include <linux/crc32c.h>
21 #include <linux/namei.h>
25 #include "connection.h"
27 #include "vfs_cache.h"
33 #include "smb_common.h"
34 #include "mgmt/share_config.h"
35 #include "mgmt/tree_connect.h"
36 #include "mgmt/user_session.h"
37 #include "mgmt/user_config.h"
39 static void ksmbd_vfs_inherit_owner(struct ksmbd_work *work,
40 struct inode *parent_inode,
43 if (!test_share_config_flag(work->tcon->share_conf,
44 KSMBD_SHARE_FLAG_INHERIT_OWNER))
47 i_uid_write(inode, i_uid_read(parent_inode));
51 * ksmbd_vfs_lock_parent() - lock parent dentry if it is stable
53 int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child)
55 inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
56 if (child->d_parent != parent) {
57 inode_unlock(d_inode(parent));
64 static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,
65 char *pathname, unsigned int flags,
66 struct path *parent_path,
70 struct filename *filename;
71 struct path *root_share_path = &share_conf->vfs_path;
75 if (pathname[0] == '\0') {
76 pathname = share_conf->path;
77 root_share_path = NULL;
79 flags |= LOOKUP_BENEATH;
82 filename = getname_kernel(pathname);
84 return PTR_ERR(filename);
86 err = vfs_path_parent_lookup(filename, flags,
87 parent_path, &last, &type,
94 if (unlikely(type != LAST_NORM)) {
95 path_put(parent_path);
100 err = mnt_want_write(parent_path->mnt);
102 path_put(parent_path);
107 inode_lock_nested(parent_path->dentry->d_inode, I_MUTEX_PARENT);
108 d = lookup_one_qstr_excl(&last, parent_path->dentry, 0);
112 if (d_is_negative(d)) {
118 path->mnt = mntget(parent_path->mnt);
120 if (test_share_config_flag(share_conf, KSMBD_SHARE_FLAG_CROSSMNT)) {
121 err = follow_down(path, 0);
132 inode_unlock(d_inode(parent_path->dentry));
133 mnt_drop_write(parent_path->mnt);
134 path_put(parent_path);
139 void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
140 struct dentry *dentry, __le32 *daccess)
142 *daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
144 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_WRITE))
145 *daccess |= cpu_to_le32(WRITE_DAC | WRITE_OWNER | SYNCHRONIZE |
146 FILE_WRITE_DATA | FILE_APPEND_DATA |
147 FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES |
150 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_READ))
151 *daccess |= FILE_READ_DATA_LE | FILE_READ_EA_LE;
153 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_EXEC))
154 *daccess |= FILE_EXECUTE_LE;
156 if (!inode_permission(idmap, d_inode(dentry->d_parent), MAY_EXEC | MAY_WRITE))
157 *daccess |= FILE_DELETE_LE;
161 * ksmbd_vfs_create() - vfs helper for smb create file
163 * @name: file name that is relative to share
164 * @mode: file create mode
166 * Return: 0 on success, otherwise error
168 int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
171 struct dentry *dentry;
174 dentry = ksmbd_vfs_kern_path_create(work, name,
175 LOOKUP_NO_SYMLINKS, &path);
176 if (IS_ERR(dentry)) {
177 err = PTR_ERR(dentry);
179 pr_err("path create failed for %s, err %d\n",
185 err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry),
188 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
191 pr_err("File(%s): creation failed (err:%d)\n", name, err);
194 done_path_create(&path, dentry);
199 * ksmbd_vfs_mkdir() - vfs helper for smb create directory
201 * @name: directory name that is relative to share
202 * @mode: directory create mode
204 * Return: 0 on success, otherwise error
206 int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
208 struct mnt_idmap *idmap;
210 struct dentry *dentry;
213 dentry = ksmbd_vfs_kern_path_create(work, name,
214 LOOKUP_NO_SYMLINKS | LOOKUP_DIRECTORY,
216 if (IS_ERR(dentry)) {
217 err = PTR_ERR(dentry);
219 ksmbd_debug(VFS, "path create failed for %s, err %d\n",
224 idmap = mnt_idmap(path.mnt);
226 err = vfs_mkdir(idmap, d_inode(path.dentry), dentry, mode);
227 if (!err && d_unhashed(dentry)) {
230 d = lookup_one(idmap, dentry->d_name.name, dentry->d_parent,
236 if (unlikely(d_is_negative(d))) {
242 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry), d_inode(d));
247 done_path_create(&path, dentry);
249 pr_err("mkdir(%s): creation failed (err:%d)\n", name, err);
253 static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,
254 struct dentry *dentry, char *attr_name,
255 int attr_name_len, char **attr_value)
257 char *name, *xattr_list = NULL;
258 ssize_t value_len = -ENOENT, xattr_list_len;
260 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
261 if (xattr_list_len <= 0)
264 for (name = xattr_list; name - xattr_list < xattr_list_len;
265 name += strlen(name) + 1) {
266 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
267 if (strncasecmp(attr_name, name, attr_name_len))
270 value_len = ksmbd_vfs_getxattr(idmap,
275 pr_err("failed to get xattr in file\n");
284 static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
288 char *stream_buf = NULL;
290 ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n",
293 v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
294 fp->filp->f_path.dentry,
306 if (v_len - *pos < count)
307 count = v_len - *pos;
309 memcpy(buf, &stream_buf[*pos], count);
317 * check_lock_range() - vfs helper for smb byte range file locking
318 * @filp: the file to apply the lock to
319 * @start: lock start byte offset
320 * @end: lock end byte offset
321 * @type: byte range type read/write
323 * Return: 0 on success, otherwise error
325 static int check_lock_range(struct file *filp, loff_t start, loff_t end,
328 struct file_lock *flock;
329 struct file_lock_context *ctx = locks_inode_context(file_inode(filp));
332 if (!ctx || list_empty_careful(&ctx->flc_posix))
335 spin_lock(&ctx->flc_lock);
336 list_for_each_entry(flock, &ctx->flc_posix, fl_list) {
337 /* check conflict locks */
338 if (flock->fl_end >= start && end >= flock->fl_start) {
339 if (flock->fl_type == F_RDLCK) {
341 pr_err("not allow write by shared lock\n");
345 } else if (flock->fl_type == F_WRLCK) {
346 /* check owner in lock */
347 if (flock->fl_file != filp) {
349 pr_err("not allow rw access by exclusive lock from other opens\n");
356 spin_unlock(&ctx->flc_lock);
361 * ksmbd_vfs_read() - vfs helper for smb file read
363 * @fid: file id of open file
364 * @count: read byte count
366 * @rbuf: read data buffer
368 * Return: number of read bytes on success, otherwise error
370 int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
371 loff_t *pos, char *rbuf)
373 struct file *filp = fp->filp;
375 struct inode *inode = file_inode(filp);
377 if (S_ISDIR(inode->i_mode))
380 if (unlikely(count == 0))
383 if (work->conn->connection_type) {
384 if (!(fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
385 pr_err("no right to read(%pD)\n", fp->filp);
390 if (ksmbd_stream_fd(fp))
391 return ksmbd_vfs_stream_read(fp, rbuf, pos, count);
393 if (!work->tcon->posix_extensions) {
396 ret = check_lock_range(filp, *pos, *pos + count - 1, READ);
398 pr_err("unable to read due to lock\n");
403 nbytes = kernel_read(filp, rbuf, count, pos);
405 pr_err("smb read failed, err = %zd\n", nbytes);
413 static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
416 char *stream_buf = NULL, *wbuf;
417 struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
422 ksmbd_debug(VFS, "write stream data pos : %llu, count : %zd\n",
426 if (size > XATTR_SIZE_MAX) {
427 size = XATTR_SIZE_MAX;
428 count = (*pos + count) - XATTR_SIZE_MAX;
431 v_len = ksmbd_vfs_getcasexattr(idmap,
432 fp->filp->f_path.dentry,
437 pr_err("not found stream in xattr : %zd\n", v_len);
443 wbuf = kvzalloc(size, GFP_KERNEL);
450 memcpy(wbuf, stream_buf, v_len);
455 memcpy(&stream_buf[*pos], buf, count);
457 err = ksmbd_vfs_setxattr(idmap,
467 fp->filp->f_pos = *pos;
475 * ksmbd_vfs_write() - vfs helper for smb file write
477 * @fid: file id of open file
478 * @buf: buf containing data for writing
479 * @count: read byte count
481 * @sync: fsync after write
482 * @written: number of bytes written
484 * Return: 0 on success, otherwise error
486 int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
487 char *buf, size_t count, loff_t *pos, bool sync,
491 loff_t offset = *pos;
494 if (work->conn->connection_type) {
495 if (!(fp->daccess & FILE_WRITE_DATA_LE)) {
496 pr_err("no right to write(%pD)\n", fp->filp);
504 if (ksmbd_stream_fd(fp)) {
505 err = ksmbd_vfs_stream_write(fp, buf, pos, count);
511 if (!work->tcon->posix_extensions) {
512 err = check_lock_range(filp, *pos, *pos + count - 1, WRITE);
514 pr_err("unable to write due to lock\n");
520 /* Do we need to break any of a levelII oplock? */
521 smb_break_all_levII_oplock(work, fp, 1);
523 err = kernel_write(filp, buf, count, pos);
525 ksmbd_debug(VFS, "smb write failed, err = %d\n", err);
533 err = vfs_fsync_range(filp, offset, offset + *written, 0);
535 pr_err("fsync failed for filename = %pD, err = %d\n",
544 * ksmbd_vfs_getattr() - vfs helper for smb getattr
546 * @fid: file id of open file
547 * @attrs: inode attributes
549 * Return: 0 on success, otherwise error
551 int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat)
555 err = vfs_getattr(path, stat, STATX_BTIME, AT_STATX_SYNC_AS_STAT);
557 pr_err("getattr failed, err %d\n", err);
562 * ksmbd_vfs_fsync() - vfs helper for smb fsync
564 * @fid: file id of open file
566 * Return: 0 on success, otherwise error
568 int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)
570 struct ksmbd_file *fp;
573 fp = ksmbd_lookup_fd_slow(work, fid, p_id);
575 pr_err("failed to get filp for fid %llu\n", fid);
578 err = vfs_fsync(fp->filp, 0);
580 pr_err("smb fsync failed, err = %d\n", err);
581 ksmbd_fd_put(work, fp);
586 * ksmbd_vfs_remove_file() - vfs helper for smb rmdir or unlink
587 * @name: directory or file name that is relative to share
589 * Return: 0 on success, otherwise error
591 int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
593 struct mnt_idmap *idmap;
594 struct dentry *parent = path->dentry->d_parent;
597 if (ksmbd_override_fsids(work))
600 if (!d_inode(path->dentry)->i_nlink) {
605 idmap = mnt_idmap(path->mnt);
606 if (S_ISDIR(d_inode(path->dentry)->i_mode)) {
607 err = vfs_rmdir(idmap, d_inode(parent), path->dentry);
608 if (err && err != -ENOTEMPTY)
609 ksmbd_debug(VFS, "rmdir failed, err %d\n", err);
611 err = vfs_unlink(idmap, d_inode(parent), path->dentry, NULL);
613 ksmbd_debug(VFS, "unlink failed, err %d\n", err);
617 ksmbd_revert_fsids(work);
622 * ksmbd_vfs_link() - vfs helper for creating smb hardlink
623 * @oldname: source file name
624 * @newname: hardlink name that is relative to share
626 * Return: 0 on success, otherwise error
628 int ksmbd_vfs_link(struct ksmbd_work *work, const char *oldname,
631 struct path oldpath, newpath;
632 struct dentry *dentry;
635 if (ksmbd_override_fsids(work))
638 err = kern_path(oldname, LOOKUP_NO_SYMLINKS, &oldpath);
640 pr_err("cannot get linux path for %s, err = %d\n",
645 dentry = ksmbd_vfs_kern_path_create(work, newname,
646 LOOKUP_NO_SYMLINKS | LOOKUP_REVAL,
648 if (IS_ERR(dentry)) {
649 err = PTR_ERR(dentry);
650 pr_err("path create err for %s, err %d\n", newname, err);
655 if (oldpath.mnt != newpath.mnt) {
656 pr_err("vfs_link failed err %d\n", err);
660 err = vfs_link(oldpath.dentry, mnt_idmap(newpath.mnt),
661 d_inode(newpath.dentry),
664 ksmbd_debug(VFS, "vfs_link failed err %d\n", err);
667 done_path_create(&newpath, dentry);
671 ksmbd_revert_fsids(work);
675 int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
676 char *newname, int flags)
678 struct dentry *old_parent, *new_dentry, *trap;
679 struct dentry *old_child = old_path->dentry;
680 struct path new_path;
681 struct qstr new_last;
682 struct renamedata rd;
684 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
685 struct ksmbd_file *parent_fp;
687 int err, lookup_flags = LOOKUP_NO_SYMLINKS;
689 if (ksmbd_override_fsids(work))
692 to = getname_kernel(newname);
699 err = vfs_path_parent_lookup(to, lookup_flags | LOOKUP_BENEATH,
700 &new_path, &new_last, &new_type,
701 &share_conf->vfs_path);
705 if (old_path->mnt != new_path.mnt) {
710 err = mnt_want_write(old_path->mnt);
714 trap = lock_rename_child(old_child, new_path.dentry);
716 old_parent = dget(old_child->d_parent);
717 if (d_unhashed(old_child)) {
722 parent_fp = ksmbd_lookup_fd_inode(d_inode(old_child->d_parent));
724 if (parent_fp->daccess & FILE_DELETE_LE) {
725 pr_err("parent dir is opened with delete access\n");
727 ksmbd_fd_put(work, parent_fp);
730 ksmbd_fd_put(work, parent_fp);
733 new_dentry = lookup_one_qstr_excl(&new_last, new_path.dentry,
734 lookup_flags | LOOKUP_RENAME_TARGET);
735 if (IS_ERR(new_dentry)) {
736 err = PTR_ERR(new_dentry);
740 if (d_is_symlink(new_dentry)) {
745 if ((flags & RENAME_NOREPLACE) && d_is_positive(new_dentry)) {
750 if (old_child == trap) {
755 if (new_dentry == trap) {
760 rd.old_mnt_idmap = mnt_idmap(old_path->mnt),
761 rd.old_dir = d_inode(old_parent),
762 rd.old_dentry = old_child,
763 rd.new_mnt_idmap = mnt_idmap(new_path.mnt),
764 rd.new_dir = new_path.dentry->d_inode,
765 rd.new_dentry = new_dentry,
767 rd.delegated_inode = NULL,
768 err = vfs_rename(&rd);
770 ksmbd_debug(VFS, "vfs_rename failed err %d\n", err);
776 unlock_rename(old_parent, new_path.dentry);
777 mnt_drop_write(old_path->mnt);
781 if (retry_estale(err, lookup_flags)) {
782 lookup_flags |= LOOKUP_REVAL;
788 ksmbd_revert_fsids(work);
793 * ksmbd_vfs_truncate() - vfs helper for smb file truncate
795 * @fid: file id of old file
796 * @size: truncate to given size
798 * Return: 0 on success, otherwise error
800 int ksmbd_vfs_truncate(struct ksmbd_work *work,
801 struct ksmbd_file *fp, loff_t size)
808 /* Do we need to break any of a levelII oplock? */
809 smb_break_all_levII_oplock(work, fp, 1);
811 if (!work->tcon->posix_extensions) {
812 struct inode *inode = file_inode(filp);
814 if (size < inode->i_size) {
815 err = check_lock_range(filp, size,
816 inode->i_size - 1, WRITE);
818 err = check_lock_range(filp, inode->i_size,
823 pr_err("failed due to lock\n");
828 err = vfs_truncate(&filp->f_path, size);
830 pr_err("truncate failed, err %d\n", err);
835 * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes
836 * @dentry: dentry of file for listing xattrs
837 * @list: destination buffer
838 * @size: destination buffer length
840 * Return: xattr list length on success, otherwise error
842 ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
847 size = vfs_listxattr(dentry, NULL, 0);
851 vlist = kvzalloc(size, GFP_KERNEL);
856 size = vfs_listxattr(dentry, vlist, size);
858 ksmbd_debug(VFS, "listxattr failed\n");
866 static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
867 struct dentry *dentry, char *xattr_name)
869 return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
873 * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value
875 * @dentry: dentry of file for getting xattrs
876 * @xattr_name: name of xattr name to query
877 * @xattr_buf: destination buffer xattr value
879 * Return: read xattr value length on success, otherwise error
881 ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
882 struct dentry *dentry,
883 char *xattr_name, char **xattr_buf)
889 xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);
893 buf = kmalloc(xattr_len + 1, GFP_KERNEL);
897 xattr_len = vfs_getxattr(idmap, dentry, xattr_name,
898 (void *)buf, xattr_len);
907 * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
908 * @idmap: idmap of the relevant mount
909 * @dentry: dentry to set XATTR at
910 * @attr_name: xattr name for setxattr
911 * @attr_value: xattr value to set
912 * @attr_size: size of xattr value
913 * @flags: destination buffer length
914 * @get_write: get write access to a mount
916 * Return: 0 on success, otherwise error
918 int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
919 const struct path *path, const char *attr_name,
920 void *attr_value, size_t attr_size, int flags,
925 if (get_write == true) {
926 err = mnt_want_write(path->mnt);
931 err = vfs_setxattr(idmap,
938 ksmbd_debug(VFS, "setxattr failed, err %d\n", err);
939 if (get_write == true)
940 mnt_drop_write(path->mnt);
945 * ksmbd_vfs_set_fadvise() - convert smb IO caching options to linux options
946 * @filp: file pointer for IO
947 * @options: smb IO options
949 void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option)
951 struct address_space *mapping;
953 mapping = filp->f_mapping;
955 if (!option || !mapping)
958 if (option & FILE_WRITE_THROUGH_LE) {
959 filp->f_flags |= O_SYNC;
960 } else if (option & FILE_SEQUENTIAL_ONLY_LE) {
961 filp->f_ra.ra_pages = inode_to_bdi(mapping->host)->ra_pages * 2;
962 spin_lock(&filp->f_lock);
963 filp->f_mode &= ~FMODE_RANDOM;
964 spin_unlock(&filp->f_lock);
965 } else if (option & FILE_RANDOM_ACCESS_LE) {
966 spin_lock(&filp->f_lock);
967 filp->f_mode |= FMODE_RANDOM;
968 spin_unlock(&filp->f_lock);
972 int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,
973 loff_t off, loff_t len)
975 smb_break_all_levII_oplock(work, fp, 1);
976 if (fp->f_ci->m_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE)
977 return vfs_fallocate(fp->filp,
978 FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
981 return vfs_fallocate(fp->filp,
982 FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE,
986 int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
987 struct file_allocated_range_buffer *ranges,
988 unsigned int in_count, unsigned int *out_count)
990 struct file *f = fp->filp;
991 struct inode *inode = file_inode(fp->filp);
992 loff_t maxbytes = (u64)inode->i_sb->s_maxbytes, end;
993 loff_t extent_start, extent_end;
996 if (start > maxbytes)
1003 * Shrink request scope to what the fs can actually handle.
1005 if (length > maxbytes || (maxbytes - length) < start)
1006 length = maxbytes - start;
1008 if (start + length > inode->i_size)
1009 length = inode->i_size - start;
1012 end = start + length;
1013 while (start < end && *out_count < in_count) {
1014 extent_start = vfs_llseek(f, start, SEEK_DATA);
1015 if (extent_start < 0) {
1016 if (extent_start != -ENXIO)
1017 ret = (int)extent_start;
1021 if (extent_start >= end)
1024 extent_end = vfs_llseek(f, extent_start, SEEK_HOLE);
1025 if (extent_end < 0) {
1026 if (extent_end != -ENXIO)
1027 ret = (int)extent_end;
1029 } else if (extent_start >= extent_end) {
1033 ranges[*out_count].file_offset = cpu_to_le64(extent_start);
1034 ranges[(*out_count)++].length =
1035 cpu_to_le64(min(extent_end, end) - extent_start);
1043 int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
1044 const struct path *path, char *attr_name)
1048 err = mnt_want_write(path->mnt);
1052 err = vfs_removexattr(idmap, path->dentry, attr_name);
1053 mnt_drop_write(path->mnt);
1058 int ksmbd_vfs_unlink(struct file *filp)
1061 struct dentry *dir, *dentry = filp->f_path.dentry;
1062 struct mnt_idmap *idmap = file_mnt_idmap(filp);
1064 err = mnt_want_write(filp->f_path.mnt);
1068 dir = dget_parent(dentry);
1069 err = ksmbd_vfs_lock_parent(dir, dentry);
1074 if (S_ISDIR(d_inode(dentry)->i_mode))
1075 err = vfs_rmdir(idmap, d_inode(dir), dentry);
1077 err = vfs_unlink(idmap, d_inode(dir), dentry, NULL);
1080 inode_unlock(d_inode(dir));
1082 ksmbd_debug(VFS, "failed to delete, err %d\n", err);
1085 mnt_drop_write(filp->f_path.mnt);
1090 static bool __dir_empty(struct dir_context *ctx, const char *name, int namlen,
1091 loff_t offset, u64 ino, unsigned int d_type)
1093 struct ksmbd_readdir_data *buf;
1095 buf = container_of(ctx, struct ksmbd_readdir_data, ctx);
1096 buf->dirent_count++;
1098 return buf->dirent_count <= 2;
1102 * ksmbd_vfs_empty_dir() - check for empty directory
1103 * @fp: ksmbd file pointer
1105 * Return: true if directory empty, otherwise false
1107 int ksmbd_vfs_empty_dir(struct ksmbd_file *fp)
1110 struct ksmbd_readdir_data readdir_data;
1112 memset(&readdir_data, 0, sizeof(struct ksmbd_readdir_data));
1114 set_ctx_actor(&readdir_data.ctx, __dir_empty);
1115 readdir_data.dirent_count = 0;
1117 err = iterate_dir(fp->filp, &readdir_data.ctx);
1118 if (readdir_data.dirent_count > 2)
1125 static bool __caseless_lookup(struct dir_context *ctx, const char *name,
1126 int namlen, loff_t offset, u64 ino,
1127 unsigned int d_type)
1129 struct ksmbd_readdir_data *buf;
1132 buf = container_of(ctx, struct ksmbd_readdir_data, ctx);
1134 if (buf->used != namlen)
1136 if (IS_ENABLED(CONFIG_UNICODE) && buf->um) {
1137 const struct qstr q_buf = {.name = buf->private,
1139 const struct qstr q_name = {.name = name,
1142 cmp = utf8_strncasecmp(buf->um, &q_buf, &q_name);
1145 cmp = strncasecmp((char *)buf->private, name, namlen);
1147 memcpy((char *)buf->private, name, namlen);
1148 buf->dirent_count = 1;
1155 * ksmbd_vfs_lookup_in_dir() - lookup a file in a directory
1157 * @name: filename to lookup
1158 * @namelen: filename length
1160 * Return: 0 on success, otherwise error
1162 static int ksmbd_vfs_lookup_in_dir(const struct path *dir, char *name,
1163 size_t namelen, struct unicode_map *um)
1167 int flags = O_RDONLY | O_LARGEFILE;
1168 struct ksmbd_readdir_data readdir_data = {
1169 .ctx.actor = __caseless_lookup,
1176 dfilp = dentry_open(dir, flags, current_cred());
1178 return PTR_ERR(dfilp);
1180 ret = iterate_dir(dfilp, &readdir_data.ctx);
1181 if (readdir_data.dirent_count > 0)
1188 * ksmbd_vfs_kern_path_locked() - lookup a file and get path info
1189 * @name: file path that is relative to share
1190 * @flags: lookup flags
1191 * @path: if lookup succeed, return path info
1192 * @caseless: caseless filename lookup
1194 * Return: 0 on success, otherwise error
1196 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
1197 unsigned int flags, struct path *parent_path,
1198 struct path *path, bool caseless)
1200 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
1203 err = ksmbd_vfs_path_lookup_locked(share_conf, name, flags, parent_path,
1210 size_t path_len, remain_len;
1212 filepath = kstrdup(name, GFP_KERNEL);
1216 path_len = strlen(filepath);
1217 remain_len = path_len;
1219 *parent_path = share_conf->vfs_path;
1220 path_get(parent_path);
1222 while (d_can_lookup(parent_path->dentry)) {
1223 char *filename = filepath + path_len - remain_len;
1224 char *next = strchrnul(filename, '/');
1225 size_t filename_len = next - filename;
1226 bool is_last = !next[0];
1228 if (filename_len == 0)
1231 err = ksmbd_vfs_lookup_in_dir(parent_path, filename,
1239 err = vfs_path_lookup(share_conf->vfs_path.dentry,
1240 share_conf->vfs_path.mnt,
1248 path_put(parent_path);
1249 *parent_path = *path;
1252 remain_len -= filename_len + 1;
1257 path_put(parent_path);
1263 err = mnt_want_write(parent_path->mnt);
1266 path_put(parent_path);
1270 err = ksmbd_vfs_lock_parent(parent_path->dentry, path->dentry);
1273 path_put(parent_path);
1279 void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path)
1281 inode_unlock(d_inode(parent_path->dentry));
1282 mnt_drop_write(parent_path->mnt);
1284 path_put(parent_path);
1287 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
1293 struct dentry *dent;
1295 abs_name = convert_to_unix_name(work->tcon->share_conf, name);
1297 return ERR_PTR(-ENOMEM);
1299 dent = kern_path_create(AT_FDCWD, abs_name, path, flags);
1304 int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
1305 const struct path *path)
1307 char *name, *xattr_list = NULL;
1308 ssize_t xattr_list_len;
1311 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1312 if (xattr_list_len < 0) {
1314 } else if (!xattr_list_len) {
1315 ksmbd_debug(SMB, "empty xattr in the file\n");
1319 err = mnt_want_write(path->mnt);
1323 for (name = xattr_list; name - xattr_list < xattr_list_len;
1324 name += strlen(name) + 1) {
1325 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1327 if (!strncmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
1328 sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
1329 !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
1330 sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
1331 err = vfs_remove_acl(idmap, path->dentry, name);
1334 "remove acl xattr failed : %s\n", name);
1337 mnt_drop_write(path->mnt);
1344 int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
1346 char *name, *xattr_list = NULL;
1347 ssize_t xattr_list_len;
1350 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1351 if (xattr_list_len < 0) {
1353 } else if (!xattr_list_len) {
1354 ksmbd_debug(SMB, "empty xattr in the file\n");
1358 for (name = xattr_list; name - xattr_list < xattr_list_len;
1359 name += strlen(name) + 1) {
1360 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1362 if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
1363 err = ksmbd_vfs_remove_xattr(idmap, path, name);
1365 ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
1373 static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap,
1374 struct inode *inode,
1377 struct xattr_smb_acl *smb_acl = NULL;
1378 struct posix_acl *posix_acls;
1379 struct posix_acl_entry *pa_entry;
1380 struct xattr_acl_entry *xa_entry;
1383 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1386 posix_acls = get_inode_acl(inode, acl_type);
1387 if (IS_ERR_OR_NULL(posix_acls))
1390 smb_acl = kzalloc(sizeof(struct xattr_smb_acl) +
1391 sizeof(struct xattr_acl_entry) * posix_acls->a_count,
1396 smb_acl->count = posix_acls->a_count;
1397 pa_entry = posix_acls->a_entries;
1398 xa_entry = smb_acl->entries;
1399 for (i = 0; i < posix_acls->a_count; i++, pa_entry++, xa_entry++) {
1400 switch (pa_entry->e_tag) {
1402 xa_entry->type = SMB_ACL_USER;
1403 xa_entry->uid = posix_acl_uid_translate(idmap, pa_entry);
1406 xa_entry->type = SMB_ACL_USER_OBJ;
1409 xa_entry->type = SMB_ACL_GROUP;
1410 xa_entry->gid = posix_acl_gid_translate(idmap, pa_entry);
1413 xa_entry->type = SMB_ACL_GROUP_OBJ;
1416 xa_entry->type = SMB_ACL_OTHER;
1419 xa_entry->type = SMB_ACL_MASK;
1422 pr_err("unknown type : 0x%x\n", pa_entry->e_tag);
1426 if (pa_entry->e_perm & ACL_READ)
1427 xa_entry->perm |= SMB_ACL_READ;
1428 if (pa_entry->e_perm & ACL_WRITE)
1429 xa_entry->perm |= SMB_ACL_WRITE;
1430 if (pa_entry->e_perm & ACL_EXECUTE)
1431 xa_entry->perm |= SMB_ACL_EXECUTE;
1434 posix_acl_release(posix_acls);
1438 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
1439 struct mnt_idmap *idmap,
1440 const struct path *path,
1441 struct smb_ntsd *pntsd, int len,
1445 struct ndr sd_ndr = {0}, acl_ndr = {0};
1446 struct xattr_ntacl acl = {0};
1447 struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;
1448 struct dentry *dentry = path->dentry;
1449 struct inode *inode = d_inode(dentry);
1452 acl.hash_type = XATTR_SD_HASH_TYPE_SHA256;
1453 acl.current_time = ksmbd_UnixTimeToNT(current_time(inode));
1455 memcpy(acl.desc, "posix_acl", 9);
1459 cpu_to_le32(le32_to_cpu(pntsd->osidoffset) + NDR_NTSD_OFFSETOF);
1461 cpu_to_le32(le32_to_cpu(pntsd->gsidoffset) + NDR_NTSD_OFFSETOF);
1463 cpu_to_le32(le32_to_cpu(pntsd->dacloffset) + NDR_NTSD_OFFSETOF);
1465 acl.sd_buf = (char *)pntsd;
1468 rc = ksmbd_gen_sd_hash(conn, acl.sd_buf, acl.sd_size, acl.hash);
1470 pr_err("failed to generate hash for ndr acl\n");
1474 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1476 if (S_ISDIR(inode->i_mode))
1477 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1480 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode,
1481 smb_acl, def_smb_acl);
1483 pr_err("failed to encode ndr to posix acl\n");
1487 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset,
1488 acl.posix_acl_hash);
1490 pr_err("failed to generate hash for ndr acl\n");
1494 rc = ndr_encode_v4_ntacl(&sd_ndr, &acl);
1496 pr_err("failed to encode ndr to posix acl\n");
1500 rc = ksmbd_vfs_setxattr(idmap, path,
1501 XATTR_NAME_SD, sd_ndr.data,
1502 sd_ndr.offset, 0, get_write);
1504 pr_err("Failed to store XATTR ntacl :%d\n", rc);
1508 kfree(acl_ndr.data);
1514 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
1515 struct mnt_idmap *idmap,
1516 struct dentry *dentry,
1517 struct smb_ntsd **pntsd)
1521 struct inode *inode = d_inode(dentry);
1522 struct ndr acl_ndr = {0};
1523 struct xattr_ntacl acl;
1524 struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;
1525 __u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};
1527 rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data);
1532 rc = ndr_decode_v4_ntacl(&n, &acl);
1536 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1538 if (S_ISDIR(inode->i_mode))
1539 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1542 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode, smb_acl,
1545 pr_err("failed to encode ndr to posix acl\n");
1549 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset, cmp_hash);
1551 pr_err("failed to generate hash for ndr acl\n");
1555 if (memcmp(cmp_hash, acl.posix_acl_hash, XATTR_SD_HASH_SIZE)) {
1556 pr_err("hash value diff\n");
1561 *pntsd = acl.sd_buf;
1562 if (acl.sd_size < sizeof(struct smb_ntsd)) {
1563 pr_err("sd size is invalid\n");
1567 (*pntsd)->osidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->osidoffset) -
1569 (*pntsd)->gsidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->gsidoffset) -
1571 (*pntsd)->dacloffset = cpu_to_le32(le32_to_cpu((*pntsd)->dacloffset) -
1576 kfree(acl_ndr.data);
1589 int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
1590 const struct path *path,
1591 struct xattr_dos_attrib *da,
1597 err = ndr_encode_dos_attr(&n, da);
1601 err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
1602 (void *)n.data, n.offset, 0, get_write);
1604 ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
1610 int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
1611 struct dentry *dentry,
1612 struct xattr_dos_attrib *da)
1617 err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,
1621 if (ndr_decode_dos_attr(&n, da))
1625 ksmbd_debug(SMB, "failed to load dos attribute in xattr\n");
1632 * ksmbd_vfs_init_kstat() - convert unix stat information to smb stat format
1633 * @p: destination buffer
1634 * @ksmbd_kstat: ksmbd kstat wrapper
1636 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
1638 struct file_directory_info *info = (struct file_directory_info *)(*p);
1639 struct kstat *kstat = ksmbd_kstat->kstat;
1642 info->FileIndex = 0;
1643 info->CreationTime = cpu_to_le64(ksmbd_kstat->create_time);
1644 time = ksmbd_UnixTimeToNT(kstat->atime);
1645 info->LastAccessTime = cpu_to_le64(time);
1646 time = ksmbd_UnixTimeToNT(kstat->mtime);
1647 info->LastWriteTime = cpu_to_le64(time);
1648 time = ksmbd_UnixTimeToNT(kstat->ctime);
1649 info->ChangeTime = cpu_to_le64(time);
1651 if (ksmbd_kstat->file_attributes & FILE_ATTRIBUTE_DIRECTORY_LE) {
1652 info->EndOfFile = 0;
1653 info->AllocationSize = 0;
1655 info->EndOfFile = cpu_to_le64(kstat->size);
1656 info->AllocationSize = cpu_to_le64(kstat->blocks << 9);
1658 info->ExtFileAttributes = ksmbd_kstat->file_attributes;
1663 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
1664 struct mnt_idmap *idmap,
1665 struct dentry *dentry,
1666 struct ksmbd_kstat *ksmbd_kstat)
1671 generic_fillattr(idmap, STATX_BASIC_STATS, d_inode(dentry),
1672 ksmbd_kstat->kstat);
1674 time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime);
1675 ksmbd_kstat->create_time = time;
1678 * set default value for the case that store dos attributes is not yes
1679 * or that acl is disable in server's filesystem and the config is yes.
1681 if (S_ISDIR(ksmbd_kstat->kstat->mode))
1682 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_DIRECTORY_LE;
1684 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_ARCHIVE_LE;
1686 if (test_share_config_flag(work->tcon->share_conf,
1687 KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {
1688 struct xattr_dos_attrib da;
1690 rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
1692 ksmbd_kstat->file_attributes = cpu_to_le32(da.attr);
1693 ksmbd_kstat->create_time = da.create_time;
1695 ksmbd_debug(VFS, "fail to load dos attribute.\n");
1702 ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
1703 struct dentry *dentry, char *attr_name,
1706 char *name, *xattr_list = NULL;
1707 ssize_t value_len = -ENOENT, xattr_list_len;
1709 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
1710 if (xattr_list_len <= 0)
1713 for (name = xattr_list; name - xattr_list < xattr_list_len;
1714 name += strlen(name) + 1) {
1715 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
1716 if (strncasecmp(attr_name, name, attr_name_len))
1719 value_len = ksmbd_vfs_xattr_len(idmap, dentry, name);
1728 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
1729 size_t *xattr_stream_name_size, int s_type)
1733 if (s_type == DIR_STREAM)
1734 type = ":$INDEX_ALLOCATION";
1738 buf = kasprintf(GFP_KERNEL, "%s%s%s",
1739 XATTR_NAME_STREAM, stream_name, type);
1743 *xattr_stream_name = buf;
1744 *xattr_stream_name_size = strlen(buf) + 1;
1749 int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
1750 struct ksmbd_file *src_fp,
1751 struct ksmbd_file *dst_fp,
1752 struct srv_copychunk *chunks,
1753 unsigned int chunk_count,
1754 unsigned int *chunk_count_written,
1755 unsigned int *chunk_size_written,
1756 loff_t *total_size_written)
1759 loff_t src_off, dst_off, src_file_size;
1763 *chunk_count_written = 0;
1764 *chunk_size_written = 0;
1765 *total_size_written = 0;
1767 if (!(src_fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
1768 pr_err("no right to read(%pD)\n", src_fp->filp);
1771 if (!(dst_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE))) {
1772 pr_err("no right to write(%pD)\n", dst_fp->filp);
1776 if (ksmbd_stream_fd(src_fp) || ksmbd_stream_fd(dst_fp))
1779 smb_break_all_levII_oplock(work, dst_fp, 1);
1781 if (!work->tcon->posix_extensions) {
1782 for (i = 0; i < chunk_count; i++) {
1783 src_off = le64_to_cpu(chunks[i].SourceOffset);
1784 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1785 len = le32_to_cpu(chunks[i].Length);
1787 if (check_lock_range(src_fp->filp, src_off,
1788 src_off + len - 1, READ))
1790 if (check_lock_range(dst_fp->filp, dst_off,
1791 dst_off + len - 1, WRITE))
1796 src_file_size = i_size_read(file_inode(src_fp->filp));
1798 for (i = 0; i < chunk_count; i++) {
1799 src_off = le64_to_cpu(chunks[i].SourceOffset);
1800 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1801 len = le32_to_cpu(chunks[i].Length);
1803 if (src_off + len > src_file_size)
1806 ret = vfs_copy_file_range(src_fp->filp, src_off,
1807 dst_fp->filp, dst_off, len, 0);
1808 if (ret == -EOPNOTSUPP || ret == -EXDEV)
1809 ret = vfs_copy_file_range(src_fp->filp, src_off,
1810 dst_fp->filp, dst_off, len,
1815 *chunk_count_written += 1;
1816 *total_size_written += ret;
1821 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock)
1823 wait_event(flock->fl_wait, !flock->fl_blocker);
1826 int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout)
1828 return wait_event_interruptible_timeout(flock->fl_wait,
1833 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
1835 locks_delete_block(flock);
1838 int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
1841 struct posix_acl_state acl_state;
1842 struct posix_acl *acls;
1843 struct dentry *dentry = path->dentry;
1844 struct inode *inode = d_inode(dentry);
1847 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1850 ksmbd_debug(SMB, "Set posix acls\n");
1851 rc = init_acl_state(&acl_state, 1);
1855 /* Set default owner group */
1856 acl_state.owner.allow = (inode->i_mode & 0700) >> 6;
1857 acl_state.group.allow = (inode->i_mode & 0070) >> 3;
1858 acl_state.other.allow = inode->i_mode & 0007;
1859 acl_state.users->aces[acl_state.users->n].uid = inode->i_uid;
1860 acl_state.users->aces[acl_state.users->n++].perms.allow =
1861 acl_state.owner.allow;
1862 acl_state.groups->aces[acl_state.groups->n].gid = inode->i_gid;
1863 acl_state.groups->aces[acl_state.groups->n++].perms.allow =
1864 acl_state.group.allow;
1865 acl_state.mask.allow = 0x07;
1867 acls = posix_acl_alloc(6, GFP_KERNEL);
1869 free_acl_state(&acl_state);
1872 posix_state_to_acl(&acl_state, acls->a_entries);
1874 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1876 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1878 else if (S_ISDIR(inode->i_mode)) {
1879 posix_state_to_acl(&acl_state, acls->a_entries);
1880 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, acls);
1882 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1886 free_acl_state(&acl_state);
1887 posix_acl_release(acls);
1891 int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
1892 struct path *path, struct inode *parent_inode)
1894 struct posix_acl *acls;
1895 struct posix_acl_entry *pace;
1896 struct dentry *dentry = path->dentry;
1897 struct inode *inode = d_inode(dentry);
1900 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1903 acls = get_inode_acl(parent_inode, ACL_TYPE_DEFAULT);
1904 if (IS_ERR_OR_NULL(acls))
1906 pace = acls->a_entries;
1908 for (i = 0; i < acls->a_count; i++, pace++) {
1909 if (pace->e_tag == ACL_MASK) {
1910 pace->e_perm = 0x07;
1915 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1917 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1919 if (S_ISDIR(inode->i_mode)) {
1920 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT,
1923 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1927 posix_acl_release(acls);