cifsd-team / ksmbd

ksmbd kernel server(SMB/CIFS server)
151 stars 23 forks source link

use IPC$ access by host name while host name length are 8 and 9 connection create will fail. the tree connect response compare by the normal miss some part. my config way is guest access #593

Open realszx opened 1 year ago

realszx commented 1 year ago

the root cause is host name length is 8 or 9, while do srvsvc will happen nla_put fail in message request to userspace.

realszx commented 1 year ago

static int ipc_msg_send(struct ksmbd_ipc_msg msg) { struct genlmsghdr nlh; struct sk_buff *skb; int ret = -EINVAL;

     if (!ksmbd_tools_pid) 
             return ret; 

     skb = genlmsg_new(msg->sz, GFP_KERNEL); 
     if (!skb) 
             return -ENOMEM; 

     nlh = genlmsg_put(skb, 0, 0, &ksmbd_genl_family, 0, msg->type); 
     if (!nlh) 
             goto out; 

     ret = nla_put(skb, msg->type, msg->sz, msg->payload); 
     if (ret) { 
             genlmsg_cancel(skb, nlh); 
             goto out; 
     } 

     genlmsg_end(skb, nlh); 
     ret = genlmsg_unicast(&init_net, skb, ksmbd_tools_pid); 
     if (!ret) 
             ipc_update_last_active(); 
     return ret; 

out: nlmsg_free(skb); return ret; }

namjaejeon commented 1 year ago

@realszx Can you send a pull request to fix this ?

realszx commented 1 year ago

@namjaejeon thanks to reply, I'm not sure the tmp fix is reasonable or not. tmp fix is skb = genlmsg_new(msg->sz + 4, GFP_KERNEL). I guess it is a pad length calculte error. final root cause is not clear, I still need trace.

namjaejeon commented 1 year ago

@realszx Can you help me reproduce this issue ? can you share your smb.conf ?

realszx commented 11 months ago

IMG_20230712_145031.jpg

config file