Re: general protection fault in watchdog

From: Michal Hocko
Date: Fri Dec 14 2018 - 08:28:43 EST

On Fri 14-12-18 14:11:05, Dmitry Vyukov wrote:
> On Fri, Dec 14, 2018 at 1:51 PM syzbot
> <syzbot+7713f3aa67be76b1552c@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit: f5d582777bcb Merge branch 'for-linus' of git://git.kernel...
> > git tree: upstream
> > console output:
> > kernel config:
> > dashboard link:
> > compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> > syz repro:
> > C reproducer:
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+7713f3aa67be76b1552c@xxxxxxxxxxxxxxxxxxxxxxxxx
> +linux-mm for memcg question
> What the repro does is effectively just
> setsockopt(EBT_SO_SET_ENTRIES). This eats all machine memory and
> causes OOMs. Somehow it also caused the GPF in watchdog when it
> iterates over task list, perhaps some scheduler code leaves a dangling
> pointer on OOM failures.
> But what bothers me is a different thing. syzkaller test processes are
> sandboxed with a restrictive memcg which should prevent them from
> eating all memory. do_replace_finish calls vmalloc, which uses
> does). And page alloc seems to change memory against memcg iff
> GFP_ACCOUNT is provided.
> Am I missing something or vmalloc is indeed not accounted (DoS)? I see
> some explicit uses of GFP_KERNEL_ACCOUNT, e.g. the one below, but they
> seem to be very sparse.
> static void *seq_buf_alloc(unsigned long size)
> {
> return kvmalloc(size, GFP_KERNEL_ACCOUNT);
> }
> Now looking at the code I also don't see how kmalloc(GFP_KERNEL) is
> accounted... Which makes me think I am still missing something.

You are not missing anything. We do not account all allocations and you
have to explicitly opt-in by __GFP_ACCOUNT. This is a deliberate
decision. If the allocation is directly controlable by an untrusted user
and the memory is associated with a process life time then this looks
like a good usecase for __GFP_ACCOUNT. If an allocation outlives a
process then there the flag should be considered with a great care
because oom killer is not able to resolve the memcg pressure and so the
limit enforcement is not effective.
Michal Hocko