From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org,
Al Viro <viro@zeniv.linux.org.uk>,
Dave Weinstein <olorin@google.com>,
Jeff Layton <jeff.layton@primarydata.com>,
Kees Cook <keescook@chromium.org>,
Nicolas Pitre <nico@linaro.org>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] arm: sys_oabi-compat: Use kmalloc_array() in two functions
Date: Fri, 26 Aug 2016 15:22:29 +0200 [thread overview]
Message-ID: <dd343c72-2ec7-2114-bee5-1d16fc6c04ac@users.sourceforge.net> (raw)
In-Reply-To: <20160825224632.GL1041@n2100.armlinux.org.uk>
>> Multiplications for the size determination of memory allocations
>> indicated that array data structures should be processed.
>
> I'm afraid the above comment doesn't mean much to me, can you rephrase?
Yes, of course.
How verbose should the explanation for this update suggestion become?
> Maybe:
>
> "Multiplications for kmalloc size arguments are liable to overflow,
> potentially causing a potential security issue. Using kmalloc_array()
> allows the overflow to be caught and the allocation failed. Switch
> these callsites to kmalloc_array()."
Thanks for your wording variant.
>> @@ -285,7 +285,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,
>> return -EINVAL;
>> if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
>> return -EFAULT;
>> - kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
>> + kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
>
> kmalloc_array() here actually buys us no additional safety at either
> of the callsites in your patch
Can this inline function apply a few sanity checks in a consistent way?
http://lxr.free-electrons.com/source/include/linux/slab.h#L564
> - we need to have carefully checked the values to ensure
> they don't overflow prior to the kmalloc for other reasons.
Are there any more constraints to consider?
> That's probably something that should be noted in the commit message too,
> so reviewers have the confidence that you're not blindly changing everything...
I imagine that a few contributors can get mixed feelings from a bunch
of my recent patches. There is a significant patch number in the works
for various Linux software modules.
Regards,
Markus
next prev parent reply other threads:[~2016-08-26 13:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-25 15:50 [PATCH] arm: sys_oabi-compat: Use kmalloc_array() in two functions SF Markus Elfring
2016-08-25 17:46 ` Nicolas Pitre
2016-08-25 22:46 ` Russell King - ARM Linux
2016-08-26 13:22 ` SF Markus Elfring [this message]
2016-08-26 13:45 ` Russell King - ARM Linux
2016-08-26 15:07 ` SF Markus Elfring
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=dd343c72-2ec7-2114-bee5-1d16fc6c04ac@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=jeff.layton@primarydata.com \
--cc=julia.lawall@lip6.fr \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nico@linaro.org \
--cc=olorin@google.com \
--cc=pbonzini@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox