* [PATCH] resource: Use 2-factor allocator calls
@ 2018-07-04 17:31 Kees Cook
2018-07-05 22:07 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2018-07-04 17:31 UTC (permalink / raw)
To: Andrew Morton; +Cc: AKASHI Takahiro, Baoquan He, Stephen Rothwell, linux-kernel
As already done treewide, switch from open-coded multiplication to using
2-factor allocation helpers.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
kernel/resource.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index d717acd12bf4..16debbf2d24c 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -453,7 +453,7 @@ int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
int ret = -1;
/* create a list */
- rams = vmalloc(sizeof(struct resource) * rams_size);
+ rams = vmalloc(array_size(rams_size, sizeof(struct resource)));
if (!rams)
return ret;
@@ -469,8 +469,8 @@ int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
int rams_new_size;
rams_new_size = rams_size + 16;
- rams_new = vmalloc(sizeof(struct resource)
- * rams_new_size);
+ rams_new = vmalloc(array_size(rams_new_size,
+ sizeof(struct resource)));
if (!rams_new)
goto out;
--
2.17.1
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] resource: Use 2-factor allocator calls
2018-07-04 17:31 [PATCH] resource: Use 2-factor allocator calls Kees Cook
@ 2018-07-05 22:07 ` Andrew Morton
2018-07-06 1:14 ` Baoquan He
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2018-07-05 22:07 UTC (permalink / raw)
To: Kees Cook
Cc: AKASHI Takahiro, Baoquan He, Stephen Rothwell, linux-kernel, Wei Yang
On Wed, 4 Jul 2018 10:31:53 -0700 Kees Cook <keescook@chromium.org> wrote:
> As already done treewide, switch from open-coded multiplication to using
> 2-factor allocation helpers.
>
This is against resource-add-walk_system_ram_res_rev.patch
(http://lkml.kernel.org/r/20180322033722.9279-2-bhe@redhat.com).
That patch is awaiting (for several months!) a v2. Will this be happening?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] resource: Use 2-factor allocator calls
2018-07-05 22:07 ` Andrew Morton
@ 2018-07-06 1:14 ` Baoquan He
0 siblings, 0 replies; 3+ messages in thread
From: Baoquan He @ 2018-07-06 1:14 UTC (permalink / raw)
To: Andrew Morton
Cc: Kees Cook, AKASHI Takahiro, Stephen Rothwell, linux-kernel, Wei Yang
Hi Andrew, Kees,
About the implemention of walk_system_ram_res_rev(), it was posted by
AKASHI firstly for his arm kexec_file adding, later he dropped it
because he took other way and doesn't need walk_system_ram_res_rev() any
more in his patchset.
Then I found my below patch needs a walk_system_ram_res_rev(),
kernel/kexec_file.c: load kernel at top of system RAM if required
so I took AKASHI's patch and posted a patchset including above patch,
and AKASHI's patch, it can be seen here:
http://lkml.kernel.org/r/20180322033722.9279-1-bhe@redhat.com
Then Andrew reviewed and added comment to say this
walk_system_ram_res_rev() is not good, and suggested me to change the
singly linked list of child resource to standard list_head which is
doubly linked list, then walk_system_ram_res_rev() can be implemented
very easily to do reversed searching. So I posted v2:
http://lkml.kernel.org/r/20180408024724.16812-1-bhe@redhat.com
Now the latest post is v6:
http://lkml.kernel.org/r/20180704041038.8190-1-bhe@redhat.com
Since changing resource child tree to take doubly linked list list_head
impacts all ARCH and many components, I am still fixing issues test
robot reported since I can only test on x86. Now I plan to ask intel
0day team to tell how I can run scripts locally for all ARCH to find out
all codes impacted and fix them all at one time.
So I think we can drop the old walk_system_ram_res_rev() in v1, I am
still working on this issue. Sorry for the confusion I made because of
my mistakes.
Thanks
Baoquan
On 07/05/18 at 03:07pm, Andrew Morton wrote:
> On Wed, 4 Jul 2018 10:31:53 -0700 Kees Cook <keescook@chromium.org> wrote:
>
> > As already done treewide, switch from open-coded multiplication to using
> > 2-factor allocation helpers.
> >
>
> This is against resource-add-walk_system_ram_res_rev.patch
> (http://lkml.kernel.org/r/20180322033722.9279-2-bhe@redhat.com).
>
> That patch is awaiting (for several months!) a v2. Will this be happening?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-06 1:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 17:31 [PATCH] resource: Use 2-factor allocator calls Kees Cook
2018-07-05 22:07 ` Andrew Morton
2018-07-06 1:14 ` Baoquan He
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.