Re: [PATCH 1/2] livepatch: Initialize shadow variables by init function safely

From: Josh Poimboeuf
Date: Wed Mar 14 2018 - 16:22:37 EST


On Wed, Mar 14, 2018 at 03:43:01PM -0400, Joe Lawrence wrote:
> >> @@ -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
> };

Ah. This code needs a nice comment above the kzalloc() call, so I won't
get confused again next time.

--
Josh