Subject: Re: [PATCH] bpf: explicitly memset the bpf_attr structure

From: Greg Kroah-Hartman <[email-masked]>
Date: Fri, 20 Mar 2020 16:46:33 +0100

On Fri, Mar 20, 2020 at 08:23:57AM -0700, Yonghong Song wrote:
> 
> 
> On 3/20/20 2:48 AM, Greg Kroah-Hartman wrote:
> > For the bpf syscall, we are relying on the compiler to properly zero out
> > the bpf_attr union that we copy userspace data into.  Unfortunately that
> > doesn't always work properly, padding and other oddities might not be
> > correctly zeroed, and in some tests odd things have been found when the
> > stack is pre-initialized to other values.
> 
> Maybe add more contexts about the failure itself so it could be clear
> why we need this patch.

I didn't have the full details, I think Maciej has them though.

> As far as I know from the link below, the failure happens in
> CHECK_ATTR() which checks any unused *area* for a particular subcommand
> must be 0, and this patch tries to provide this guarantee beyond
> area beyond min(uattr_size, sizeof(attr)).

That macro also will get tripped up if padding is not zeroed out as
well, so this is good to fix up.

thanks for the review.

greg k-h