[bug report] ksmbd: fix racy issue from using ->d_parent and ->d_name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Namjae Jeon,

The patch 74d7970febf7: "ksmbd: fix racy issue from using ->d_parent
and ->d_name" from Apr 21, 2023, leads to the following Smatch static
checker warning:

	fs/smb/server/vfs.c:1159 ksmbd_vfs_kern_path_locked()
	info: return a literal instead of 'err'

fs/smb/server/vfs.c
    1149 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
    1150                                unsigned int flags, struct path *path,
    1151                                bool caseless)
    1152 {
    1153         struct ksmbd_share_config *share_conf = work->tcon->share_conf;
    1154         int err;
    1155         struct path parent_path;
    1156 
    1157         err = ksmbd_vfs_path_lookup_locked(share_conf, name, flags, path);
    1158         if (!err)
--> 1159                 return err;
                         ^^^^^^^^^^^
This used to be a "return 0;".  Now it looks like a reversed if
statement bug now where people accidentally include a ! in the if
statement.  I spotted a reversed if statement in someone's code yesterday
so that's not a super uncommon bug, hence this unpublished static
checker warning.

Cifs code as a few of these.

fs/smb/client/file.c:1723 cifs_getlk() info: return a literal instead of 'rc'
fs/smb/client/file.c:1739 cifs_getlk() info: return a literal instead of 'rc'
fs/smb/client/netmisc.c:171 cifs_convert_address() info: return a literal instead of 'rc'

    1160 
    1161         if (caseless) {
    1162                 char *filepath;
    1163                 size_t path_len, remain_len;
    1164 
    1165                 filepath = kstrdup(name, GFP_KERNEL);
    1166                 if (!filepath)
    1167                         return -ENOMEM;

regards,
dan carpenter



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux