lkml.org 
[lkml]   [2018]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] livepatch: Initialize shadow variables by init function safely
From
Date
On 03/14/2018 03:28 PM, Josh Poimboeuf wrote:
> On Tue, Mar 13, 2018 at 04:54:47PM +0100, Petr Mladek wrote:
>
>> diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
>> index 4754f01c1abb..fc7c64ce0992 100644
>> --- a/include/linux/livepatch.h
>> +++ b/include/linux/livepatch.h
>> @@ -186,11 +186,20 @@ static inline bool klp_have_reliable_stack(void)
>> IS_ENABLED(CONFIG_HAVE_RELIABLE_STACKTRACE);
>> }
>>
>> +struct klp_shadow;
>
> Why is this forward struct declaration needed?

Compiles ok w/o it, so shouldn't be needed.

>> @@ -150,6 +145,23 @@ static void *__klp_shadow_get_or_alloc(void *obj, unsigned long id, void *data,
>> goto exists;
>> }
>>
>> + new_shadow->obj = obj;
>> + new_shadow->id = id;
>> +
>> + if (init_func) {
>> + int err;
>> +
>> + err = init_func(obj, new_shadow->data, init_data);
>
> Am I hallucinating, or will new_shadow->data always be NULL? How did it
> even work before?
>
struct klp_shadow {
struct hlist_node node;
struct rcu_head rcu_head;
void *obj;
unsigned long id;
char data[]; << not a pointer
};

In the past, this function would allocate the klp_shadow struct size
accordingly, then memcpy in its data contents. This patch pushes the
responsibility of data initialization out to the init_func().

-- Joe

\
 
 \ /
  Last update: 2018-03-14 20:44    [W:0.162 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site