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,
69 struct filename *filename;
70 struct path *root_share_path = &share_conf->vfs_path;
72 struct path parent_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 = share_conf->vfs_path.mnt;
112 path_put(&parent_path);
118 inode_unlock(parent_path.dentry->d_inode);
119 path_put(&parent_path);
124 void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
125 struct dentry *dentry, __le32 *daccess)
127 *daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
129 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_WRITE))
130 *daccess |= cpu_to_le32(WRITE_DAC | WRITE_OWNER | SYNCHRONIZE |
131 FILE_WRITE_DATA | FILE_APPEND_DATA |
132 FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES |
135 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_READ))
136 *daccess |= FILE_READ_DATA_LE | FILE_READ_EA_LE;
138 if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_EXEC))
139 *daccess |= FILE_EXECUTE_LE;
141 if (!inode_permission(idmap, d_inode(dentry->d_parent), MAY_EXEC | MAY_WRITE))
142 *daccess |= FILE_DELETE_LE;
146 * ksmbd_vfs_create() - vfs helper for smb create file
148 * @name: file name that is relative to share
149 * @mode: file create mode
151 * Return: 0 on success, otherwise error
153 int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
156 struct dentry *dentry;
159 dentry = ksmbd_vfs_kern_path_create(work, name,
160 LOOKUP_NO_SYMLINKS, &path);
161 if (IS_ERR(dentry)) {
162 err = PTR_ERR(dentry);
164 pr_err("path create failed for %s, err %d\n",
169 err = mnt_want_write(path.mnt);
174 err = vfs_create(mnt_idmap(path.mnt), d_inode(path.dentry),
177 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
180 pr_err("File(%s): creation failed (err:%d)\n", name, err);
182 mnt_drop_write(path.mnt);
185 done_path_create(&path, dentry);
190 * ksmbd_vfs_mkdir() - vfs helper for smb create directory
192 * @name: directory name that is relative to share
193 * @mode: directory create mode
195 * Return: 0 on success, otherwise error
197 int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
199 struct mnt_idmap *idmap;
201 struct dentry *dentry;
204 dentry = ksmbd_vfs_kern_path_create(work, name,
205 LOOKUP_NO_SYMLINKS | LOOKUP_DIRECTORY,
207 if (IS_ERR(dentry)) {
208 err = PTR_ERR(dentry);
210 ksmbd_debug(VFS, "path create failed for %s, err %d\n",
215 err = mnt_want_write(path.mnt);
219 idmap = mnt_idmap(path.mnt);
221 err = vfs_mkdir(idmap, d_inode(path.dentry), dentry, mode);
222 if (!err && d_unhashed(dentry)) {
225 d = lookup_one(idmap, dentry->d_name.name, dentry->d_parent,
231 if (unlikely(d_is_negative(d))) {
237 ksmbd_vfs_inherit_owner(work, d_inode(path.dentry), d_inode(d));
242 mnt_drop_write(path.mnt);
244 done_path_create(&path, dentry);
246 pr_err("mkdir(%s): creation failed (err:%d)\n", name, err);
250 static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,
251 struct dentry *dentry, char *attr_name,
252 int attr_name_len, char **attr_value)
254 char *name, *xattr_list = NULL;
255 ssize_t value_len = -ENOENT, xattr_list_len;
257 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
258 if (xattr_list_len <= 0)
261 for (name = xattr_list; name - xattr_list < xattr_list_len;
262 name += strlen(name) + 1) {
263 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
264 if (strncasecmp(attr_name, name, attr_name_len))
267 value_len = ksmbd_vfs_getxattr(idmap,
272 pr_err("failed to get xattr in file\n");
281 static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
285 char *stream_buf = NULL;
287 ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n",
290 v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
291 fp->filp->f_path.dentry,
303 if (v_len - *pos < count)
304 count = v_len - *pos;
306 memcpy(buf, &stream_buf[*pos], count);
314 * check_lock_range() - vfs helper for smb byte range file locking
315 * @filp: the file to apply the lock to
316 * @start: lock start byte offset
317 * @end: lock end byte offset
318 * @type: byte range type read/write
320 * Return: 0 on success, otherwise error
322 static int check_lock_range(struct file *filp, loff_t start, loff_t end,
325 struct file_lock *flock;
326 struct file_lock_context *ctx = locks_inode_context(file_inode(filp));
329 if (!ctx || list_empty_careful(&ctx->flc_posix))
332 spin_lock(&ctx->flc_lock);
333 list_for_each_entry(flock, &ctx->flc_posix, fl_list) {
334 /* check conflict locks */
335 if (flock->fl_end >= start && end >= flock->fl_start) {
336 if (flock->fl_type == F_RDLCK) {
338 pr_err("not allow write by shared lock\n");
342 } else if (flock->fl_type == F_WRLCK) {
343 /* check owner in lock */
344 if (flock->fl_file != filp) {
346 pr_err("not allow rw access by exclusive lock from other opens\n");
353 spin_unlock(&ctx->flc_lock);
358 * ksmbd_vfs_read() - vfs helper for smb file read
360 * @fid: file id of open file
361 * @count: read byte count
364 * Return: number of read bytes on success, otherwise error
366 int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
369 struct file *filp = fp->filp;
371 char *rbuf = work->aux_payload_buf;
372 struct inode *inode = file_inode(filp);
374 if (S_ISDIR(inode->i_mode))
377 if (unlikely(count == 0))
380 if (work->conn->connection_type) {
381 if (!(fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
382 pr_err("no right to read(%pD)\n", fp->filp);
387 if (ksmbd_stream_fd(fp))
388 return ksmbd_vfs_stream_read(fp, rbuf, pos, count);
390 if (!work->tcon->posix_extensions) {
393 ret = check_lock_range(filp, *pos, *pos + count - 1, READ);
395 pr_err("unable to read due to lock\n");
400 nbytes = kernel_read(filp, rbuf, count, pos);
402 pr_err("smb read failed, err = %zd\n", nbytes);
410 static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
413 char *stream_buf = NULL, *wbuf;
414 struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
418 ksmbd_debug(VFS, "write stream data pos : %llu, count : %zd\n",
422 if (size > XATTR_SIZE_MAX) {
423 size = XATTR_SIZE_MAX;
424 count = (*pos + count) - XATTR_SIZE_MAX;
427 v_len = ksmbd_vfs_getcasexattr(idmap,
428 fp->filp->f_path.dentry,
432 if ((int)v_len < 0) {
433 pr_err("not found stream in xattr : %zd\n", v_len);
439 wbuf = kvzalloc(size, GFP_KERNEL);
446 memcpy(wbuf, stream_buf, v_len);
451 memcpy(&stream_buf[*pos], buf, count);
453 err = ksmbd_vfs_setxattr(idmap,
462 fp->filp->f_pos = *pos;
470 * ksmbd_vfs_write() - vfs helper for smb file write
472 * @fid: file id of open file
473 * @buf: buf containing data for writing
474 * @count: read byte count
476 * @sync: fsync after write
477 * @written: number of bytes written
479 * Return: 0 on success, otherwise error
481 int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
482 char *buf, size_t count, loff_t *pos, bool sync,
486 loff_t offset = *pos;
489 if (work->conn->connection_type) {
490 if (!(fp->daccess & FILE_WRITE_DATA_LE)) {
491 pr_err("no right to write(%pD)\n", fp->filp);
499 if (ksmbd_stream_fd(fp)) {
500 err = ksmbd_vfs_stream_write(fp, buf, pos, count);
506 if (!work->tcon->posix_extensions) {
507 err = check_lock_range(filp, *pos, *pos + count - 1, WRITE);
509 pr_err("unable to write due to lock\n");
515 /* Do we need to break any of a levelII oplock? */
516 smb_break_all_levII_oplock(work, fp, 1);
518 err = kernel_write(filp, buf, count, pos);
520 ksmbd_debug(VFS, "smb write failed, err = %d\n", err);
528 err = vfs_fsync_range(filp, offset, offset + *written, 0);
530 pr_err("fsync failed for filename = %pD, err = %d\n",
539 * ksmbd_vfs_getattr() - vfs helper for smb getattr
541 * @fid: file id of open file
542 * @attrs: inode attributes
544 * Return: 0 on success, otherwise error
546 int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat)
550 err = vfs_getattr(path, stat, STATX_BTIME, AT_STATX_SYNC_AS_STAT);
552 pr_err("getattr failed, err %d\n", err);
557 * ksmbd_vfs_fsync() - vfs helper for smb fsync
559 * @fid: file id of open file
561 * Return: 0 on success, otherwise error
563 int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)
565 struct ksmbd_file *fp;
568 fp = ksmbd_lookup_fd_slow(work, fid, p_id);
570 pr_err("failed to get filp for fid %llu\n", fid);
573 err = vfs_fsync(fp->filp, 0);
575 pr_err("smb fsync failed, err = %d\n", err);
576 ksmbd_fd_put(work, fp);
581 * ksmbd_vfs_remove_file() - vfs helper for smb rmdir or unlink
582 * @name: directory or file name that is relative to share
584 * Return: 0 on success, otherwise error
586 int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
588 struct mnt_idmap *idmap;
589 struct dentry *parent = path->dentry->d_parent;
592 if (ksmbd_override_fsids(work))
595 if (!d_inode(path->dentry)->i_nlink) {
600 err = mnt_want_write(path->mnt);
604 idmap = mnt_idmap(path->mnt);
605 if (S_ISDIR(d_inode(path->dentry)->i_mode)) {
606 err = vfs_rmdir(idmap, d_inode(parent), path->dentry);
607 if (err && err != -ENOTEMPTY)
608 ksmbd_debug(VFS, "rmdir failed, err %d\n", err);
610 err = vfs_unlink(idmap, d_inode(parent), path->dentry, NULL);
612 ksmbd_debug(VFS, "unlink failed, err %d\n", err);
614 mnt_drop_write(path->mnt);
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 = mnt_want_write(newpath.mnt);
664 err = vfs_link(oldpath.dentry, mnt_idmap(newpath.mnt),
665 d_inode(newpath.dentry),
668 ksmbd_debug(VFS, "vfs_link failed err %d\n", err);
669 mnt_drop_write(newpath.mnt);
672 done_path_create(&newpath, dentry);
676 ksmbd_revert_fsids(work);
680 int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
681 char *newname, int flags)
683 struct dentry *old_parent, *new_dentry, *trap;
684 struct dentry *old_child = old_path->dentry;
685 struct path new_path;
686 struct qstr new_last;
687 struct renamedata rd;
689 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
690 struct ksmbd_file *parent_fp;
692 int err, lookup_flags = LOOKUP_NO_SYMLINKS;
694 if (ksmbd_override_fsids(work))
697 to = getname_kernel(newname);
704 err = vfs_path_parent_lookup(to, lookup_flags | LOOKUP_BENEATH,
705 &new_path, &new_last, &new_type,
706 &share_conf->vfs_path);
710 if (old_path->mnt != new_path.mnt) {
715 err = mnt_want_write(old_path->mnt);
719 trap = lock_rename_child(old_child, new_path.dentry);
721 old_parent = dget(old_child->d_parent);
722 if (d_unhashed(old_child)) {
727 parent_fp = ksmbd_lookup_fd_inode(d_inode(old_child->d_parent));
729 if (parent_fp->daccess & FILE_DELETE_LE) {
730 pr_err("parent dir is opened with delete access\n");
732 ksmbd_fd_put(work, parent_fp);
735 ksmbd_fd_put(work, parent_fp);
738 new_dentry = lookup_one_qstr_excl(&new_last, new_path.dentry,
739 lookup_flags | LOOKUP_RENAME_TARGET);
740 if (IS_ERR(new_dentry)) {
741 err = PTR_ERR(new_dentry);
745 if (d_is_symlink(new_dentry)) {
750 if ((flags & RENAME_NOREPLACE) && d_is_positive(new_dentry)) {
755 if (old_child == trap) {
760 if (new_dentry == trap) {
765 rd.old_mnt_idmap = mnt_idmap(old_path->mnt),
766 rd.old_dir = d_inode(old_parent),
767 rd.old_dentry = old_child,
768 rd.new_mnt_idmap = mnt_idmap(new_path.mnt),
769 rd.new_dir = new_path.dentry->d_inode,
770 rd.new_dentry = new_dentry,
772 rd.delegated_inode = NULL,
773 err = vfs_rename(&rd);
775 ksmbd_debug(VFS, "vfs_rename failed err %d\n", err);
781 unlock_rename(old_parent, new_path.dentry);
782 mnt_drop_write(old_path->mnt);
786 if (retry_estale(err, lookup_flags)) {
787 lookup_flags |= LOOKUP_REVAL;
793 ksmbd_revert_fsids(work);
798 * ksmbd_vfs_truncate() - vfs helper for smb file truncate
800 * @fid: file id of old file
801 * @size: truncate to given size
803 * Return: 0 on success, otherwise error
805 int ksmbd_vfs_truncate(struct ksmbd_work *work,
806 struct ksmbd_file *fp, loff_t size)
813 /* Do we need to break any of a levelII oplock? */
814 smb_break_all_levII_oplock(work, fp, 1);
816 if (!work->tcon->posix_extensions) {
817 struct inode *inode = file_inode(filp);
819 if (size < inode->i_size) {
820 err = check_lock_range(filp, size,
821 inode->i_size - 1, WRITE);
823 err = check_lock_range(filp, inode->i_size,
828 pr_err("failed due to lock\n");
833 err = vfs_truncate(&filp->f_path, size);
835 pr_err("truncate failed, err %d\n", err);
840 * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes
841 * @dentry: dentry of file for listing xattrs
842 * @list: destination buffer
843 * @size: destination buffer length
845 * Return: xattr list length on success, otherwise error
847 ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
852 size = vfs_listxattr(dentry, NULL, 0);
856 vlist = kvzalloc(size, GFP_KERNEL);
861 size = vfs_listxattr(dentry, vlist, size);
863 ksmbd_debug(VFS, "listxattr failed\n");
871 static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
872 struct dentry *dentry, char *xattr_name)
874 return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
878 * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value
880 * @dentry: dentry of file for getting xattrs
881 * @xattr_name: name of xattr name to query
882 * @xattr_buf: destination buffer xattr value
884 * Return: read xattr value length on success, otherwise error
886 ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
887 struct dentry *dentry,
888 char *xattr_name, char **xattr_buf)
894 xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);
898 buf = kmalloc(xattr_len + 1, GFP_KERNEL);
902 xattr_len = vfs_getxattr(idmap, dentry, xattr_name,
903 (void *)buf, xattr_len);
912 * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
913 * @idmap: idmap of the relevant mount
914 * @dentry: dentry to set XATTR at
915 * @attr_name: xattr name for setxattr
916 * @attr_value: xattr value to set
917 * @attr_size: size of xattr value
918 * @flags: destination buffer length
920 * Return: 0 on success, otherwise error
922 int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
923 const struct path *path, const char *attr_name,
924 void *attr_value, size_t attr_size, int flags)
928 err = mnt_want_write(path->mnt);
932 err = vfs_setxattr(idmap,
939 ksmbd_debug(VFS, "setxattr failed, err %d\n", err);
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 *path,
1200 struct ksmbd_share_config *share_conf = work->tcon->share_conf;
1202 struct path parent_path;
1204 err = ksmbd_vfs_path_lookup_locked(share_conf, name, flags, 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 = ksmbd_vfs_lock_parent(parent_path.dentry, path->dentry);
1266 path_put(&parent_path);
1271 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
1277 struct dentry *dent;
1279 abs_name = convert_to_unix_name(work->tcon->share_conf, name);
1281 return ERR_PTR(-ENOMEM);
1283 dent = kern_path_create(AT_FDCWD, abs_name, path, flags);
1288 int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
1289 const struct path *path)
1291 char *name, *xattr_list = NULL;
1292 ssize_t xattr_list_len;
1295 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1296 if (xattr_list_len < 0) {
1298 } else if (!xattr_list_len) {
1299 ksmbd_debug(SMB, "empty xattr in the file\n");
1303 err = mnt_want_write(path->mnt);
1307 for (name = xattr_list; name - xattr_list < xattr_list_len;
1308 name += strlen(name) + 1) {
1309 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1311 if (!strncmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
1312 sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
1313 !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
1314 sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
1315 err = vfs_remove_acl(idmap, path->dentry, name);
1318 "remove acl xattr failed : %s\n", name);
1321 mnt_drop_write(path->mnt);
1328 int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
1330 char *name, *xattr_list = NULL;
1331 ssize_t xattr_list_len;
1334 xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
1335 if (xattr_list_len < 0) {
1337 } else if (!xattr_list_len) {
1338 ksmbd_debug(SMB, "empty xattr in the file\n");
1342 for (name = xattr_list; name - xattr_list < xattr_list_len;
1343 name += strlen(name) + 1) {
1344 ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
1346 if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
1347 err = ksmbd_vfs_remove_xattr(idmap, path, name);
1349 ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
1357 static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap,
1358 struct inode *inode,
1361 struct xattr_smb_acl *smb_acl = NULL;
1362 struct posix_acl *posix_acls;
1363 struct posix_acl_entry *pa_entry;
1364 struct xattr_acl_entry *xa_entry;
1367 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1370 posix_acls = get_inode_acl(inode, acl_type);
1371 if (IS_ERR_OR_NULL(posix_acls))
1374 smb_acl = kzalloc(sizeof(struct xattr_smb_acl) +
1375 sizeof(struct xattr_acl_entry) * posix_acls->a_count,
1380 smb_acl->count = posix_acls->a_count;
1381 pa_entry = posix_acls->a_entries;
1382 xa_entry = smb_acl->entries;
1383 for (i = 0; i < posix_acls->a_count; i++, pa_entry++, xa_entry++) {
1384 switch (pa_entry->e_tag) {
1386 xa_entry->type = SMB_ACL_USER;
1387 xa_entry->uid = posix_acl_uid_translate(idmap, pa_entry);
1390 xa_entry->type = SMB_ACL_USER_OBJ;
1393 xa_entry->type = SMB_ACL_GROUP;
1394 xa_entry->gid = posix_acl_gid_translate(idmap, pa_entry);
1397 xa_entry->type = SMB_ACL_GROUP_OBJ;
1400 xa_entry->type = SMB_ACL_OTHER;
1403 xa_entry->type = SMB_ACL_MASK;
1406 pr_err("unknown type : 0x%x\n", pa_entry->e_tag);
1410 if (pa_entry->e_perm & ACL_READ)
1411 xa_entry->perm |= SMB_ACL_READ;
1412 if (pa_entry->e_perm & ACL_WRITE)
1413 xa_entry->perm |= SMB_ACL_WRITE;
1414 if (pa_entry->e_perm & ACL_EXECUTE)
1415 xa_entry->perm |= SMB_ACL_EXECUTE;
1418 posix_acl_release(posix_acls);
1422 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
1423 struct mnt_idmap *idmap,
1424 const struct path *path,
1425 struct smb_ntsd *pntsd, int len)
1428 struct ndr sd_ndr = {0}, acl_ndr = {0};
1429 struct xattr_ntacl acl = {0};
1430 struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;
1431 struct dentry *dentry = path->dentry;
1432 struct inode *inode = d_inode(dentry);
1435 acl.hash_type = XATTR_SD_HASH_TYPE_SHA256;
1436 acl.current_time = ksmbd_UnixTimeToNT(current_time(inode));
1438 memcpy(acl.desc, "posix_acl", 9);
1442 cpu_to_le32(le32_to_cpu(pntsd->osidoffset) + NDR_NTSD_OFFSETOF);
1444 cpu_to_le32(le32_to_cpu(pntsd->gsidoffset) + NDR_NTSD_OFFSETOF);
1446 cpu_to_le32(le32_to_cpu(pntsd->dacloffset) + NDR_NTSD_OFFSETOF);
1448 acl.sd_buf = (char *)pntsd;
1451 rc = ksmbd_gen_sd_hash(conn, acl.sd_buf, acl.sd_size, acl.hash);
1453 pr_err("failed to generate hash for ndr acl\n");
1457 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1459 if (S_ISDIR(inode->i_mode))
1460 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1463 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode,
1464 smb_acl, def_smb_acl);
1466 pr_err("failed to encode ndr to posix acl\n");
1470 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset,
1471 acl.posix_acl_hash);
1473 pr_err("failed to generate hash for ndr acl\n");
1477 rc = ndr_encode_v4_ntacl(&sd_ndr, &acl);
1479 pr_err("failed to encode ndr to posix acl\n");
1483 rc = ksmbd_vfs_setxattr(idmap, path,
1484 XATTR_NAME_SD, sd_ndr.data,
1487 pr_err("Failed to store XATTR ntacl :%d\n", rc);
1491 kfree(acl_ndr.data);
1497 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
1498 struct mnt_idmap *idmap,
1499 struct dentry *dentry,
1500 struct smb_ntsd **pntsd)
1504 struct inode *inode = d_inode(dentry);
1505 struct ndr acl_ndr = {0};
1506 struct xattr_ntacl acl;
1507 struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;
1508 __u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};
1510 rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data);
1515 rc = ndr_decode_v4_ntacl(&n, &acl);
1519 smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1521 if (S_ISDIR(inode->i_mode))
1522 def_smb_acl = ksmbd_vfs_make_xattr_posix_acl(idmap, inode,
1525 rc = ndr_encode_posix_acl(&acl_ndr, idmap, inode, smb_acl,
1528 pr_err("failed to encode ndr to posix acl\n");
1532 rc = ksmbd_gen_sd_hash(conn, acl_ndr.data, acl_ndr.offset, cmp_hash);
1534 pr_err("failed to generate hash for ndr acl\n");
1538 if (memcmp(cmp_hash, acl.posix_acl_hash, XATTR_SD_HASH_SIZE)) {
1539 pr_err("hash value diff\n");
1544 *pntsd = acl.sd_buf;
1545 if (acl.sd_size < sizeof(struct smb_ntsd)) {
1546 pr_err("sd size is invalid\n");
1550 (*pntsd)->osidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->osidoffset) -
1552 (*pntsd)->gsidoffset = cpu_to_le32(le32_to_cpu((*pntsd)->gsidoffset) -
1554 (*pntsd)->dacloffset = cpu_to_le32(le32_to_cpu((*pntsd)->dacloffset) -
1559 kfree(acl_ndr.data);
1572 int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
1573 const struct path *path,
1574 struct xattr_dos_attrib *da)
1579 err = ndr_encode_dos_attr(&n, da);
1583 err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
1584 (void *)n.data, n.offset, 0);
1586 ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
1592 int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
1593 struct dentry *dentry,
1594 struct xattr_dos_attrib *da)
1599 err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,
1603 if (ndr_decode_dos_attr(&n, da))
1607 ksmbd_debug(SMB, "failed to load dos attribute in xattr\n");
1614 * ksmbd_vfs_init_kstat() - convert unix stat information to smb stat format
1615 * @p: destination buffer
1616 * @ksmbd_kstat: ksmbd kstat wrapper
1618 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
1620 struct file_directory_info *info = (struct file_directory_info *)(*p);
1621 struct kstat *kstat = ksmbd_kstat->kstat;
1624 info->FileIndex = 0;
1625 info->CreationTime = cpu_to_le64(ksmbd_kstat->create_time);
1626 time = ksmbd_UnixTimeToNT(kstat->atime);
1627 info->LastAccessTime = cpu_to_le64(time);
1628 time = ksmbd_UnixTimeToNT(kstat->mtime);
1629 info->LastWriteTime = cpu_to_le64(time);
1630 time = ksmbd_UnixTimeToNT(kstat->ctime);
1631 info->ChangeTime = cpu_to_le64(time);
1633 if (ksmbd_kstat->file_attributes & FILE_ATTRIBUTE_DIRECTORY_LE) {
1634 info->EndOfFile = 0;
1635 info->AllocationSize = 0;
1637 info->EndOfFile = cpu_to_le64(kstat->size);
1638 info->AllocationSize = cpu_to_le64(kstat->blocks << 9);
1640 info->ExtFileAttributes = ksmbd_kstat->file_attributes;
1645 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
1646 struct mnt_idmap *idmap,
1647 struct dentry *dentry,
1648 struct ksmbd_kstat *ksmbd_kstat)
1653 generic_fillattr(idmap, d_inode(dentry), ksmbd_kstat->kstat);
1655 time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime);
1656 ksmbd_kstat->create_time = time;
1659 * set default value for the case that store dos attributes is not yes
1660 * or that acl is disable in server's filesystem and the config is yes.
1662 if (S_ISDIR(ksmbd_kstat->kstat->mode))
1663 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_DIRECTORY_LE;
1665 ksmbd_kstat->file_attributes = FILE_ATTRIBUTE_ARCHIVE_LE;
1667 if (test_share_config_flag(work->tcon->share_conf,
1668 KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {
1669 struct xattr_dos_attrib da;
1671 rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
1673 ksmbd_kstat->file_attributes = cpu_to_le32(da.attr);
1674 ksmbd_kstat->create_time = da.create_time;
1676 ksmbd_debug(VFS, "fail to load dos attribute.\n");
1683 ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
1684 struct dentry *dentry, char *attr_name,
1687 char *name, *xattr_list = NULL;
1688 ssize_t value_len = -ENOENT, xattr_list_len;
1690 xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
1691 if (xattr_list_len <= 0)
1694 for (name = xattr_list; name - xattr_list < xattr_list_len;
1695 name += strlen(name) + 1) {
1696 ksmbd_debug(VFS, "%s, len %zd\n", name, strlen(name));
1697 if (strncasecmp(attr_name, name, attr_name_len))
1700 value_len = ksmbd_vfs_xattr_len(idmap, dentry, name);
1709 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
1710 size_t *xattr_stream_name_size, int s_type)
1714 if (s_type == DIR_STREAM)
1715 type = ":$INDEX_ALLOCATION";
1719 buf = kasprintf(GFP_KERNEL, "%s%s%s",
1720 XATTR_NAME_STREAM, stream_name, type);
1724 *xattr_stream_name = buf;
1725 *xattr_stream_name_size = strlen(buf) + 1;
1730 int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
1731 struct ksmbd_file *src_fp,
1732 struct ksmbd_file *dst_fp,
1733 struct srv_copychunk *chunks,
1734 unsigned int chunk_count,
1735 unsigned int *chunk_count_written,
1736 unsigned int *chunk_size_written,
1737 loff_t *total_size_written)
1740 loff_t src_off, dst_off, src_file_size;
1744 *chunk_count_written = 0;
1745 *chunk_size_written = 0;
1746 *total_size_written = 0;
1748 if (!(src_fp->daccess & (FILE_READ_DATA_LE | FILE_EXECUTE_LE))) {
1749 pr_err("no right to read(%pD)\n", src_fp->filp);
1752 if (!(dst_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE))) {
1753 pr_err("no right to write(%pD)\n", dst_fp->filp);
1757 if (ksmbd_stream_fd(src_fp) || ksmbd_stream_fd(dst_fp))
1760 smb_break_all_levII_oplock(work, dst_fp, 1);
1762 if (!work->tcon->posix_extensions) {
1763 for (i = 0; i < chunk_count; i++) {
1764 src_off = le64_to_cpu(chunks[i].SourceOffset);
1765 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1766 len = le32_to_cpu(chunks[i].Length);
1768 if (check_lock_range(src_fp->filp, src_off,
1769 src_off + len - 1, READ))
1771 if (check_lock_range(dst_fp->filp, dst_off,
1772 dst_off + len - 1, WRITE))
1777 src_file_size = i_size_read(file_inode(src_fp->filp));
1779 for (i = 0; i < chunk_count; i++) {
1780 src_off = le64_to_cpu(chunks[i].SourceOffset);
1781 dst_off = le64_to_cpu(chunks[i].TargetOffset);
1782 len = le32_to_cpu(chunks[i].Length);
1784 if (src_off + len > src_file_size)
1787 ret = vfs_copy_file_range(src_fp->filp, src_off,
1788 dst_fp->filp, dst_off, len, 0);
1789 if (ret == -EOPNOTSUPP || ret == -EXDEV)
1790 ret = vfs_copy_file_range(src_fp->filp, src_off,
1791 dst_fp->filp, dst_off, len,
1796 *chunk_count_written += 1;
1797 *total_size_written += ret;
1802 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock)
1804 wait_event(flock->fl_wait, !flock->fl_blocker);
1807 int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout)
1809 return wait_event_interruptible_timeout(flock->fl_wait,
1814 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
1816 locks_delete_block(flock);
1819 int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
1822 struct posix_acl_state acl_state;
1823 struct posix_acl *acls;
1824 struct dentry *dentry = path->dentry;
1825 struct inode *inode = d_inode(dentry);
1828 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1831 ksmbd_debug(SMB, "Set posix acls\n");
1832 rc = init_acl_state(&acl_state, 1);
1836 /* Set default owner group */
1837 acl_state.owner.allow = (inode->i_mode & 0700) >> 6;
1838 acl_state.group.allow = (inode->i_mode & 0070) >> 3;
1839 acl_state.other.allow = inode->i_mode & 0007;
1840 acl_state.users->aces[acl_state.users->n].uid = inode->i_uid;
1841 acl_state.users->aces[acl_state.users->n++].perms.allow =
1842 acl_state.owner.allow;
1843 acl_state.groups->aces[acl_state.groups->n].gid = inode->i_gid;
1844 acl_state.groups->aces[acl_state.groups->n++].perms.allow =
1845 acl_state.group.allow;
1846 acl_state.mask.allow = 0x07;
1848 acls = posix_acl_alloc(6, GFP_KERNEL);
1850 free_acl_state(&acl_state);
1853 posix_state_to_acl(&acl_state, acls->a_entries);
1855 rc = mnt_want_write(path->mnt);
1859 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1861 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1863 else if (S_ISDIR(inode->i_mode)) {
1864 posix_state_to_acl(&acl_state, acls->a_entries);
1865 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, acls);
1867 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1870 mnt_drop_write(path->mnt);
1873 free_acl_state(&acl_state);
1874 posix_acl_release(acls);
1878 int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
1879 struct path *path, struct inode *parent_inode)
1881 struct posix_acl *acls;
1882 struct posix_acl_entry *pace;
1883 struct dentry *dentry = path->dentry;
1884 struct inode *inode = d_inode(dentry);
1887 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
1890 acls = get_inode_acl(parent_inode, ACL_TYPE_DEFAULT);
1891 if (IS_ERR_OR_NULL(acls))
1893 pace = acls->a_entries;
1895 for (i = 0; i < acls->a_count; i++, pace++) {
1896 if (pace->e_tag == ACL_MASK) {
1897 pace->e_perm = 0x07;
1902 rc = mnt_want_write(path->mnt);
1906 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
1908 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
1910 if (S_ISDIR(inode->i_mode)) {
1911 rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT,
1914 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
1917 mnt_drop_write(path->mnt);
1920 posix_acl_release(acls);