Received: by 10.213.65.68 with SMTP id h4csp3371749imn; Tue, 3 Apr 2018 03:52:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vtWX/XNyzO6UdnwV5TNgL8dnJGtGUu68bWy6FBtUhaY4kZ7PON6UzZH96k77X4iny28z6 X-Received: by 2002:a17:902:8490:: with SMTP id c16-v6mr13835592plo.132.1522752776268; Tue, 03 Apr 2018 03:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522752776; cv=none; d=google.com; s=arc-20160816; b=Xi7V5hjvkz0ZZGzxYtAioQNKQdtOby3NcUbUbhVLVQ48a/mpib+hjD2xPYeKyR9dTF nSgBzF0EtCzV66t22G0obaTn5cWxQYHLImLURbIpOOxdfd/WDlEFBYqabN+b2gU/QRvP 0VeXujsfybuAbYCljVsPy6UN6FL7sgcYcQDcaZ5YzSUfPTyK90+Eii734gNYIc/Cd51z d+JyOPZnu82MmHTEupSkAmBcQ8dTCbo9QO1VAAJ3JSIhZ+7uNF3yKvnu93jPSjQU4VmD s10wGxVIse/FMe/Z6UdGiewiozjJqgpsmUE+hinaJuj6KIANAb8J1vhjxwpbS6Ail8Ho qRpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=QcDz8hm8jo4vqhDrqV4TYGCAbQhuytHghoI0vixxG1c=; b=kbxcZHuONaROTrEx64rlnp428X9YC0g88lbGG5ZRZsG11DCu/rzQDoGwXRo1VFyewz DY5sxmglFdyS2iLqrXofwbLfjAW4fQ1FfOy4YdKZGWvizVhXYVNgHfSTJnKQdv7U5t/F 0ZaZs1kF8BEWNkEL95i9P5jJy+CedlcGVg0xf/jgWyaSB5g4pB+hFhgmUOIVcJGVkNuY YN4I5eDMhPQgGpDPct9Xf+s8qtKq9EMg+lRzAHI0Shq4hHVLlIe313/SpYA8bnyH/Hfh hBhJtbfmAWZR0aRCkhAi1ZosC68bjwWFyIzNNBvOFT+V5a41qcNxUncsUN1XM+ZUVQV9 addA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1-v6si264340pld.222.2018.04.03.03.52.42; Tue, 03 Apr 2018 03:52:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932171AbeDCKu5 (ORCPT + 99 others); Tue, 3 Apr 2018 06:50:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:51410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932090AbeDCKuv (ORCPT ); Tue, 3 Apr 2018 06:50:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6BA23AEEF; Tue, 3 Apr 2018 10:50:49 +0000 (UTC) Date: Tue, 3 Apr 2018 12:50:48 +0200 From: Michal Hocko To: syzbot Cc: cgroups@vger.kernel.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, vdavydov.dev@gmail.com, Andrey Ryabinin Subject: Re: general protection fault in __mem_cgroup_free Message-ID: <20180403105048.GK5501@dhcp22.suse.cz> References: <001a113fe4c0a623b10568bb75ea@google.com> <20180403093733.GI5501@dhcp22.suse.cz> <20180403094329.GJ5501@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403094329.GJ5501@dhcp22.suse.cz> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Here we go From 38f0f08a3f9f19c106ae53350e43dc97e2e3a4d8 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Tue, 3 Apr 2018 12:40:41 +0200 Subject: [PATCH] memcg: fix per_node_info cleanup syzbot has triggered a NULL ptr dereference when allocation fault injection enforces a failure and alloc_mem_cgroup_per_node_info initializes memcg->nodeinfo only half way through. __mem_cgroup_free still tries to free all per-node data and dereferences pn->lruvec_stat_cpu unconditioanlly even if the specific per-node data hasn't been initialized. The bug is quite unlikely to hit because small allocations do not fail and we would need quite some numa nodes to make struct mem_cgroup_per_node large enough to cross the costly order. Reported-by: syzbot+8a5de3cce7cdc70e9ebe@syzkaller.appspotmail.com Fixes: 00f3ca2c2d66 ("mm: memcontrol: per-lruvec stats infrastructure") Signed-off-by: Michal Hocko --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e3d5a0a7917f..0a9c4d5194f3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4340,6 +4340,9 @@ static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) { struct mem_cgroup_per_node *pn = memcg->nodeinfo[node]; + if (!pn) + return; + free_percpu(pn->lruvec_stat_cpu); kfree(pn); } -- 2.16.3 -- Michal Hocko SUSE Labs