[PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
Hi,

Please accept this trivial patch that fixes allocation info query for an
AIX client (df command returning weird values).
Easy to reproduce by executing smbtorture raw.qfsinfo (with > 4 TB on the
server side) + capturing a network trace to see the wrong values.
Changing the 'block size' param might be a workaround, but not the
preferred solution.



--
Peter Somogyi
IBM Magyarországi Kft.
1117 Budapest
Infopark, Neumann János u. 1.
Hungary
Phone: +36 1 382 5469


0001-SMB_INFO_ALLOCATION-return-with-UINT32_MAX-rather-th.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
Hi, Peter!

On Fri, May 12, 2017 at 01:51:30PM +0000, Peter Somogyi via samba-technical wrote:
> Please accept this trivial patch that fixes allocation info query for an
> AIX client (df command returning weird values).
> Easy to reproduce by executing smbtorture raw.qfsinfo (with > 4 TB on the
> server side) + capturing a network trace to see the wrong values.
> Changing the 'block size' param might be a workaround, but not the
> preferred solution.

Looks good, thanks! However,

dsize = MIN(dsize, UINT32_MAX);
dfree = MIN(dfree, UINT32_MAX);

has a few lines less. What do you think?

Volker

--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
> dsize = MIN(dsize, UINT32_MAX);
> dfree = MIN(dfree, UINT32_MAX);
>
> has a few lines less. What do you think?

Sure, much nicer !
Just retested and no warning or functional issue.

--
Peter Somogyi
IBM Magyarországi Kft.
1117 Budapest
Infopark, Neumann János u. 1.
Hungary
Phone: +36 1 382 5469

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
On Mon, May 15, 2017 at 10:28:25AM +0200, Peter Somogyi wrote:
> > dsize = MIN(dsize, UINT32_MAX);
> > dfree = MIN(dfree, UINT32_MAX);
> >
> > has a few lines less. What do you think?
>
> Sure, much nicer !
> Just retested and no warning or functional issue.

Do you want to submit a fresh patch?

Thanks, Volker

--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
> Do you want to submit a fresh patch?

Yes, here it is:

--
Peter Somogyi
IBM Magyarországi Kft.
1117 Budapest
Infopark, Neumann János u. 1.
Hungary
Phone: +36 1 382 5469


0001-SMB_INFO_ALLOCATION-return-with-UINT32_MAX-rather-th.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
On Mon, May 15, 2017 at 10:26:04AM +0000, Peter Somogyi wrote:
> Yes, here it is:

Thanks!

Reformatted the commit msg, added a comment, reviewed.

Another Team review?

Thanks, Volker

--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:[hidden email]

patch.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][SMB1] SMB_INFO_ALLOC return UINT_MAX rather than cut at 4-byte

Samba - samba-technical mailing list
On Mon, May 15, 2017 at 02:35:54PM +0200, Volker Lendecke via samba-technical wrote:
> On Mon, May 15, 2017 at 10:26:04AM +0000, Peter Somogyi wrote:
> > Yes, here it is:
>
> Thanks!
>
> Reformatted the commit msg, added a comment, reviewed.
>
> Another Team review?

LGTM - pushed !

> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:[hidden email]

> From e75f67ecc7056de017d3afad0be2e35034c7236e Mon Sep 17 00:00:00 2001
> From: Peter Somogyi <[hidden email]>
> Date: Mon, 15 May 2017 10:21:01 +0200
> Subject: [PATCH] SMB_INFO_ALLOCATION: return with UINT32_MAX rather than
>  cutting at 4 bytes
>
> An AIX cifs client queries SMB_INFO_ALLOCATION that has only 4 bytes to report
> dfree and dsize. Return the max instead of random unexpeced numbers.
>
> Signed-off-by: Peter Somogyi <[hidden email]>
> Reviewed-by: Volker Lendecke <[hidden email]>
> ---
>  source3/smbd/trans2.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
> index e8346ba..01df2ee 100644
> --- a/source3/smbd/trans2.c
> +++ b/source3/smbd/trans2.c
> @@ -3510,6 +3510,12 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
>  cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (unsigned int)bsize, (unsigned int)sectors_per_unit,
>   (unsigned int)bytes_per_sector, (unsigned int)dsize, (unsigned int)dfree));
>  
> + /*
> + * For large drives, return max values and not modulo.
> + */
> + dsize = MIN(dsize, UINT32_MAX);
> + dfree = MIN(dfree, UINT32_MAX);
> +
>   SIVAL(pdata,l1_idFileSystem,st.st_ex_dev);
>   SIVAL(pdata,l1_cSectorUnit,sectors_per_unit);
>   SIVAL(pdata,l1_cUnit,dsize);
> --
> 2.1.4
>