From: Kees Cook <keescook@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
David Howells <dhowells@redhat.com>,
Randy Dunlap <rdunlap@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
Li Zefan <lizefan@huawei.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Aaron Tomlin <atomlin@redhat.com>,
Dario Faggioli <raistlin@linux.it>,
Andrew Shewmaker <agshew@gmail.com>,
Andi Kleen <ak@linux.intel.com>, Jens Axboe <axboe@fb.com>,
Wanpeng Li <liwanp@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Pavel Emelyanov <xemul@parallels.com>,
Andrey Vagin <avagin@openvz.org>,
Michael Ellerman <michael@ellerman.id.au>
Subject: [PATCH v2 1/4] sysctl: clean up char buffer arguments
Date: Thu, 17 Apr 2014 17:16:20 -0700 [thread overview]
Message-ID: <1397780183-24633-2-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1397780183-24633-1-git-send-email-keescook@chromium.org>
The char buffer arguments are needlessly cast in weird places. Clean it up
so things are easier to read.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
kernel/sysctl.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 74f5b580fe34..e7ff80a73c44 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1698,8 +1698,8 @@ int __init sysctl_init(void)
#ifdef CONFIG_PROC_SYSCTL
-static int _proc_do_string(void* data, int maxlen, int write,
- void __user *buffer,
+static int _proc_do_string(char *data, int maxlen, int write,
+ char __user *buffer,
size_t *lenp, loff_t *ppos)
{
size_t len;
@@ -1725,7 +1725,7 @@ static int _proc_do_string(void* data, int maxlen, int write,
len = maxlen-1;
if(copy_from_user(data, buffer, len))
return -EFAULT;
- ((char *) data)[len] = 0;
+ data[len] = 0;
*ppos += *lenp;
} else {
len = strlen(data);
@@ -1743,10 +1743,10 @@ static int _proc_do_string(void* data, int maxlen, int write,
if (len > *lenp)
len = *lenp;
if (len)
- if(copy_to_user(buffer, data, len))
+ if (copy_to_user(buffer, data, len))
return -EFAULT;
if (len < *lenp) {
- if(put_user('\n', ((char __user *) buffer) + len))
+ if (put_user('\n', buffer + len))
return -EFAULT;
len++;
}
@@ -1776,8 +1776,8 @@ static int _proc_do_string(void* data, int maxlen, int write,
int proc_dostring(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- return _proc_do_string(table->data, table->maxlen, write,
- buffer, lenp, ppos);
+ return _proc_do_string((char *)(table->data), table->maxlen, write,
+ (char __user *)buffer, lenp, ppos);
}
static size_t proc_skip_spaces(char **buf)
--
1.7.9.5
next prev parent reply other threads:[~2014-04-18 0:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-18 0:16 [PATCH v2 0/4] sysctl: fix incorrect write position handling Kees Cook
2014-04-18 0:16 ` Kees Cook [this message]
2014-04-18 0:28 ` [PATCH v2 1/4] sysctl: clean up char buffer arguments Andi Kleen
2014-04-18 6:24 ` Kees Cook
2014-04-18 0:16 ` [PATCH v2 2/4] sysctl: refactor sysctl string writing logic Kees Cook
2014-04-18 0:16 ` [PATCH v2 3/4] sysctl: allow for strict write position handling Kees Cook
2014-04-21 22:45 ` Andrew Morton
2014-04-22 4:52 ` Kees Cook
2014-04-22 18:11 ` Andrew Morton
2014-04-22 18:37 ` Kees Cook
2014-04-18 0:16 ` [PATCH v2 4/4] test: validate CONFIG_PROC_SYSCTL_STRICT_WRITES Kees Cook
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=1397780183-24633-2-git-send-email-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=agshew@gmail.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=atomlin@redhat.com \
--cc=avagin@openvz.org \
--cc=axboe@fb.com \
--cc=benh@kernel.crashing.org \
--cc=dave@linux.vnet.ibm.com \
--cc=dhowells@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liwanp@linux.vnet.ibm.com \
--cc=lizefan@huawei.com \
--cc=mgorman@suse.de \
--cc=michael@ellerman.id.au \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=raistlin@linux.it \
--cc=rdunlap@infradead.org \
--cc=riel@redhat.com \
--cc=xemul@parallels.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