lkml.org 
[lkml]   [2018]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 2/6] cifs: Allocate validate negoation request through kmalloc
Date


> -----Original Message-----
> From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> owner@vger.kernel.org] On Behalf Of Long Li
> Sent: Monday, April 16, 2018 7:49 PM
> To: Steve French <sfrench@samba.org>; linux-cifs@vger.kernel.org; samba-
> technical@lists.samba.org; linux-kernel@vger.kernel.org; linux-
> rdma@vger.kernel.org; stable@vger.kernel.org
> Cc: longli <longli@microsoft.com>
> Subject: [PATCH 2/6] cifs: Allocate validate negoation request through kmalloc
>
> From: Long Li <longli@microsoft.com>
>
> The data buffer allocated on the stack can't be DMA'ed, and hence can't send
> through RDMA via SMB Direct.
>
> Fix this by allocating the request on the heap in smb3_validate_negotiate.
>
Please provide Fixes ("12-letters commit id") "commit string" which introduced this issue and it is getting fixed here, so that other can apply this fix to older versions.

> Signed-off-by: Long Li <longli@microsoft.com>
> ---
> fs/cifs/smb2pdu.c | 38 ++++++++++++++++++++++----------------
> 1 file changed, 22 insertions(+), 16 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 0f044c4..abbefe2
> 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -730,7 +730,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses
> *ses) int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon
> *tcon) {
> int rc = 0;
> - struct validate_negotiate_info_req vneg_inbuf;
> + struct validate_negotiate_info_req *pneg_inbuf;
[..]

> rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
> FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
> - (char *)&vneg_inbuf, sizeof(struct
> validate_negotiate_info_req),
> + (char *)pneg_inbuf, sizeof(struct validate_negotiate_info_req),
> (char **)&pneg_rsp, &rsplen);
>
> if (rc != 0) {
> cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
> + kfree(pneg_inbuf);
> return -EIO;
Instead of duplicating code here, please jump to err_rsp_free label. Kfree() takes care to not panic for NULL pointer.
Or for clarity define new label.

> }
>
> @@ -838,12 +842,14 @@ int smb3_validate_negotiate(const unsigned int xid,
> struct cifs_tcon *tcon)
>
> /* validate negotiate successful */
> cifs_dbg(FYI, "validate negotiate info successful\n");
> + kfree(pneg_inbuf);
> kfree(pneg_rsp);
> return 0;
>
> vneg_out:
> cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
> err_rsp_free:
> + kfree(pneg_inbuf);
> kfree(pneg_rsp);
> return -EIO;
> }
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body
> of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html

\
 
 \ /
  Last update: 2018-04-17 06:01    [W:0.077 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site