Commit Graph

1013663 Commits

Author SHA1 Message Date
Namjae Jeon
fba08fa005 cifsd: use d_inode()
Use d_inode().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:44 -05:00
Marios Makassikis
e6b1059ffa cifsd: Fix potential null-ptr-deref in smb2_open()
Fix potential null-ptr-deref in smb2_open().

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:43 -05:00
Namjae Jeon
5626518eca cifsd: move nt time functions to misc.c
Move nt time functions in netmisc.c to misc.c to remove netmisc.c file.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:43 -05:00
Namjae Jeon
2efec2dee8 cifsd: remove unused nterr.c file
Remove unused nterr.c file.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:42 -05:00
Namjae Jeon
7e8094a73e cifsd: remove unused smberr.h
smberr.h is a leftover of SMB1. This patch remove unused smberr.h.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:42 -05:00
Marios Makassikis
915f570a97 cifsd: Remove smb2_put_name()
smb2_put_name() is called twice, and both call sites do the IS_ERR() check
before.

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:41 -05:00
Hyunchul Lee
24b626967d cifsd: fix reference count decrement of unclaimed file in __ksmbd_lookup_fd
__ksmbd_lookup_fd could decrement the reference count of
unclaimed ksmbd_file to 0 but not release this ksmbd_file.

ksmbd_file cannot be unclaimed except ksmbd_close_inode_fds(),
because ksmbd_file is only removed from the m_fp_list list
after the reference count of ksmbd_file becomes 0. And if the
count is 0, __ksmbd_lookup_fd does not use ksmbd_file found
from idr due to atomic_inc_not_zero.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:41 -05:00
Hyunchul Lee
3c20378325 cifsd: re-implement ksmbd_vfs_kern_path
re-implement ksmbd_vfs_kern_path() to change
recursion to iteration.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:40 -05:00
Namjae Jeon
7c3d3e99ca cifsd: get parent dentry from child in ksmbd_vfs_remove_file()
To remove the file, We have parsed full pathname to divide parent path and
filename. It is a better way to get parent dentry from child dentry that
obtained by lookup with given pathname.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:40 -05:00
Namjae Jeon
ff1d572725 cifsd: add the check if parent is stable by unexpected rename
This patch add the check if parent is stable by unexpected rename.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:39 -05:00
Namjae Jeon
d40012a83f cifsd: declare ida statically
Matthew pointed out that embedding struct ida into the struct is
better than having a pointer to it.
This patch initialise it statically using DEFINE_IDA() or ida_init()
and remove ksmbd_ida_alloc/free().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:39 -05:00
Tian Tao
1920bb1f80 cifsd: remove unused including <linux/version.h>
Remove including <linux/version.h> that don't need it.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:38 -05:00
Zhang Xiaoxu
0ab777453f cifsd: Select SG_POOL for SMB_SERVER_SMBDIRECT
hulk-robot following build error:
 fs/cifsd/transport_rdma.c: In function 'read_write_done':
 fs/cifsd/transport_rdma.c:1297:2: error: implicit declaration of
function 'sg_free_table_chained'
[-Werror=implicit-function-declaration]
  1297 |  sg_free_table_chained(&msg->sgt, SG_CHUNK_SIZE);

The reason is CONFIG_SG_POOL is not enabled in the config, to
avoid such failure, select SG_POOL in Kconfig for SMB_SERVER_SMBDIRECT.

Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:38 -05:00
Namjae Jeon
4030b27836 cifsd: prevent a integer overflow in wm_alloc()
Dan Carpenter pointed out that there there is a possibility of
integer overflow. This patch prevent a integer overflow in wm_alloc().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:37 -05:00
Mauro Carvalho Chehab
9cca7516f4 doc: cifsd: change the reference to configuration.txt
added documentation for cifsd. There, it points to a file
named:
        Documentation/configuration.txt

This confuses Kernel scripts, as they think that this is a
document within the Kernel tree, instead of a file from
some other place.

Replace it by an hyperlink to the ksmbd-tools tree, in order
to avoid false-positives.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:37 -05:00
Namjae Jeon
79f6b11a10 cifsd: remove wrappers of kvmalloc/kvfree
Do directly call kvmalloc/kvfree().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:36 -05:00
kernel test robot
86f5297846 cifsd: fix memdup.cocci warnings
fs/cifsd/smb2pdu.c:1177:27-34: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:36 -05:00
Muhammad Usama Anjum
822bc8ea51 cifsd: use kfree to free memory allocated by kmalloc or kzalloc
kfree should be used to free memory allocated by kmalloc or kzalloc to
avoid any overhead and for maintaining consistency.

Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:36 -05:00
Muhammad Usama Anjum
c250e8f556 cifsd: fix memory leak when loop ends
Memory is being allocated and if veto_list is zero, the loop breaks
without cleaning up the allocated memory. In this patch, the length
check has been moved before allocation. If loop breaks, the memory isn't
allocated in the first place. Thus the memory is being protected from
leaking.

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1503590 ("Resource leaks")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:35 -05:00
Gibeom Kim
5da64d8784 cifsd: remove stale prototype and variables
Remove unused function prototype and variables.

Signed-off-by: Gibeom Kim <gibeomii.kim@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:35 -05:00
Namjae Jeon
02b68b2065 cifsd: use xarray instead of linked list for tree connect list
Matthew suggest to change linked list of tree connect list to xarray.
It will be tree connect lookup in O(log(n)) time instead of O(n) time.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:34 -05:00
Hyunchul Lee
8044ee8e64 cifsd: remove useless error handling in ksmbd_vfs_read
dentry->d_inode never happen to be NULL if we hold the dentry.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:34 -05:00
Hyunchul Lee
d2f72ed8fa cifsd: use file_inode() instead of d_inode()
use file_inode() to get layerd filesystems right.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:33 -05:00
Hyunchul Lee
1637023594 cifsd: handle unhashed dentry in ksmbd_vfs_mkdir
vfs_mkdir could return the dentry left unhashed negative on success.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:33 -05:00
Hyunchul Lee
96a34377dc cifsd: remove calling d_path in error paths
calling d_path is excessive in error paths.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:32 -05:00
Namjae Jeon
d710f37c7b cifsd: remove smack inherit leftovers
smack inherit was added for internal product beofre.
It is no longer used. This patch remove it's left overs.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:32 -05:00
Namjae Jeon
17af7d5b8a cifsd: fix implicit declaration of function 'locks_alloc_lock'
Randy reported build failure:
 ../fs/cifsd/smb2pdu.c:6655:7: error: implicit declaration of function
 'locks_alloc_lock'; did you mean 'locks_copy_lock'?

This patch add depend on FILE_LOCKING.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:31 -05:00
Namjae Jeon
a36abeaaf0 cifsd: fix implicit declaration of function 'groups_alloc'
kernel test robot reported:
    fs/cifsd/smb_common.c: In function 'ksmbd_override_fsids':
>> fs/cifsd/smb_common.c:613:7: error: implicit declaration of function
>> 'groups_alloc'; did you mean 'cgroup_sk_alloc'?
>> [-Werror=implicit-function-declaration]
     613 |  gi = groups_alloc(0);
         |       ^~~~~~~~~~~~
         |       cgroup_sk_alloc
   fs/cifsd/smb_common.c:613:5: warning: assignment to 'struct
group_info *' from 'int' makes pointer from integer without a cast
[-Wint-conversion]
     613 |  gi = groups_alloc(0);
         |     ^
>> fs/cifsd/smb_common.c:618:2: error: implicit declaration of function
>> 'set_groups'; did you mean 'get_cgroup_ns'?
>> [-Werror=implicit-function-declaration]
     618 |  set_groups(cred, gi);
         |  ^~~~~~~~~~
         |  get_cgroup_ns
   cc1: some warnings being treated as errors

This patch add depends on MULTIUSER.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:31 -05:00
Namjae Jeon
5365564901 cifsd: fix wrong prototype in comment
kernel test robot reported:
 >> fs/cifsd/oplock.c:1454: warning: expecting prototype for
    create_durable_rsp__buf(). Prototype was for
    create_durable_rsp_buf() instead

This patch fix wrong prototype in comment.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:30 -05:00
Namjae Jeon
a648d8aff8 cifsd: merge time_wrappers.h into smb_common.h
This patch merge time_wrappers.h into smb_common.h.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:30 -05:00
Namjae Jeon
64b39f4a2f cifsd: clean-up codes using chechpatch.pl --strict
Dan Carpenter suggested to run chechpatch.pl --strict on ksmbd to fix
check warnings. This patch does not fix all warnings but only things that
I can understand.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:29 -05:00
Namjae Jeon
7cb82de3cd cifsd: fix error return code in ksmbd_vfs_remove_file()
Change -ENOENT error to -EINVAL to response STATUS_INVALID_PARAMETER.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:29 -05:00
Namjae Jeon
c36fca8630 cifsd: add the check to work file lock and rename behaviors like Windows unless POSIX extensions are negotiated
This patch add the check to work file lock and rename behaviors
like Windows if POSIX extensions are not negotiated.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:28 -05:00
Namjae Jeon
20ea7fd2ac cifsd: use kmalloc() for small allocations
Just use kmalloc() for small allocations.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:28 -05:00
Namjae Jeon
69f447be15 cifsd: fix wrong use of rw semaphore in __session_create()
Adding list to session table should be protected by
down_write/up_write().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:27 -05:00
Namjae Jeon
e506649907 cifsd: remove unneeded macros
Remove unneeded RESPONSE_BUF, REQUEST_BUF, RESPONSE_SZ, INIT_AUX_PAYLOAD,
HAS_AUX_PAYLOAD, AUX_PAYLOAD, AUX_PAYLOAD_SIZE, RESP_HDR_SIZE,
HAS_TRANSFORM_BUF and TRANSFORM_BUF macros.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:27 -05:00
Colin Ian King
3161ad3a71 cifsd: remove redundant assignment to variable err
The variable err is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:26 -05:00
Dan Carpenter
849f59e1a1 cifsd: fix error handling in ksmbd_server_init()
The error handling in ksmbd_server_init() uses "one function to free
everything style" which is impossible to audit and leads to several
canonical bugs.  When we free something that wasn't allocated it may be
uninitialized, an error pointer, freed in a different function or we
try freeing "foo->bar" when "foo" is a NULL pointer.  And since the
code is impossible to audit then it leads to memory leaks.

In the ksmbd_server_init() function, every goto will lead to a crash
because we have not allocated the work queue but we call
ksmbd_workqueue_destroy() which tries to flush a NULL work queue.
Another bug is if ksmbd_init_buffer_pools() fails then it leads to a
double free because we free "work_cache" twice.  A third type of bug is
that we forgot to call ksmbd_release_inode_hash() so that is a resource
leak.

A better way to write error handling is for every function to clean up
after itself and never leave things partially allocated.  Then we can
use "free the last successfully allocated resource" style.  That way
when someone is reading the code they can just track the last resource
in their head and verify that the goto matches what they expect.

In this patch I modified ksmbd_ipc_init() to clean up after itself and
then I converted ksmbd_server_init() to use gotos to clean up.

Fixes: cabcebc31de4 ("cifsd: introduce SMB3 kernel server")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:26 -05:00
Dan Carpenter
c1ea111fd1 cifsd: Fix an error code in smb2_read()
This code is assigning the wrong variable to "err" so it returns
zero/success instead of -ENOMEM.

Fixes: 788b6f45c1d2 ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:25 -05:00
Namjae Jeon
269d3feec1 cifsd: fix build warnings from cifsd.rst
Stephen reported a build warnings from cifsd.rst:

Documentation/filesystems/cifs/cifsd.rst:13: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:14: WARNING: Block quote ends
without a blank line; unexpected unindent.
Documentation/filesystems/cifs/cifsd.rst:14: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:18: WARNING: Block quote ends
without a blank line; unexpected unindent.
Documentation/filesystems/cifs/cifsd.rst:23: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:23: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:24: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:25: WARNING: Definition list
ends without a blank line; unexpected unindent.
Documentation/filesystems/cifs/cifsd.rst:28: WARNING: Unexpected
indentation.
Documentation/filesystems/cifs/cifsd.rst:31: WARNING: Block quote ends
without a blank line; unexpected unindent.
Documentation/filesystems/cifs/cifsd.rst:38: WARNING: Unexpected
indentation.
Documentation/filesystems/cifs/cifsd.rst:32: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:32: WARNING: Inline
substitution_reference start-string without end-string.
Documentation/filesystems/cifs/cifsd.rst:39: WARNING: Block quote ends
without a blank line; unexpected unindent.
Documentation/filesystems/cifs/cifsd.rst:14: WARNING: Undefined
substitution referenced: "--- ksmbd/3 - Client 3 |-------".
Documentation/filesystems/cifs/cifsd.rst:0: WARNING: Undefined
substitution referenced:
"____________________________________________________".
Documentation/filesystems/cifs/cifsd.rst:25: WARNING: Undefined
substitution referenced: "--- ksmbd/0(forker kthread) ---------------|".
Documentation/filesystems/cifs/cifsd.rst:32: WARNING: Undefined
substitution referenced:
"______________________________________________".

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:25 -05:00
Namjae Jeon
b24c933580 cifsd: Pass string length parameter to match_pattern()
When iterating through a directory, a file's name may not be
null-terminated (depending on the underlying filesystem implementation).

Modify match_pattern to take the string's length into account when matching
it against the request pattern.

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:24 -05:00
Namjae Jeon
548e9ad317 cifsd: fix warning: variable 'total_ace_size' and 'posix_ccontext' set but not used
kernel test robot reported warnings:

   fs/cifsd/smbacl.c: In function 'parse_sec_desc':
>> fs/cifsd/smbacl.c:786:6: warning: variable 'total_ace_size' set but
not used [-Wunused-but-set-variable]
     786 |  int total_ace_size = 0, pntsd_type;
         |      ^~~~~~~~~~~~~~
--
   fs/cifsd/smb2pdu.c: In function 'smb2_open':
>> fs/cifsd/smb2pdu.c:3285:26: warning: variable 'posix_ccontext' set but
not used [-Wunused-but-set-variable]
    3285 |   struct create_context *posix_ccontext;
         |                          ^~~~~~~~~~~~~~

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:24 -05:00
Hyunchul Lee
95fa1ce947 cifsd: fix incorrect comments
kernel test bot reports some incorrect comments.
This patch fixes these comments.

Reported-by: kernel test bot <lkp@intel.com>
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:23 -05:00
Sergey Senozhatsky
2e2b0dda18 cifsd: remove unneeded FIXME comments
Remove unneeded FIXME comments.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:23 -05:00
Namjae Jeon
0416536651 cifsd: add index.rst in cifs documentation
Since more than one file is in the cifs document directory,
This patch add an index.rst.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:22 -05:00
Namjae Jeon
04bee6e336 cifsd: update cifsd.rst document
Add work flow of cifsd and feature stats table.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:22 -05:00
Namjae Jeon
50355b0b20 cifsd: fix static checker warning from smb_check_perm_dacl()
Dan reported static checker warning:

  fs/cifsd/smbacl.c:1140 smb_check_perm_dacl()
  error: we previously assumed 'pntsd' could be null (see line 1137)

This patch validate bounds of pntsd buffer.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:21 -05:00
Namjae Jeon
bc3fcc9462 cifsd: fix static checker warning from smb_direct_post_send_data()
Dan reported static checker warning:
 fs/cifsd/transport_rdma.c:1168 smb_direct_post_send_data()
 warn: missing error code 'ret'

This patch add missing ret error code.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:21 -05:00
Dan Carpenter
a2ba2709f5 cifsd: Fix a use after free on error path
The ksmbd_free_work_struct() frees "work" so we need to swap the order
of these two function calls to avoid a use after free.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:20 -05:00
Dan Carpenter
8ef3296706 cifsd: fix a IS_ERR() vs NULL bug
The smb_direct_alloc_sendmsg() function never returns NULL, it only
returns error pointers so the check needs to be updated.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2021-05-10 19:15:20 -05:00