Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [bug report] CIFS: Implement follow_link for SMB2
@ 2016-07-12 13:55 Dan Carpenter
  2016-07-19 19:27 ` Pavel Shilovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-07-12 13:55 UTC (permalink / raw)
  To: pshilovsky-eUNUBHrolfbYtjvyW6yDsg; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

Hello Pavel Shilovsky,

The patch b42bf88828cd: "CIFS: Implement follow_link for SMB2" from
Aug 14, 2013, leads to the following static checker warning:

	fs/cifs/smb2pdu.c:1408 SMB2_open()
	warn: potentially allocating too little.  77 vs 4

fs/cifs/smb2pdu.c
  1402          rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
  1403          rsp = (struct smb2_create_rsp *)iov[0].iov_base;
  1404  
  1405          if (rc != 0) {
  1406                  cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
  1407                  if (err_buf)
  1408                          *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4,

I'm not an expert, but these look like it might be controlled from user
space.  How do we know that get_rfc1002_length() returns something large
enough?

  1409                                             GFP_KERNEL);
  1410                  goto creat_exit;
  1411          }
  1412  

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] CIFS: Implement follow_link for SMB2
  2016-07-12 13:55 [bug report] CIFS: Implement follow_link for SMB2 Dan Carpenter
@ 2016-07-19 19:27 ` Pavel Shilovsky
       [not found]   ` <CAKywueR7pGqL-HqqJH60XxPJ8fr1Mf3H7BZsSp2ePfXkdvH5sQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Shilovsky @ 2016-07-19 19:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-cifs

2016-07-12 16:55 GMT+03:00 Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>:
> Hello Pavel Shilovsky,
>
> The patch b42bf88828cd: "CIFS: Implement follow_link for SMB2" from
> Aug 14, 2013, leads to the following static checker warning:
>
>         fs/cifs/smb2pdu.c:1408 SMB2_open()
>         warn: potentially allocating too little.  77 vs 4
>
> fs/cifs/smb2pdu.c
>   1402          rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
>   1403          rsp = (struct smb2_create_rsp *)iov[0].iov_base;
>   1404
>   1405          if (rc != 0) {
>   1406                  cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
>   1407                  if (err_buf)
>   1408                          *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4,
>
> I'm not an expert, but these look like it might be controlled from user
> space.  How do we know that get_rfc1002_length() returns something large
> enough?

Good catch. err_buf is used by smb2_query_symlink() without any checks
for a buffer size. Thanks!

-- 
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] CIFS: Implement follow_link for SMB2
       [not found]   ` <CAKywueR7pGqL-HqqJH60XxPJ8fr1Mf3H7BZsSp2ePfXkdvH5sQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-07-24  7:40     ` Pavel Shilovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Shilovsky @ 2016-07-24  7:40 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-cifs

2016-07-19 22:27 GMT+03:00 Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>:
> 2016-07-12 16:55 GMT+03:00 Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>:
>> Hello Pavel Shilovsky,
>>
>> The patch b42bf88828cd: "CIFS: Implement follow_link for SMB2" from
>> Aug 14, 2013, leads to the following static checker warning:
>>
>>         fs/cifs/smb2pdu.c:1408 SMB2_open()
>>         warn: potentially allocating too little.  77 vs 4
>>
>> fs/cifs/smb2pdu.c
>>   1402          rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
>>   1403          rsp = (struct smb2_create_rsp *)iov[0].iov_base;
>>   1404
>>   1405          if (rc != 0) {
>>   1406                  cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
>>   1407                  if (err_buf)
>>   1408                          *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4,
>>
>> I'm not an expert, but these look like it might be controlled from user
>> space.  How do we know that get_rfc1002_length() returns something large
>> enough?
>
> Good catch. err_buf is used by smb2_query_symlink() without any checks
> for a buffer size. Thanks!
>
> --
> Best regards,
> Pavel Shilovsky

I have posted a patch "CIFS: Fix a possible invalid memory access in
smb2_query_symlink()" that addressed the problem. It seems like we
good in SMB2_open() but an invalid memory access can happen in
smb2_query_symlink().

-- 
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-24  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-12 13:55 [bug report] CIFS: Implement follow_link for SMB2 Dan Carpenter
2016-07-19 19:27 ` Pavel Shilovsky
     [not found]   ` <CAKywueR7pGqL-HqqJH60XxPJ8fr1Mf3H7BZsSp2ePfXkdvH5sQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-24  7:40     ` Pavel Shilovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox