Re: KASAN: use-after-free Read in path_lookupat

From: Al Viro
Date: Mon Mar 25 2019 - 18:50:10 EST


On Mon, Mar 25, 2019 at 11:04:53PM +0100, Daniel Borkmann wrote:

> +static void bpf_destroy_inode_deferred(struct rcu_head *head)
> +{
> + struct inode *inode = container_of(head, struct inode, i_rcu);
> + enum bpf_type type;
> +
> + if (S_ISLNK(inode->i_mode))
> + kfree(inode->i_link);
> + if (!bpf_inode_type(inode, &type))
> + bpf_any_put(inode->i_private, type);
> + free_inode_nonrcu(inode);
> +}

Umm... Can bpf_any_put() can be called in that context? It's going
to run in softirq; if that's OK (I'm not familiar enough with BPF guts
to tell), sure, that's probably the best approach.

Note, BTW, that it's obviously -stable fodder, so any splitting
of ->destroy_inode() would live on top of that fix.