Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4618300imm; Mon, 30 Jul 2018 19:07:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmS5xwTw2cKhpZLOWxgbXly0CZdQDTZLtAhMAiUwYkhVEed8eCl9c3Nqt92Tso9acLc5oU X-Received: by 2002:a65:450a:: with SMTP id n10-v6mr18057356pgq.392.1533002854715; Mon, 30 Jul 2018 19:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533002854; cv=none; d=google.com; s=arc-20160816; b=0VZRollkIf1vUbKD4AS2gRb3HYpJELH9Fso3zGERtcJUyEwjLjVavm/OD1V67zKUTo tBSaw+Ai/U1qjIzZ4ohEbuxw3Zf7Wn8uP+d3UaVevsfBjfH+FNjz5MxrqX+ipd2aTJ23 usA3nM7UAPIfeTR/JuuNRbWdfTVDuJgzao0DwmSZAN3vXd8RJ1yI1gHKGzYC9HFUdWPR c3EqE+gAhjlQt/bAWzx1+Mk3rw1dRt73gakyNoSzElaCzKt+7LXyHIXFL7Wc9eUDWm+u vHiOJR1dZqN8fQ3RiY18OFJcGjFR8ZaM+fYiI/bPoJZodDSjaQgHyZ8l78Wlzg5vzPr2 AT4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=+n3IsCXIfXKQ9eeO1rwRumWFV0g1UNY/QxIgbOPxHlc=; b=QElCXVOBchnxFz9aGOZ2H0tS756tclU6NJrxSAZhPGQEz37ZNCzZX9yJMzSVDcylzm pMqvSH913UT8vCBFl6ddlfnAUxEcNeW/XAiDfYBB1xhxgQYLLLcfceFqoXITvhea9f9G KkgkEPRaQUZBf50m2vSNc9hyzSaPghbmdSHuJRaWfw93z/z1B6fqSW7sQh8n9MdcHHBm e91/qD9ImrfeTiXHexFXih4K3O+TqaZ5u2yyAGkPcxKBdZ+fXK4uvYVrpyTAot0y+G6J HOZtQovCyNZvu9bXUMkscxAqVTOL2yCXmkw9mFToFagl4uu3EL+Mf3iBzRHFH0XLBpqF HS5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JepEBOmG; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c15-v6si10836549pgw.550.2018.07.30.19.07.20; Mon, 30 Jul 2018 19:07:34 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=JepEBOmG; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731947AbeGaDno (ORCPT + 99 others); Mon, 30 Jul 2018 23:43:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42504 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbeGaDno (ORCPT ); Mon, 30 Jul 2018 23:43:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id l9-v6so5360389pff.9 for ; Mon, 30 Jul 2018 19:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=+n3IsCXIfXKQ9eeO1rwRumWFV0g1UNY/QxIgbOPxHlc=; b=JepEBOmGUPkwxQT7viGZqyV4vrqsiu+k7Bq67fzlNl/MH58KZfz2Ud81x6kzvlRXcu nhULcXxEjNFWhvLOWeuJXgGfkAtH7q+FQq2JMCVnfFlJ4YDOpan0vQHam1cdWFLjbVHw ljUPKBFcKo87u+EeQjJG7QgnpBk1pFU8r/gn1sr+f+BCVlCZ+JIGZn0QV44LPmDEyv/J 5sF+xt9hoYtqnYN6JnfcR9gPKBKVP8+VfV6Y/nL5hUTtFwjF6MQyO4R65C4/Y1xeJf6Z EO/dOIe5jCn4BlhFFAfvk7pJNg+zvm14TLxOM+n7UNnHbvkmIw8O6ZjoLvqa876LJvwk qrbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=+n3IsCXIfXKQ9eeO1rwRumWFV0g1UNY/QxIgbOPxHlc=; b=MGxdKqMb7ltBfyx3C9LjR6MHoy8fZOM9ge6d60qNsbU2L7vBYbJcs8BVUZyNW/NfnL WsXBjR1nECPlh4y1hz1ZGVc2BCG5C7JqLNcsRqWgjwV2WzwUeGsx/EGCEzUC+QLoCbh9 m1MOk0V5+vfXZoMLp4d3r1+ZLTbVebP9GovsiU36w3wd+YZ8NaFSOqtOJevCPzf48obN 1qcpoiqs6vMxnouQpV9M0T2iZfype7TCKPurOPAiD4us4DTEm1MnTfp6J47GL4qvduxJ hgbqAMhsdvnwUwoLKvRfrvsr/K9tuFW73tkJBUy1b6Wt4vxrE2C11itSx2sWiVzLp2Mi l74g== X-Gm-Message-State: AOUpUlGqdq7A6lj+Ex3McIptMusBbG84haYLgH4CFPkZ6iWBS6Xi5ny+ 88J2CaYOAobcSq6LuCt2eTs34Q== X-Received: by 2002:a63:fd52:: with SMTP id m18-v6mr13762857pgj.304.1533002751887; Mon, 30 Jul 2018 19:05:51 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id a77-v6sm23812516pfj.38.2018.07.30.19.05.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 19:05:51 -0700 (PDT) Date: Mon, 30 Jul 2018 19:05:50 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: kernel test robot , yuzhoujian , Stephen Rothwell , "Kirill A. Shutemov" , Andrea Arcangeli , Tetsuo Handa , Roman Gushchin , Yang Shi , Andrew Morton , LKML , lkp@01.org Subject: Re: [LKP] [mm, oom] c1e4c54f9c: BUG:KASAN:null-ptr-deref_in_d In-Reply-To: <20180730095635.GI24267@dhcp22.suse.cz> Message-ID: References: <20180730090320.GD30690@shao2-debian> <20180730095635.GI24267@dhcp22.suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Jul 2018, Michal Hocko wrote: > On Mon 30-07-18 17:03:20, kernel test robot wrote: > [...] > > [ 9.034310] BUG: KASAN: null-ptr-deref in dump_header+0x10c/0x448 > > Could you faddr2line on the offset please? > It's possible that p is NULL when calling dump_header(). In this case we do not want to print any line concerning a victim because no oom kill has occurred. This code shouldn't be part of dump_header(), which is called from multiple contexts even when an oom kill has not occurred, and is ratelimited. The single line output should be the canonical way that userspace parses the log for oom victims, we can't ratelimit it. The following would be a fix patch, but it will be broken if the cgroup aware oom killer is removed from -mm so that the oom_group stuff can be merged. diff --git a/mm/oom_kill.c b/mm/oom_kill.c --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -438,14 +438,6 @@ static void dump_header(struct oom_control *oc, struct task_struct *p) dump_stack(); - /* one line summary of the oom killer context. */ - pr_info("oom-kill:constraint=%s,nodemask=%*pbl", - oom_constraint_text[oc->constraint], - nodemask_pr_args(oc->nodemask)); - cpuset_print_current_mems_allowed(); - mem_cgroup_print_oom_context(oc->memcg, p); - pr_cont(",task=%s,pid=%d,uid=%d\n", p->comm, p->pid, - from_kuid(&init_user_ns, task_uid(p))); if (is_memcg_oom(oc)) mem_cgroup_print_oom_meminfo(oc->memcg); else { @@ -836,7 +828,8 @@ static bool task_will_free_mem(struct task_struct *task) return ret; } -static void __oom_kill_process(struct task_struct *victim) +static void __oom_kill_process(struct task_struct *victim, + struct oom_control *oc) { struct task_struct *p; struct mm_struct *mm; @@ -883,6 +876,18 @@ static void __oom_kill_process(struct task_struct *victim) K(get_mm_counter(victim->mm, MM_ANONPAGES)), K(get_mm_counter(victim->mm, MM_FILEPAGES)), K(get_mm_counter(victim->mm, MM_SHMEMPAGES))); + + if (oc) { + /* One line summary for non-group oom kills */ + pr_info("oom-kill: constraint=%s, nodemask=%*pbl", + oom_constraint_text[oc->constraint], + nodemask_pr_args(oc->nodemask)); + cpuset_print_current_mems_allowed(); + mem_cgroup_print_oom_context(oc->memcg, victim); + pr_cont(", task=%s, pid=%d, uid=%d\n", + victim->comm, victim->pid, + from_kuid(&init_user_ns, task_uid(victim))); + } task_unlock(victim); /* @@ -986,13 +991,13 @@ static void oom_kill_process(struct oom_control *oc, const char *message) } read_unlock(&tasklist_lock); - __oom_kill_process(victim); + __oom_kill_process(victim, oc); } static int oom_kill_memcg_member(struct task_struct *task, void *unused) { get_task_struct(task); - __oom_kill_process(task); + __oom_kill_process(task, NULL); return 0; } @@ -1020,7 +1025,7 @@ static bool oom_kill_memcg_victim(struct oom_control *oc) oc->chosen_task == INFLIGHT_VICTIM) goto out; - __oom_kill_process(oc->chosen_task); + __oom_kill_process(oc->chosen_task, oc); } out: