Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72547C433FE for ; Thu, 30 Dec 2021 19:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241773AbhL3TI2 (ORCPT ); Thu, 30 Dec 2021 14:08:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236868AbhL3TI0 (ORCPT ); Thu, 30 Dec 2021 14:08:26 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 537EAC06173E for ; Thu, 30 Dec 2021 11:08:25 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id q8so26330714ljp.9 for ; Thu, 30 Dec 2021 11:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kgyj97ctTErwJCIhgzUX8EMyaDF/bLUdCmbEuAYlHjw=; b=YOZVOBHDDpfH3Ql5u1ocW3n2/vJn9YZp1eV0ovKa0V9oHZEI4tHDNs5y3oqOeRyYLB uhnnc1xa7T/vkBCfrT26Kw5tter/RZgpklftKQ2G/60d+OvlMPJnDW9APlJzmOKHwKU1 /yamItDqCuyQ0HpIcSy2xYO8EVL9rVcrw1yOWj8N8IffziJ8mVAdX/e8AKwBGLunsly4 YFpEdTZEZIcfafjeNPCPssBDelxxIrw4qI0pc6PtHVJdUTqfKBsJLPlUnC8ko5hhqeMB vJB8dEryxS3tfVB+qYDZX8erLuN9Vaebet1OIINCgn7RSLNWAmkZzMWzStggjp3N0KFg 6WkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kgyj97ctTErwJCIhgzUX8EMyaDF/bLUdCmbEuAYlHjw=; b=RfQLilwfL5m6yG9nbh4NHZu6FUgiR71Bcle9yenW4xtOTssKWaK01O+9asI4OP13h8 okvtmni0lk5RNppndjVdUOcOE4U/rzLAfi/BucsRWUT+rPmSosoZ//pLPYFLp6wPFe5W LAcTmXX5QBYH9V+eslM5yaGe2cPy/EpIULjmB3L0zGLf/c64QqS2LyZG2r6SyvSrUMMZ ZSbKuiMC66kjP9Ht/QIfnDAfJY/I0zp+tofV+R97u0C4Ow9IvdWz40/V4QtXgukZlW49 KAtpGNisPK0ot2k/UqoEj4pKy4mJiZdrNXu4H8bvA7p6sWs97oyrxnuX9wVlfVNT0tHT NyXA== X-Gm-Message-State: AOAM5331T/Eu2fAt1F0O5g7hrn4Q88j3zzK8BSVokVhV3G2/AwRIE9Y3 gZ3QcJlKxuKAqaNiBxszhhPwJbjzz458dvUDG4eKVg== X-Google-Smtp-Source: ABdhPJwRuz90LSenncg3Ir0RuESemN0QoyVzJiasaGluR94kNn7uQB+PloeHXS2750u1IXJBq7bTmvMkM0LB6KJDmp8= X-Received: by 2002:a2e:8854:: with SMTP id z20mr20464394ljj.202.1640891303360; Thu, 30 Dec 2021 11:08:23 -0800 (PST) MIME-Version: 1.0 References: <00000000000049f33f05d4535526@google.com> In-Reply-To: From: Shakeel Butt Date: Thu, 30 Dec 2021 11:08:12 -0800 Message-ID: Subject: Re: [syzbot] general protection fault in mod_memcg_page_state To: Michal Hocko Cc: syzbot , Andrii Nakryiko , Alexei Starovoitov , bpf , changbin.du@intel.com, Daniel Borkmann , "David S . Miller" , Eric Dumazet , Jesper Dangaard Brouer , hkallweit1@gmail.com, John Fastabend , Martin KaFai Lau , kpsingh@kernel.org, Jakub Kicinski , LKML , netdev , Song Liu , syzkaller-bugs , yajun.deng@linux.dev, Yonghong Song Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 30, 2021 at 12:53 AM Michal Hocko wrote: [...] > > This might have something to do with http://lkml.kernel.org/r/20211222052457.1960701-1-shakeelb@google.com > which has added the accounting which is blowing up. The problem happens > when a memcg is retrieved from the allocated page. This should be NULL > as the reported commit doesn't really add any __GFP_ACCOUNT user AFAICS. > Anyway vm_area_alloc_pages can fail the allocation if the current > context has fatal signals pending. array->pages array is allocated with > __GFP_ZERO so the failed allocation should have kept the pages[0] NULL. > I haven't followed the page->memcg path to double check whether that > could lead to 0xdffffc0000000001 in the end. > > I believe we need something like > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 9bf838817a47..d2e392cac909 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2627,7 +2627,8 @@ static void __vunmap(const void *addr, int deallocate_pages) > unsigned int page_order = vm_area_page_order(area); > int i; > > - mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, > + if (area->pages[0]) > + mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, > -area->nr_pages); > > for (i = 0; i < area->nr_pages; i += 1U << page_order) { > @@ -2968,7 +2969,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > page_order, nr_small_pages, area->pages); > > atomic_long_add(area->nr_pages, &nr_vmalloc_pages); > - mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, area->nr_pages); > + if (area->pages[0]) > + mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, area->nr_pages); > > /* > * If not enough pages were obtained to accomplish an > > Or to account each page separately so that we do not have to rely on > pages[0]. > Thanks Michal for the CC. I will add these checks in the next version (or convert to account each page separately based on discussion on the other thread). Shakeel