From: Geliang Tang <geliangtang@gmail.com>
To: David Howells <dhowells@redhat.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] KEYS: use memdup_user
Date: Sat, 13 May 2017 11:15:57 +0800 [thread overview]
Message-ID: <908fa521decaf3703e172c3734c0d498741f3ddb.1494580404.git.geliangtang@gmail.com> (raw)
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
security/keys/keyctl.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index dd0da25..ce1574a 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -326,14 +326,11 @@ long keyctl_update_key(key_serial_t id,
/* pull the payload in if one was supplied */
payload = NULL;
if (_payload) {
- ret = -ENOMEM;
- payload = kmalloc(plen, GFP_KERNEL);
- if (!payload)
+ payload = memdup_user(_payload, plen);
+ if (IS_ERR(payload)) {
+ ret = PTR_ERR(payload);
goto error;
-
- ret = -EFAULT;
- if (copy_from_user(payload, _payload, plen) != 0)
- goto error2;
+ }
}
/* find the target key (which must be writable) */
--
2.9.3
next reply other threads:[~2017-05-13 3:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-13 3:15 Geliang Tang [this message]
2017-05-13 3:15 ` [PATCH] mmc: block: " Geliang Tang
2017-05-19 7:43 ` Ulf Hansson
2017-05-13 3:15 ` [PATCH] usb: gadget: f_fs: " Geliang Tang
2017-05-13 8:05 ` Dan Carpenter
2017-05-21 3:25 ` Al Viro
2017-05-14 11:33 ` Michal Nazarewicz
2017-05-13 3:16 ` [PATCH] USB: iowarrior: " Geliang Tang
2017-05-15 10:14 ` Johan Hovold
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=908fa521decaf3703e172c3734c0d498741f3ddb.1494580404.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=dhowells@redhat.com \
--cc=james.l.morris@oracle.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®