Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-cifs@vger.kernel.org, Ronnie Sahlberg <lsahlber@redhat.com>,
	Ronnie Sahlberg <lsahlber@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org, Aurelien Aptel <aaptel@suse.com>
Subject: [PATCH 1/2] CIFS: Use memdup_user() rather than duplicating its implementation
Date: Tue, 5 Nov 2019 22:42:13 +0100
Message-ID: <df3d1da0-a907-80f3-b8f1-6ec7615086d9@web.de> (raw)
In-Reply-To: <b797b2fc-1a33-7311-70d7-dd258d721a03@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 5 Nov 2019 21:30:25 +0100

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

Generated by: scripts/coccinelle/api/memdup_user.cocci

Fixes: f5b05d622a3e99e6a97a189fe500414be802a05c ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/cifs/smb2ops.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 9cbb0ae0e53e..fde2e6d241a8 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1413,15 +1413,10 @@ smb2_ioctl_query_info(const unsigned int xid,
 	if (smb3_encryption_required(tcon))
 		flags |= CIFS_TRANSFORM_REQ;

-	buffer = kmalloc(qi.output_buffer_length, GFP_KERNEL);
-	if (buffer == NULL)
-		return -ENOMEM;
-
-	if (copy_from_user(buffer, arg + sizeof(struct smb_query_info),
-			   qi.output_buffer_length)) {
-		rc = -EFAULT;
-		goto iqinf_exit;
-	}
+	buffer = memdup_user(arg + sizeof(struct smb_query_info),
+			     qi.output_buffer_length);
+	if (IS_ERR(buffer))
+		return PTR_ERR(buffer);

 	/* Open */
 	memset(&open_iov, 0, sizeof(open_iov));
--
2.24.0


  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 21:38 [PATCH 0/2] CIFS: Adjustments for smb2_ioctl_query_info() Markus Elfring
2019-11-05 21:42 ` Markus Elfring [this message]
2019-11-05 21:44 ` [PATCH 2/2] CIFS: Use common error handling code in smb2_ioctl_query_info() Markus Elfring
2019-11-05 22:26 ` [PATCH 0/2] CIFS: Adjustments for smb2_ioctl_query_info() Steve French
2019-11-06  8:45   ` [0/2] " Markus Elfring

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df3d1da0-a907-80f3-b8f1-6ec7615086d9@web.de \
    --to=markus.elfring@web.de \
    --cc=aaptel@suse.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git