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 inode_lock_nested(parent_path->dentry->d_inode, I_MUTEX_PARENT);
101 d = lookup_one_qstr_excl(&last, parent_path->dentry, 0);
105 if (d_is_negative(d)) {
111 path->mnt = mntget(parent_path->mnt);
113 if (test_share_config_flag(share_conf, KSMBD_SHARE_FLAG_CROSSMNT)) {
114 err = follow_down(path, 0);
125 inode_unlock(d_inode(parent_path->dentry));
126 path_put(parent_path);
131 void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
132 struct dentry *dentry, __le32 *daccess)
134 *daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
136 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_WRITE))
137 *daccess |= cpu_to_le32(WRITE_DAC | WRITE_OWNER | SYNCHRONIZE |
138 FILE_WRITE_DATA | FILE_APPEND_DATA |
139 FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES |
142 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_READ))
143 *daccess |= FILE_READ_DATA_LE | FILE_READ_EA_LE;
145 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_EXEC))
146 *daccess |= FILE_EXECUTE_LE;
148 if (!inode_permission(idmap, d_inode(dentry->d_parent), MAY_EXEC | MAY_WRITE))
149 *daccess |= FILE_DELETE_LE;
153 * ksmbd_vfs_create() - vfs helper for smb create file
155 * @name: file name that is relative to share
156 * @mode: file create mode
158 * Return: 0 on success, otherwise error
160 int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
163 struct dentry *dentry;
166 dentry = ksmbd_vfs_kern_path_create(work, name,
167 LOOKUP_NO_SYMLINKS, &path);
168 if (IS_ERR(dentry)) {
169 err = PTR_ERR(dentry);
171 pr_err("path create failed for %s, err %d\n",
176 err = mnt_want_write(path.mnt);
181 err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry),
184 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
187 pr_err("File(%s): creation failed (err:%d)\n", name, err);
189 mnt_drop_write(path.mnt);
192 done_path_create(&path, dentry);
197 * ksmbd_vfs_mkdir() - vfs helper for smb create directory
199 * @name: directory name that is relative to share
200 * @mode: directory create mode
202 * Return: 0 on success, otherwise error
204 int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
206 struct mnt_idmap *idmap;
208 struct dentry *dentry;
211 dentry = ksmbd_vfs_kern_path_create(work, name,
212 LOOKUP_NO_SYMLINKS | LOOKUP_DIRECTORY,
214 if (IS_ERR(dentry)) {
215 err = PTR_ERR(dentry);
217 ksmbd_debug(VFS, "path create failed for %s, err %d\n",
222 err = mnt_want_write(path.mnt);
226 idmap = mnt_idmap(path.mnt);
228 err = vfs_mkdir(idmap, d_inode(path.dentry), dentry, mode);
229 if (!err && d_unhashed(dentry)) {
232 d = lookup_one(idmap, dentry->d_name.name, dentry->d_parent,
238 if (unlikely(d_is_negative(d))) {
244 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry), d_inode(d));
249 mnt_drop_write(path.mnt);
251 done_path_create(&path, dentry);
253 pr_err("mkdir(%s): creation failed (err:%d)\n", name, err);
257 static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,
258 struct dentry *dentry, char *attr_name,
259 int attr_name_len, char **attr_value)
261 char *name, *xattr_list = NULL;
262 ssize_t value_len = -ENOENT, xattr_list_len;
264 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
265 if (xattr_list_len <= 0)
268 for (name = xattr_list; name - xattr_list < xattr_list_len;
269 name += strlen(name) + 1) {
270 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
271 if (strncasecmp(attr_name, name, attr_name_len))
274 value_len = ksmbd_vfs_getxattr(idmap,
279 pr_err("failed to get xattr in file\n");
288 static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
292 char *stream_buf = NULL;
294 ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n",
297 v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
298 fp->filp->f_path.dentry,
310 if (v_len - *pos < count)
311 count = v_len - *pos;
313 memcpy(buf, &stream_buf[*pos], count);
321 * check_lock_range() - vfs helper for smb byte range file locking
322 * @filp: the file to apply the lock to
323 * @start: lock start byte offset
324 * @end: lock end byte offset
325 * @type: byte range type read/write
327 * Return: 0 on success, otherwise error
329 static int check_lock_range(struct file *filp, loff_t start, loff_t end,
332 struct file_lock *flock;
333 struct file_lock_context *ctx = locks_inode_context(file_inode(filp));
336 if (!ctx || list_empty_careful(&ctx->flc_posix))
339 spin_lock(&ctx->flc_lock);
340 list_for_each_entry(flock, &ctx->flc_posix, fl_list) {
341 /* check conflict locks */
342 if (flock->fl_end >= start && end >= flock->fl_start) {
343 if (flock->fl_type == F_RDLCK) {
345 pr_err("not allow write by shared lock\n");
349 } else if (flock->fl_type == F_WRLCK) {
350 /* check owner in lock */
351 if (flock->fl_file != filp) {
353 pr_err("not allow rw access by exclusive lock from other opens\n");
360 spin_unlock(&ctx->flc_lock);
365 * ksmbd_vfs_read() - vfs helper for smb file read
367 * @fid: file id of open file
368 * @count: read byte count
370 * @rbuf: read data buffer
372 * Return: number of read bytes on success, otherwise error
374 int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
375 loff_t *pos, char *rbuf)
377 struct file *filp = fp->filp;
379 struct inode *inode = file_inode(filp);
381 if (S_ISDIR(inode->i_mode))
384 if (unlikely(count == 0))
387 if (work->conn->connection_type) {
388 if (!(fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
389 pr_err("no right to read(%pD)\n", fp->filp);
394 if (ksmbd_stream_fd(fp))
395 return ksmbd_vfs_stream_read(fp, rbuf, pos, count);
397 if (!work->tcon->posix_extensions) {
400 ret = check_lock_range(filp, *pos, *pos + count - 1, READ);
402 pr_err("unable to read due to lock\n");
407 nbytes = kernel_read(filp, rbuf, count, pos);
409 pr_err("smb read failed, err = %zd\n", nbytes);
417 static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
420 char *stream_buf = NULL, *wbuf;
421 struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
426 ksmbd_debug(VFS, "write stream data pos : %llu, count : %zd\n",
430 if (size > XATTR_SIZE_MAX) {
431 size = XATTR_SIZE_MAX;
432 count = (*pos + count) - XATTR_SIZE_MAX;
435 v_len = ksmbd_vfs_getcasexattr(idmap,
436 fp->filp->f_path.dentry,
441 pr_err("not found stream in xattr : %zd\n", v_len);
447 wbuf = kvzalloc(size, GFP_KERNEL);
454 memcpy(wbuf, stream_buf, v_len);
459 memcpy(&stream_buf[*pos], buf, count);
461 err = ksmbd_vfs_setxattr(idmap,
470 fp->filp->f_pos = *pos;
478 * ksmbd_vfs_write() - vfs helper for smb file write
480 * @fid: file id of open file
481 * @buf: buf containing data for writing
482 * @count: read byte count
484 * @sync: fsync after write
485 * @written: number of bytes written
487 * Return: 0 on success, otherwise error
489 int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
490 char *buf, size_t count, loff_t *pos, bool sync,
494 loff_t offset = *pos;
497 if (work->conn->connection_type) {
498 if (!(fp->daccess & FILE_WRITE_DATA_LE)) {
499 pr_err("no right to write(%pD)\n", fp->filp);
507 if (ksmbd_stream_fd(fp)) {
508 err = ksmbd_vfs_stream_write(fp, buf, pos, count);
514 if (!work->tcon->posix_extensions) {
515 err = check_lock_range(filp, *pos, *pos + count - 1, WRITE);
517 pr_err("unable to write due to lock\n");
523 /* Do we need to break any of a levelII oplock? */
524 smb_break_all_levII_oplock(work, fp, 1);
526 err = kernel_write(filp, buf, count, pos);
528 ksmbd_debug(VFS, "smb write failed, err = %d\n", err);
536 err = vfs_fsync_range(filp, offset, offset + *written, 0);
538 pr_err("fsync failed for filename = %pD, err = %d\n",
547 * ksmbd_vfs_getattr() - vfs helper for smb getattr
549 * @fid: file id of open file
550 * @attrs: inode attributes
552 * Return: 0 on success, otherwise error
554 int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat)
558 err = vfs_getattr(path, stat, STATX_BTIME, AT_STATX_SYNC_AS_STAT);
560 pr_err("getattr failed, err %d\n", err);
565 * ksmbd_vfs_fsync() - vfs helper for smb fsync
567 * @fid: file id of open file
569 * Return: 0 on success, otherwise error
571 int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)
573 struct ksmbd_file *fp;
576 fp = ksmbd_lookup_fd_slow(work, fid, p_id);
578 pr_err("failed to get filp for fid %llu\n", fid);
581 err = vfs_fsync(fp->filp, 0);
583 pr_err("smb fsync failed, err = %d\n", err);
584 ksmbd_fd_put(work, fp);
589 * ksmbd_vfs_remove_file() - vfs helper for smb rmdir or unlink
590 * @name: directory or file name that is relative to share
592 * Return: 0 on success, otherwise error
594 int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
596 struct mnt_idmap *idmap;
597 struct dentry *parent = path->dentry->d_parent;
600 if (ksmbd_override_fsids(work))
603 if (!d_inode(path->dentry)->i_nlink) {
608 err = mnt_want_write(path->mnt);
612 idmap = mnt_idmap(path->mnt);
613 if (S_ISDIR(d_inode(path->dentry)->i_mode)) {
614 err = vfs_rmdir(idmap, d_inode(parent), path->dentry);
615 if (err && err != -ENOTEMPTY)
616 ksmbd_debug(VFS, "rmdir failed, err %d\n", err);
618 err = vfs_unlink(idmap, d_inode(parent), path->dentry, NULL);
620 ksmbd_debug(VFS, "unlink failed, err %d\n", err);
622 mnt_drop_write(path->mnt);
625 ksmbd_revert_fsids(work);
630 * ksmbd_vfs_link() - vfs helper for creating smb hardlink
631 * @oldname: source file name
632 * @newname: hardlink name that is relative to share
634 * Return: 0 on success, otherwise error
636 int ksmbd_vfs_link(struct ksmbd_work *work, const char *oldname,
639 struct path oldpath, newpath;
640 struct dentry *dentry;
643 if (ksmbd_override_fsids(work))
646 err = kern_path(oldname, LOOKUP_NO_SYMLINKS, &oldpath);
648 pr_err("cannot get linux path for %s, err = %d\n",
653 dentry = ksmbd_vfs_kern_path_create(work, newname,
654 LOOKUP_NO_SYMLINKS | LOOKUP_REVAL,
656 if (IS_ERR(dentry)) {
657 err = PTR_ERR(dentry);
658 pr_err("path create err for %s, err %d\n", newname, err);
663 if (oldpath.mnt != newpath.mnt) {
664 pr_err("vfs_link failed err %d\n", err);
668 err = mnt_want_write(newpath.mnt);
672 err = vfs_link(oldpath.dentry, mnt_idmap(newpath.mnt),
673 d_inode(newpath.dentry),
676 ksmbd_debug(VFS, "vfs_link failed err %d\n", err);
677 mnt_drop_write(newpath.mnt);
680 done_path_create(&newpath, dentry);
684 ksmbd_revert_fsids(work);
688 int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
689 char *newname, int flags)
691 struct dentry *old_parent, *new_dentry, *trap;
692 struct dentry *old_child = old_path->dentry;
693 struct path new_path;
694 struct qstr new_last;
695 struct renamedata rd;
697 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
698 struct ksmbd_file *parent_fp;
700 int err, lookup_flags = LOOKUP_NO_SYMLINKS;
702 if (ksmbd_override_fsids(work))
705 to = getname_kernel(newname);
712 err = vfs_path_parent_lookup(to, lookup_flags | LOOKUP_BENEATH,
713 &new_path, &new_last, &new_type,
714 &share_conf->vfs_path);
718 if (old_path->mnt != new_path.mnt) {
723 err = mnt_want_write(old_path->mnt);
727 trap = lock_rename_child(old_child, new_path.dentry);
729 old_parent = dget(old_child->d_parent);
730 if (d_unhashed(old_child)) {
735 parent_fp = ksmbd_lookup_fd_inode(d_inode(old_child->d_parent));
737 if (parent_fp->daccess & FILE_DELETE_LE) {
738 pr_err("parent dir is opened with delete access\n");
740 ksmbd_fd_put(work, parent_fp);
743 ksmbd_fd_put(work, parent_fp);
746 new_dentry = lookup_one_qstr_excl(&new_last, new_path.dentry,
747 lookup_flags | LOOKUP_RENAME_TARGET);
748 if (IS_ERR(new_dentry)) {
749 err = PTR_ERR(new_dentry);
753 if (d_is_symlink(new_dentry)) {
758 if ((flags & RENAME_NOREPLACE) && d_is_positive(new_dentry)) {
763 if (old_child == trap) {
768 if (new_dentry == trap) {
773 rd.old_mnt_idmap = mnt_idmap(old_path->mnt),
774 rd.old_dir = d_inode(old_parent),
775 rd.old_dentry = old_child,
776 rd.new_mnt_idmap = mnt_idmap(new_path.mnt),
777 rd.new_dir = new_path.dentry->d_inode,
778 rd.new_dentry = new_dentry,
780 rd.delegated_inode = NULL,
781 err = vfs_rename(&rd);
783 ksmbd_debug(VFS, "vfs_rename failed err %d\n", err);
789 unlock_rename(old_parent, new_path.dentry);
790 mnt_drop_write(old_path->mnt);
794 if (retry_estale(err, lookup_flags)) {
795 lookup_flags |= LOOKUP_REVAL;
801 ksmbd_revert_fsids(work);
806 * ksmbd_vfs_truncate() - vfs helper for smb file truncate
808 * @fid: file id of old file
809 * @size: truncate to given size
811 * Return: 0 on success, otherwise error
813 int ksmbd_vfs_truncate(struct ksmbd_work *work,
814 struct ksmbd_file *fp, loff_t size)
821 /* Do we need to break any of a levelII oplock? */
822 smb_break_all_levII_oplock(work, fp, 1);
824 if (!work->tcon->posix_extensions) {
825 struct inode *inode = file_inode(filp);
827 if (size < inode->i_size) {
828 err = check_lock_range(filp, size,
829 inode->i_size - 1, WRITE);
831 err = check_lock_range(filp, inode->i_size,
836 pr_err("failed due to lock\n");
841 err = vfs_truncate(&filp->f_path, size);
843 pr_err("truncate failed, err %d\n", err);
848 * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes
849 * @dentry: dentry of file for listing xattrs
850 * @list: destination buffer
851 * @size: destination buffer length
853 * Return: xattr list length on success, otherwise error
855 ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
860 size = vfs_listxattr(dentry, NULL, 0);
864 vlist = kvzalloc(size, GFP_KERNEL);
869 size = vfs_listxattr(dentry, vlist, size);
871 ksmbd_debug(VFS, "listxattr failed\n");
879 static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
880 struct dentry *dentry, char *xattr_name)
882 return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
886 * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value
888 * @dentry: dentry of file for getting xattrs
889 * @xattr_name: name of xattr name to query
890 * @xattr_buf: destination buffer xattr value
892 * Return: read xattr value length on success, otherwise error
894 ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
895 struct dentry *dentry,
896 char *xattr_name, char **xattr_buf)
902 xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);
906 buf = kmalloc(xattr_len + 1, GFP_KERNEL);
910 xattr_len = vfs_getxattr(idmap, dentry, xattr_name,
911 (void *)buf, xattr_len);
920 * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
921 * @idmap: idmap of the relevant mount
922 * @dentry: dentry to set XATTR at
923 * @attr_name: xattr name for setxattr
924 * @attr_value: xattr value to set
925 * @attr_size: size of xattr value
926 * @flags: destination buffer length
928 * Return: 0 on success, otherwise error
930 int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
931 const struct path *path, const char *attr_name,
932 void *attr_value, size_t attr_size, int flags)
936 err = mnt_want_write(path->mnt);
940 err = vfs_setxattr(idmap,
947 ksmbd_debug(VFS, "setxattr failed, err %d\n", err);
948 mnt_drop_write(path->mnt);
953 * ksmbd_vfs_set_fadvise() - convert smb IO caching options to linux options
954 * @filp: file pointer for IO
955 * @options: smb IO options
957 void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option)
959 struct address_space *mapping;
961 mapping = filp->f_mapping;
963 if (!option || !mapping)
966 if (option & FILE_WRITE_THROUGH_LE) {
967 filp->f_flags |= O_SYNC;
968 } else if (option & FILE_SEQUENTIAL_ONLY_LE) {
969 filp->f_ra.ra_pages = inode_to_bdi(mapping->host)->ra_pages * 2;
970 spin_lock(&filp->f_lock);
971 filp->f_mode &= ~FMODE_RANDOM;
972 spin_unlock(&filp->f_lock);
973 } else if (option & FILE_RANDOM_ACCESS_LE) {
974 spin_lock(&filp->f_lock);
975 filp->f_mode |= FMODE_RANDOM;
976 spin_unlock(&filp->f_lock);
980 int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,
981 loff_t off, loff_t len)
983 smb_break_all_levII_oplock(work, fp, 1);
984 if (fp->f_ci->m_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE)
985 return vfs_fallocate(fp->filp,
986 FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
989 return vfs_fallocate(fp->filp,
990 FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE,
994 int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
995 struct file_allocated_range_buffer *ranges,
996 unsigned int in_count, unsigned int *out_count)
998 struct file *f = fp->filp;
999 struct inode *inode = file_inode(fp->filp);
1000 loff_t maxbytes = (u64)inode->i_sb->s_maxbytes, end;
1001 loff_t extent_start, extent_end;
1004 if (start > maxbytes)
1011 * Shrink request scope to what the fs can actually handle.
1013 if (length > maxbytes || (maxbytes - length) < start)
1014 length = maxbytes - start;
1016 if (start + length > inode->i_size)
1017 length = inode->i_size - start;
1020 end = start + length;
1021 while (start < end && *out_count < in_count) {
1022 extent_start = vfs_llseek(f, start, SEEK_DATA);
1023 if (extent_start < 0) {
1024 if (extent_start != -ENXIO)
1025 ret = (int)extent_start;
1029 if (extent_start >= end)
1032 extent_end = vfs_llseek(f, extent_start, SEEK_HOLE);
1033 if (extent_end < 0) {
1034 if (extent_end != -ENXIO)
1035 ret = (int)extent_end;
1037 } else if (extent_start >= extent_end) {
1041 ranges[*out_count].file_offset = cpu_to_le64(extent_start);
1042 ranges[(*out_count)++].length =
1043 cpu_to_le64(min(extent_end, end) - extent_start);
1051 int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
1052 const struct path *path, char *attr_name)
1056 err = mnt_want_write(path->mnt);
1060 err = vfs_removexattr(idmap, path->dentry, attr_name);
1061 mnt_drop_write(path->mnt);
1066 int ksmbd_vfs_unlink(struct file *filp)
1069 struct dentry *dir, *dentry = filp->f_path.dentry;
1070 struct mnt_idmap *idmap = file_mnt_idmap(filp);
1072 err = mnt_want_write(filp->f_path.mnt);
1076 dir = dget_parent(dentry);
1077 err = ksmbd_vfs_lock_parent(dir, dentry);
1082 if (S_ISDIR(d_inode(dentry)->i_mode))
1083 err = vfs_rmdir(idmap, d_inode(dir), dentry);
1085 err = vfs_unlink(idmap, d_inode(dir), dentry, NULL);
1088 inode_unlock(d_inode(dir));
1090 ksmbd_debug(VFS, "failed to delete, err %d\n", err);
1093 mnt_drop_write(filp->f_path.mnt);
1098 static bool __dir_empty(struct dir_context *ctx, const char *name, int namlen,
1099 loff_t offset, u64 ino, unsigned int d_type)
1101 struct ksmbd_readdir_data *buf;
1103 buf = container_of(ctx, struct ksmbd_readdir_data, ctx);
1104 buf->dirent_count++;
1106 return buf->dirent_count <= 2;
1110 * ksmbd_vfs_empty_dir() - check for empty directory
1111 * @fp: ksmbd file pointer
1113 * Return: true if directory empty, otherwise false
1115 int ksmbd_vfs_empty_dir(struct ksmbd_file *fp)
1118 struct ksmbd_readdir_data readdir_data;
1120 memset(&readdir_data, 0, sizeof(struct ksmbd_readdir_data));
1122 set_ctx_actor(&readdir_data.ctx, __dir_empty);
1123 readdir_data.dirent_count = 0;
1125 err = iterate_dir(fp->filp, &readdir_data.ctx);
1126 if (readdir_data.dirent_count > 2)
1133 static bool __caseless_lookup(struct dir_context *ctx, const char *name,
1134 int namlen, loff_t offset, u64 ino,
1135 unsigned int d_type)
1137 struct ksmbd_readdir_data *buf;
1140 buf = container_of(ctx, struct ksmbd_readdir_data, ctx);
1142 if (buf->used != namlen)
1144 if (IS_ENABLED(CONFIG_UNICODE) && buf->um) {
1145 const struct qstr q_buf = {.name = buf->private,
1147 const struct qstr q_name = {.name = name,
1150 cmp = utf8_strncasecmp(buf->um, &q_buf, &q_name);
1153 cmp = strncasecmp((char *)buf->private, name, namlen);
1155 memcpy((char *)buf->private, name, namlen);
1156 buf->dirent_count = 1;
1163 * ksmbd_vfs_lookup_in_dir() - lookup a file in a directory
1165 * @name: filename to lookup
1166 * @namelen: filename length
1168 * Return: 0 on success, otherwise error
1170 static int ksmbd_vfs_lookup_in_dir(const struct path *dir, char *name,
1171 size_t namelen, struct unicode_map *um)
1175 int flags = O_RDONLY | O_LARGEFILE;
1176 struct ksmbd_readdir_data readdir_data = {
1177 .ctx.actor = __caseless_lookup,
1184 dfilp = dentry_open(dir, flags, current_cred());
1186 return PTR_ERR(dfilp);
1188 ret = iterate_dir(dfilp, &readdir_data.ctx);
1189 if (readdir_data.dirent_count > 0)
1196 * ksmbd_vfs_kern_path_locked() - lookup a file and get path info
1197 * @name: file path that is relative to share
1198 * @flags: lookup flags
1199 * @path: if lookup succeed, return path info
1200 * @caseless: caseless filename lookup
1202 * Return: 0 on success, otherwise error
1204 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
1205 unsigned int flags, struct path *parent_path,
1206 struct path *path, bool caseless)
1208 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
1211 err = ksmbd_vfs_path_lookup_locked(share_conf, name, flags, parent_path,
1218 size_t path_len, remain_len;
1220 filepath = kstrdup(name, GFP_KERNEL);
1224 path_len = strlen(filepath);
1225 remain_len = path_len;
1227 *parent_path = share_conf->vfs_path;
1228 path_get(parent_path);
1230 while (d_can_lookup(parent_path->dentry)) {
1231 char *filename = filepath + path_len - remain_len;
1232 char *next = strchrnul(filename, '/');
1233 size_t filename_len = next - filename;
1234 bool is_last = !next[0];
1236 if (filename_len == 0)
1239 err = ksmbd_vfs_lookup_in_dir(parent_path, filename,
1247 err = vfs_path_lookup(share_conf->vfs_path.dentry,
1248 share_conf->vfs_path.mnt,
1256 path_put(parent_path);
1257 *parent_path = *path;
1260 remain_len -= filename_len + 1;
1265 path_put(parent_path);
1271 err = ksmbd_vfs_lock_parent(parent_path->dentry, path->dentry);
1274 path_put(parent_path);
1280 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
1286 struct dentry *dent;
1288 abs_name = convert_to_unix_name(work->tcon->share_conf, name);
1290 return ERR_PTR(-ENOMEM);
1292 dent = kern_path_create(AT_FDCWD, abs_name, path, flags);
1297 int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
1298 const struct path *path)
1300 char *name, *xattr_list = NULL;
1301 ssize_t xattr_list_len;
1304 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1305 if (xattr_list_len < 0) {
1307 } else if (!xattr_list_len) {
1308 ksmbd_debug(SMB, "empty xattr in the file\n");
1312 err = mnt_want_write(path->mnt);
1316 for (name = xattr_list; name - xattr_list < xattr_list_len;
1317 name += strlen(name) + 1) {
1318 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1320 if (!strncmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
1321 sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
1322 !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
1323 sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
1324 err = vfs_remove_acl(idmap, path->dentry, name);
1327 "remove acl xattr failed : %s\n", name);
1330 mnt_drop_write(path->mnt);
1337 int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
1339 char *name, *xattr_list = NULL;
1340 ssize_t xattr_list_len;
1343 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1344 if (xattr_list_len < 0) {
1346 } else if (!xattr_list_len) {
1347 ksmbd_debug(SMB, "empty xattr in the file\n");
1351 for (name = xattr_list; name - xattr_list < xattr_list_len;
1352 name += strlen(name) + 1) {
1353 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1355 if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
1356 err = ksmbd_vfs_remove_xattr(idmap, path, name);
1358 ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
1366 static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap,
1367 struct inode *inode,
1370 struct xattr_smb_acl *smb_acl = NULL;
1371 struct posix_acl *posix_acls;
1372 struct posix_acl_entry *pa_entry;
1373 struct xattr_acl_entry *xa_entry;
1376 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1379 posix_acls = get_inode_acl(inode, acl_type);
1380 if (IS_ERR_OR_NULL(posix_acls))
1383 smb_acl = kzalloc(sizeof(struct xattr_smb_acl) +
1384 sizeof(struct xattr_acl_entry) * posix_acls->a_count,
1389 smb_acl->count = posix_acls->a_count;
1390 pa_entry = posix_acls->a_entries;
1391 xa_entry = smb_acl->entries;
1392 for (i = 0; i < posix_acls->a_count; i++, pa_entry++, xa_entry++) {
1393 switch (pa_entry->e_tag) {
1395 xa_entry->type = SMB_ACL_USER;
1396 xa_entry->uid = posix_acl_uid_translate(idmap, pa_entry);
1399 xa_entry->type = SMB_ACL_USER_OBJ;
1402 xa_entry->type = SMB_ACL_GROUP;
1403 xa_entry->gid = posix_acl_gid_translate(idmap, pa_entry);
1406 xa_entry->type = SMB_ACL_GROUP_OBJ;
1409 xa_entry->type = SMB_ACL_OTHER;
1412 xa_entry->type = SMB_ACL_MASK;
1415 pr_err("unknown type : 0x%x\n", pa_entry->e_tag);
1419 if (pa_entry->e_perm & ACL_READ)
1420 xa_entry->perm |= SMB_ACL_READ;
1421 if (pa_entry->e_perm & ACL_WRITE)
1422 xa_entry->perm |= SMB_ACL_WRITE;
1423 if (pa_entry->e_perm & ACL_EXECUTE)
1424 xa_entry->perm |= SMB_ACL_EXECUTE;
1427 posix_acl_release(posix_acls);
1431 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
1432 struct mnt_idmap *idmap,
1433 const struct path *path,
1434 struct smb_ntsd *pntsd, int len)
1437 struct ndr sd_ndr = {0}, acl_ndr = {0};
1438 struct xattr_ntacl acl = {0};
1439 struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;
1440 struct dentry *dentry = path->dentry;
1441 struct inode *inode = d_inode(dentry);
1444 acl.hash_type = XATTR_SD_HASH_TYPE_SHA256;
1445 acl.current_time = ksmbd_UnixTimeToNT(current_time(inode));
1447 memcpy(acl.desc, "posix_acl", 9);
1451 cpu_to_le32(le32_to_cpu(pntsd->osidoffset) + NDR_NTSD_OFFSETOF);
1453 cpu_to_le32(le32_to_cpu(pntsd->gsidoffset) + NDR_NTSD_OFFSETOF);
1455 cpu_to_le32(le32_to_cpu(pntsd->dacloffset) + NDR_NTSD_OFFSETOF);
1457 acl.sd_buf = (char *)pntsd;
1460 rc = ksmbd_gen_sd_hash(conn, acl.sd_buf, acl.sd_size, acl.hash);
1462 pr_err("failed to generate hash for ndr acl\n");
1466 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1468 if (S_ISDIR(inode->i_mode))
1469 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1472 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode,
1473 smb_acl, def_smb_acl);
1475 pr_err("failed to encode ndr to posix acl\n");
1479 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset,
1480 acl.posix_acl_hash);
1482 pr_err("failed to generate hash for ndr acl\n");
1486 rc = ndr_encode_v4_ntacl(&sd_ndr, &acl);
1488 pr_err("failed to encode ndr to posix acl\n");
1492 rc = ksmbd_vfs_setxattr(idmap, path,
1493 XATTR_NAME_SD, sd_ndr.data,
1496 pr_err("Failed to store XATTR ntacl :%d\n", rc);
1500 kfree(acl_ndr.data);
1506 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
1507 struct mnt_idmap *idmap,
1508 struct dentry *dentry,
1509 struct smb_ntsd **pntsd)
1513 struct inode *inode = d_inode(dentry);
1514 struct ndr acl_ndr = {0};
1515 struct xattr_ntacl acl;
1516 struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;
1517 __u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};
1519 rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data);
1524 rc = ndr_decode_v4_ntacl(&n, &acl);
1528 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1530 if (S_ISDIR(inode->i_mode))
1531 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1534 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode, smb_acl,
1537 pr_err("failed to encode ndr to posix acl\n");
1541 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset, cmp_hash);
1543 pr_err("failed to generate hash for ndr acl\n");
1547 if (memcmp(cmp_hash, acl.posix_acl_hash, XATTR_SD_HASH_SIZE)) {
1548 pr_err("hash value diff\n");
1553 *pntsd = acl.sd_buf;
1554 if (acl.sd_size < sizeof(struct smb_ntsd)) {
1555 pr_err("sd size is invalid\n");
1559 (*pntsd)->osidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->osidoffset) -
1561 (*pntsd)->gsidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->gsidoffset) -
1563 (*pntsd)->dacloffset = cpu_to_le32(le32_to_cpu((*pntsd)->dacloffset) -
1568 kfree(acl_ndr.data);
1581 int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
1582 const struct path *path,
1583 struct xattr_dos_attrib *da)
1588 err = ndr_encode_dos_attr(&n, da);
1592 err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
1593 (void *)n.data, n.offset, 0);
1595 ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
1601 int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
1602 struct dentry *dentry,
1603 struct xattr_dos_attrib *da)
1608 err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,
1612 if (ndr_decode_dos_attr(&n, da))
1616 ksmbd_debug(SMB, "failed to load dos attribute in xattr\n");
1623 * ksmbd_vfs_init_kstat() - convert unix stat information to smb stat format
1624 * @p: destination buffer
1625 * @ksmbd_kstat: ksmbd kstat wrapper
1627 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
1629 struct file_directory_info *info = (struct file_directory_info *)(*p);
1630 struct kstat *kstat = ksmbd_kstat->kstat;
1633 info->FileIndex = 0;
1634 info->CreationTime = cpu_to_le64(ksmbd_kstat->create_time);
1635 time = ksmbd_UnixTimeToNT(kstat->atime);
1636 info->LastAccessTime = cpu_to_le64(time);
1637 time = ksmbd_UnixTimeToNT(kstat->mtime);
1638 info->LastWriteTime = cpu_to_le64(time);
1639 time = ksmbd_UnixTimeToNT(kstat->ctime);
1640 info->ChangeTime = cpu_to_le64(time);
1642 if (ksmbd_kstat->file_attributes & FILE_ATTRIBUTE_DIRECTORY_LE) {
1643 info->EndOfFile = 0;
1644 info->AllocationSize = 0;
1646 info->EndOfFile = cpu_to_le64(kstat->size);
1647 info->AllocationSize = cpu_to_le64(kstat->blocks << 9);
1649 info->ExtFileAttributes = ksmbd_kstat->file_attributes;
1654 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
1655 struct mnt_idmap *idmap,
1656 struct dentry *dentry,
1657 struct ksmbd_kstat *ksmbd_kstat)
1662 generic_fillattr(idmap, STATX_BASIC_STATS, d_inode(dentry),
1663 ksmbd_kstat->kstat);
1665 time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime);
1666 ksmbd_kstat->create_time = time;
1669 * set default value for the case that store dos attributes is not yes
1670 * or that acl is disable in server's filesystem and the config is yes.
1672 if (S_ISDIR(ksmbd_kstat->kstat->mode))
1673 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_DIRECTORY_LE;
1675 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_ARCHIVE_LE;
1677 if (test_share_config_flag(work->tcon->share_conf,
1678 KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {
1679 struct xattr_dos_attrib da;
1681 rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
1683 ksmbd_kstat->file_attributes = cpu_to_le32(da.attr);
1684 ksmbd_kstat->create_time = da.create_time;
1686 ksmbd_debug(VFS, "fail to load dos attribute.\n");
1693 ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
1694 struct dentry *dentry, char *attr_name,
1697 char *name, *xattr_list = NULL;
1698 ssize_t value_len = -ENOENT, xattr_list_len;
1700 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
1701 if (xattr_list_len <= 0)
1704 for (name = xattr_list; name - xattr_list < xattr_list_len;
1705 name += strlen(name) + 1) {
1706 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
1707 if (strncasecmp(attr_name, name, attr_name_len))
1710 value_len = ksmbd_vfs_xattr_len(idmap, dentry, name);
1719 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
1720 size_t *xattr_stream_name_size, int s_type)
1724 if (s_type == DIR_STREAM)
1725 type = ":$INDEX_ALLOCATION";
1729 buf = kasprintf(GFP_KERNEL, "%s%s%s",
1730 XATTR_NAME_STREAM, stream_name, type);
1734 *xattr_stream_name = buf;
1735 *xattr_stream_name_size = strlen(buf) + 1;
1740 int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
1741 struct ksmbd_file *src_fp,
1742 struct ksmbd_file *dst_fp,
1743 struct srv_copychunk *chunks,
1744 unsigned int chunk_count,
1745 unsigned int *chunk_count_written,
1746 unsigned int *chunk_size_written,
1747 loff_t *total_size_written)
1750 loff_t src_off, dst_off, src_file_size;
1754 *chunk_count_written = 0;
1755 *chunk_size_written = 0;
1756 *total_size_written = 0;
1758 if (!(src_fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
1759 pr_err("no right to read(%pD)\n", src_fp->filp);
1762 if (!(dst_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE))) {
1763 pr_err("no right to write(%pD)\n", dst_fp->filp);
1767 if (ksmbd_stream_fd(src_fp) || ksmbd_stream_fd(dst_fp))
1770 smb_break_all_levII_oplock(work, dst_fp, 1);
1772 if (!work->tcon->posix_extensions) {
1773 for (i = 0; i < chunk_count; i++) {
1774 src_off = le64_to_cpu(chunks[i].SourceOffset);
1775 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1776 len = le32_to_cpu(chunks[i].Length);
1778 if (check_lock_range(src_fp->filp, src_off,
1779 src_off + len - 1, READ))
1781 if (check_lock_range(dst_fp->filp, dst_off,
1782 dst_off + len - 1, WRITE))
1787 src_file_size = i_size_read(file_inode(src_fp->filp));
1789 for (i = 0; i < chunk_count; i++) {
1790 src_off = le64_to_cpu(chunks[i].SourceOffset);
1791 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1792 len = le32_to_cpu(chunks[i].Length);
1794 if (src_off + len > src_file_size)
1797 ret = vfs_copy_file_range(src_fp->filp, src_off,
1798 dst_fp->filp, dst_off, len, 0);
1799 if (ret == -EOPNOTSUPP || ret == -EXDEV)
1800 ret = vfs_copy_file_range(src_fp->filp, src_off,
1801 dst_fp->filp, dst_off, len,
1806 *chunk_count_written += 1;
1807 *total_size_written += ret;
1812 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock)
1814 wait_event(flock->fl_wait, !flock->fl_blocker);
1817 int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout)
1819 return wait_event_interruptible_timeout(flock->fl_wait,
1824 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
1826 locks_delete_block(flock);
1829 int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
1832 struct posix_acl_state acl_state;
1833 struct posix_acl *acls;
1834 struct dentry *dentry = path->dentry;
1835 struct inode *inode = d_inode(dentry);
1838 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1841 ksmbd_debug(SMB, "Set posix acls\n");
1842 rc = init_acl_state(&acl_state, 1);
1846 /* Set default owner group */
1847 acl_state.owner.allow = (inode->i_mode & 0700) >> 6;
1848 acl_state.group.allow = (inode->i_mode & 0070) >> 3;
1849 acl_state.other.allow = inode->i_mode & 0007;
1850 acl_state.users->aces[acl_state.users->n].uid = inode->i_uid;
1851 acl_state.users->aces[acl_state.users->n++].perms.allow =
1852 acl_state.owner.allow;
1853 acl_state.groups->aces[acl_state.groups->n].gid = inode->i_gid;
1854 acl_state.groups->aces[acl_state.groups->n++].perms.allow =
1855 acl_state.group.allow;
1856 acl_state.mask.allow = 0x07;
1858 acls = posix_acl_alloc(6, GFP_KERNEL);
1860 free_acl_state(&acl_state);
1863 posix_state_to_acl(&acl_state, acls->a_entries);
1865 rc = mnt_want_write(path->mnt);
1869 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1871 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1873 else if (S_ISDIR(inode->i_mode)) {
1874 posix_state_to_acl(&acl_state, acls->a_entries);
1875 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, acls);
1877 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1880 mnt_drop_write(path->mnt);
1883 free_acl_state(&acl_state);
1884 posix_acl_release(acls);
1888 int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
1889 struct path *path, struct inode *parent_inode)
1891 struct posix_acl *acls;
1892 struct posix_acl_entry *pace;
1893 struct dentry *dentry = path->dentry;
1894 struct inode *inode = d_inode(dentry);
1897 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1900 acls = get_inode_acl(parent_inode, ACL_TYPE_DEFAULT);
1901 if (IS_ERR_OR_NULL(acls))
1903 pace = acls->a_entries;
1905 for (i = 0; i < acls->a_count; i++, pace++) {
1906 if (pace->e_tag == ACL_MASK) {
1907 pace->e_perm = 0x07;
1912 rc = mnt_want_write(path->mnt);
1916 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1918 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1920 if (S_ISDIR(inode->i_mode)) {
1921 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT,
1924 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1927 mnt_drop_write(path->mnt);
1930 posix_acl_release(acls);