diff --git a/kernel/cifsd/Makefile b/kernel/cifsd/Makefile index ac514b16be..b0eeca7729 100644 --- a/kernel/cifsd/Makefile +++ b/kernel/cifsd/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/cifsd-team/cifsd.git -PKG_SOURCE_DATE:=2019-07-17 -PKG_SOURCE_VERSION:=0c3049e84fc7737cedbcef3e1791a570871168cd -PKG_MIRROR_HASH:=2717cb1e3d28e7ff5ea69c3fa2a6ae182b70bcdf8680a41a0df2b190b072d04b +PKG_SOURCE_DATE:=2019-08-19 +PKG_SOURCE_VERSION:=b919acf32027cd5d7616726336305b47e24f02ab +PKG_MIRROR_HASH:=fd64b2cb78b8847f11ff79cbe06c3416bb0e67ca7433215d20c810fbfff6ee8f PKG_MAINTAINER:=Andy Walsh PKG_LICENSE:=GPL-2.0-or-later diff --git a/kernel/cifsd/patches/001-mips-vfree_vmalloc-fix.patch b/kernel/cifsd/patches/001-mips-vfree_vmalloc-fix.patch new file mode 100644 index 0000000000..6d00df0ea7 --- /dev/null +++ b/kernel/cifsd/patches/001-mips-vfree_vmalloc-fix.patch @@ -0,0 +1,33 @@ +--- a/vfs_cache.c ++++ b/vfs_cache.c +@@ -232,7 +232,7 @@ int __init cifsd_inode_hash_init(void) + size = bucketsize << inode_hash_shift; + + /* init master fp hash table */ +- inode_hashtable = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); ++ inode_hashtable = vmalloc(size); + if (!inode_hashtable) + return -ENOMEM; + +--- b/vfs.c ++++ b/vfs.c +@@ -17,6 +17,8 @@ + #include + #include + #include ++#include ++#include + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + #include +--- b/vfs_cache.c ++++ b/vfs_cache.c +@@ -5,6 +5,8 @@ + */ + + #include ++#include ++#include + + /* @FIXME */ + #include "glob.h" diff --git a/kernel/cifsd/patches/002-fix-xattr_list.patch b/kernel/cifsd/patches/002-fix-xattr_list.patch new file mode 100644 index 0000000000..af3680df6a --- /dev/null +++ b/kernel/cifsd/patches/002-fix-xattr_list.patch @@ -0,0 +1,89 @@ +=== + +SMB1/SMB2 don't know exactly how vfs layer allocates xattr list, +via kmalloc() or vmalloc(). Introduce cifsd_vfs_xattr_free() and +keep both xattr allocation and de-allocation in one place. + +Signed-off-by: Sergey Senozhatsky +--- + smb1pdu.c | 4 ++-- + smb2pdu.c | 6 ++---- + vfs.c | 6 ++++++ + vfs.h | 1 + + 4 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/smb1pdu.c b/smb1pdu.c +index 35599ef..8cb92cf 100644 +--- a/smb1pdu.c ++++ b/smb1pdu.c +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + + #include "glob.h" + #include "smb1pdu.h" +@@ -3844,8 +3845,7 @@ done: + rsp->ByteCount = cpu_to_le16(rsp_data_cnt + 5); + inc_rfc1001_len(&rsp->hdr, (10 * 2 + rsp->ByteCount)); + out: +- if (xattr_list) +- vfree(xattr_list); ++ cifsd_vfs_xattr_free(xattr_list); + return rc; + } + +diff --git a/smb2pdu.c b/smb2pdu.c +index 754258f..2727622 100644 +--- a/smb2pdu.c ++++ b/smb2pdu.c +@@ -3867,8 +3867,7 @@ done: + rsp->OutputBufferLength = cpu_to_le32(rsp_data_cnt); + inc_rfc1001_len(rsp_org, rsp_data_cnt); + out: +- if (xattr_list) +- vfree(xattr_list); ++ cifsd_vfs_xattr_free(xattr_list); + return rc; + } + +@@ -4151,8 +4150,7 @@ static void get_file_stream_info(struct cifsd_work *work, + /* last entry offset should be 0 */ + file_info->NextEntryOffset = 0; + out: +- if (xattr_list) +- vfree(xattr_list); ++ cifsd_vfs_xattr_free(xattr_list); + + rsp->OutputBufferLength = cpu_to_le32(nbytes); + inc_rfc1001_len(rsp_org, nbytes); +diff --git a/vfs.c b/vfs.c +index 556b1a5..6da6f8e 100644 +--- a/vfs.c ++++ b/vfs.c +@@ -1550,6 +1550,12 @@ int cifsd_vfs_remove_xattr(struct dentry *dentry, char *attr_name) + return vfs_removexattr(dentry, attr_name); + } + ++void cifsd_vfs_xattr_free(char *xattr) ++{ ++ if (xattr) ++ vfree(xattr); ++} ++ + int cifsd_vfs_unlink(struct dentry *dir, struct dentry *dentry) + { + int err = 0; +diff --git a/vfs.h b/vfs.h +index ee54daf..16b4f9e 100644 +--- a/vfs.h ++++ b/vfs.h +@@ -186,6 +186,7 @@ int cifsd_vfs_xattr_stream_name(char *stream_name, + + int cifsd_vfs_truncate_xattr(struct dentry *dentry, int wo_streams); + int cifsd_vfs_remove_xattr(struct dentry *dentry, char *attr_name); ++void cifsd_vfs_xattr_free(char *xattr); + + int cifsd_vfs_kern_path(char *name, unsigned int flags, struct path *path, + bool caseless); diff --git a/net/cifsd-tools/Makefile b/net/cifsd-tools/Makefile index 1a8eeb4ea7..591b1ee7f6 100644 --- a/net/cifsd-tools/Makefile +++ b/net/cifsd-tools/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cifsd-tools -PKG_RELEASE:=2 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/cifsd-team/cifsd-tools.git -PKG_SOURCE_DATE:=2019-07-05 -PKG_SOURCE_VERSION:=539fa21a8dd427a8ca2dc13c9a5a1c975be96d3c -PKG_MIRROR_HASH:=8c1b22d9926112a7e8ec94a3f731639a3789bef1aeb447f0bd7c41a1884e4dc5 +PKG_SOURCE_DATE:=2019-08-19 +PKG_SOURCE_VERSION:=bbeab27f0a1695f711fb84d9cd29a83f818ef90e +PKG_MIRROR_HASH:=f8bef545400aa8c0db6ba0fffdf0c0a2f201603503728f140df133aff3a39cbb PKG_MAINTAINER:=Andy Walsh PKG_LICENSE:=GPL-2.0-or-later diff --git a/net/cifsd-tools/files/cifsd.init b/net/cifsd-tools/files/cifsd.init index e2ea0c5008..c676159e0f 100644 --- a/net/cifsd-tools/files/cifsd.init +++ b/net/cifsd-tools/files/cifsd.init @@ -60,6 +60,9 @@ smb_add_share() local read_list local hide_dot_files local veto_files + local inherit_owner + local force_create_mode + local force_directory_mode config_get name $1 name config_get path $1 path @@ -76,6 +79,9 @@ smb_add_share() config_get read_list $1 read_list config_get_bool hide_dot_files $1 hide_dot_files 0 config_get veto_files $1 veto_files + config_get inherit_owner $1 inherit_owner + config_get force_create_mode $1 force_create_mode + config_get force_directory_mode $1 force_directory_mode [ -z "$name" ] || [ -z "$path" ] && return @@ -92,11 +98,14 @@ smb_add_share() [ -n "$create_mask" ] && printf "\tcreate mask = %s\n" "$create_mask" [ -n "$dir_mask" ] && printf "\tdirectory mask = %s\n" "$dir_mask" + [ -n "$force_create_mode" ] && printf "\tforce create mode = %s\n" "$force_create_mode" + [ -n "$force_directory_mode" ] && printf "\tforce directory mode = %s\n" "$force_directory_mode" [ -n "$browseable" ] && printf "\tbrowseable = %s\n" "$browseable" [ -n "$read_only" ] && printf "\tread only = %s\n" "$read_only" [ -n "$writeable" ] && printf "\twriteable = %s\n" "$writeable" [ -n "$guest_ok" ] && printf "\tguest ok = %s\n" "$guest_ok" + [ -n "$inherit_owner" ] && printf "\tinherit owner = %s\n" "$inherit_owner" [ -n "$write_list" ] && printf "\twrite list = %s\n" "$write_list" [ -n "$read_list" ] && printf "\tread list = %s\n" "$read_list" @@ -139,11 +148,6 @@ start_service() exit 1 fi - [ -f /tmp/cifsd.lock ] && rm /tmp/cifsd.lock - - # try remove again before start - [ -e /sys/module/cifsd ] && rmmod cifsd > /dev/null 2>&1 - modprobe cifsd 2> /dev/null if [ ! -e /sys/module/cifsd ]; then logger -t 'cifsd' "modprobe of cifsd module failed, can\'t start cifsd!" @@ -155,3 +159,25 @@ start_service() procd_set_param command /usr/sbin/cifsd --n procd_close_instance } + +stop_service() +{ + logger -t 'cifsd' "Stopping CIFSD userspace service." + killall cifsd > /dev/null 2>&1 + sleep 1 + [ -e /sys/class/cifsd-control/kill_server ] && echo hard > /sys/class/cifsd-control/kill_server + sleep 2 + [ -e /sys/module/cifsd ] && rmmod cifsd > /dev/null 2>&1 + # With open smb connections rmmod takes longer + if [ -e /sys/module/cifsd ]; then + sleep 5 + rmmod cifsd > /dev/null 2>&1 + fi + [ -f /tmp/cifsd.lock ] && rm /tmp/cifsd.lock +} + +reload_service() { + stop_service "$@" + sleep 1 + start_service "$@" +} diff --git a/net/cifsd-tools/files/smb.conf.help b/net/cifsd-tools/files/smb.conf.help index cd4e87fb36..a4c29d268f 100644 --- a/net/cifsd-tools/files/smb.conf.help +++ b/net/cifsd-tools/files/smb.conf.help @@ -135,7 +135,20 @@ ; Veto the Apple specific files that a NetAtalk server ; creates. ; veto files = /.AppleDouble/.bin/.AppleDesktop/Network Trash Folder/ -; +; - inherit owner +; The ownership for new files and directories should be controlled +; by the ownership of the parent directory. +; Valid options are yes or no. +; - inherit smack +; This parameter can be used to ensure that if smack label exist +; on parent directories. +; Valid options are yes or no. +; - force create mode +; This parameter specifies a set of UNIX mode bit permissions +; that will always be set on a file created by cifsd. +; - force directory mode +; This parameter specifies a set of UNIX mode bit permissions +; that will always be set on a directory created by cifsd. ; ; Rules to update this file: ; - Every [share] definition should start on new line @@ -148,13 +161,8 @@ ;****************************************************************************** [global] - server string = CIFSD on OpenWrt netbios name = CIFSD - map to guest = Bad User -[share] +[homes] comment = content server share - path = /mnt - guest ok = yes - create mask = 0777 - directory mask = 0777 + path = /tmp