Subject: Re: [PATCH net] net: filter: initialize A and X registers

From: Daniel Borkmann <[email-masked]>
Date: Wed, 23 Apr 2014 09:53:37 +0200

On 04/23/2014 05:18 AM, Alexei Starovoitov wrote:
> exisiting BPF verifier allows uninitialized access to registers,
> 'ret A' is considered to be a valid filter.
> So initialize A and X to zero to prevent leaking kernel memory
> In the future BPF verifier will be rejecting such filters
>
> Signed-off-by: Alexei Starovoitov <[email-masked]>
> Cc: Daniel Borkmann <[email-masked]>

I gave it some more thought, it's actually more than just 'ret A'
from your description, user programs could be used to generate code
like 'add X' or 'add #42' instead of a txa or load instruction [where
A is previously uninitialized], as it was always initialized to 0
before. We prevent to do a 'ret X', but X could be uninitialized and
then transferred over to taint A etc. So yeah, this patch is the most
simple way to prevent that w/o huge complexity. Therefore, it's
better this way:

Acked-by: Daniel Borkmann <[email-masked]>