All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	"David S. Miller" <davem@davemloft.net>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 6/9 next] security/keys: Use iovec_import() instead of import_iovec().
Date: Tue, 15 Sep 2020 14:55:27 +0000	[thread overview]
Message-ID: <4cea8bac469142118b996f62294de6ef@AcuMS.aculab.com> (raw)


iovec_import() has a safer calling convention than import_iovec().

Signed-off-by: David Laight <david.laight@aculab.com>
---
 security/keys/compat.c | 11 +++++------
 security/keys/keyctl.c | 10 +++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/security/keys/compat.c b/security/keys/compat.c
index 6ee9d8f6a4a5..c8b6cc77028b 100644
--- a/security/keys/compat.c
+++ b/security/keys/compat.c
@@ -26,18 +26,17 @@ static long compat_keyctl_instantiate_key_iov(
 	unsigned ioc,
 	key_serial_t ringid)
 {
-	struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
+	struct iovec_cache cache;
 	struct iov_iter from;
+	struct iovec *iov;
 	long ret;
 
 	if (!_payload_iov)
 		ioc = 0;
 
-	ret = compat_import_iovec(WRITE, _payload_iov, ioc,
-				  ARRAY_SIZE(iovstack), &iov,
-				  &from);
-	if (ret < 0)
-		return ret;
+	iov = compat_iovec_import(WRITE, _payload_iov, ioc, &cache, &from);
+	if (IS_ERR(iov))
+		return PTR_ERR(iov);
 
 	ret = keyctl_instantiate_key_common(id, &from, ringid);
 	kfree(iov);
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 9febd37a168f..9a90b89ef24b 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1276,17 +1276,17 @@ long keyctl_instantiate_key_iov(key_serial_t id,
 				unsigned ioc,
 				key_serial_t ringid)
 {
-	struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
+	struct iovec_cache cache;
 	struct iov_iter from;
+	struct iovec *iov;
 	long ret;
 
 	if (!_payload_iov)
 		ioc = 0;
 
-	ret = import_iovec(WRITE, _payload_iov, ioc,
-				    ARRAY_SIZE(iovstack), &iov, &from);
-	if (ret < 0)
-		return ret;
+	iov = iovec_import(WRITE, _payload_iov, ioc, &cache, &from);
+	if (IS_ERR(iov))
+		return PTR_ERR(iov);
 	ret = keyctl_instantiate_key_common(id, &from, ringid);
 	kfree(iov);
 	return ret;
-- 
2.25.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


                 reply	other threads:[~2020-09-15 23:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly 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=4cea8bac469142118b996f62294de6ef@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.