From patchwork Thu Sep 6 10:58:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10590481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 343485A4 for ; Thu, 6 Sep 2018 11:55:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F05D2A75F for ; Thu, 6 Sep 2018 11:55:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 134FD2A763; Thu, 6 Sep 2018 11:55:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F8A32A75F for ; Thu, 6 Sep 2018 11:55:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B46E56B7879; Thu, 6 Sep 2018 07:55:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B1EE46B787B; Thu, 6 Sep 2018 07:55:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A35756B787C; Thu, 6 Sep 2018 07:55:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 67B416B7879 for ; Thu, 6 Sep 2018 07:55:21 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id o16-v6so5420849pgv.21 for ; Thu, 06 Sep 2018 04:55:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :references:from:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=TcFB5CHCFhSma7PKOsEl+KfUQE/5xlEkESrVJm/qzKw=; b=W+YoNThrqd9PPknwXmqqpgX4h/lwJHO90U8WBfrvxjOJ2KiEEUB+DWfDs/9LklwY5f tJTS97YS0AnwUfuSwnIJXAwXHu4m81dxjkyq52ROsl7WA2K2mVycUNc9Cf5zvjQg0Z4a 3onTJ+62tptRlvndPfCgnh4y2NbuAF/U4/v9c3d0+cLQBP9WFLq78kDJlpbrayDDl23s JZdQCouIy7TuqtaeHZzVYwS/7uCqffhVPHlkgPZbRI3hG02TApWHuMGjsONLowXVrqbO FzR8LogZInreHdoJgkEWVRROMgbVWGZBgNT6TpVeIQBssMcY1kpoxfaiEcCOxXyiHlKv 9vdQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: APzg51BJhY6UeS2zTqS3nwXNz5xsFvP1pifN4kyMd5GnBZlpOmIO1Mz5 qs15wEHKXAQWouGUGKkk5+z5thil+0QCwl0Jds6Thxy+cxID6dvbjtES10G1A/v/BGIi4pQihaR ZJJERNW7SVmvnnvFm3U3kWP+8AXVmHf8gacTSp78pujRlrr8PHCnQIYaadhW2hoZHHQ== X-Received: by 2002:a63:6fca:: with SMTP id k193-v6mr2267208pgc.360.1536234921110; Thu, 06 Sep 2018 04:55:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYP28J/mB0J9OWol/F3yn0d/7BGmF775o0Z/dLOOmB/M9t6DWzjTq/Da+15p/2BEF34UooP X-Received: by 2002:a63:6fca:: with SMTP id k193-v6mr2267172pgc.360.1536234920568; Thu, 06 Sep 2018 04:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536234920; cv=none; d=google.com; s=arc-20160816; b=yWvYnhM6tTVDK7cibVrv4RKIQLmTLAGqchzARWkbSWJHk4EEIxUNSVsbHZGaktMjpe Qe7E/jTNvDemj++EMliUkXXHJay0hRznFYgYF4jwxJUEoGHkjJKQMi7ESa5qq0k6hkko hC969QAvuIZQxe2RFGwvd3hFmWZiiRC5PqdJjla+iSfN/KP4CBHFOdNHEEphmeH0B7Uj F3MEx+lN5M1eGMK51QFLoSE6X1cxzDHMnG9I8lfR8t0ut1Ry+YFrawUtLNBrLRhhnCUg gF83Emk0c/tQhn9PxBwWvM5vsqD8Wn6Jzc7+vkM1IDDX12MlygUsE3z6/s5Nugoc/V9y UPrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject; bh=TcFB5CHCFhSma7PKOsEl+KfUQE/5xlEkESrVJm/qzKw=; b=MbZPyucsQAAyf7brFmXa67QCzzFCfqBEewPLYKYyPJkWEIxt2HnoOIe8X5ZtKCccFY iWADRUfL6wkRbaN1W3tIVkD0Tqo+3P5hRXQ94K3h+2aNnFTlgQYIjIR/x3ieH2FMN3VG TJ0FMv6UqSKOvrPUDfDJ7mcJdWVh51L/wGdHuIxnPSLexrKdE5Dc4m14o933/zRhE22c 2w25GaQN4WqzpIjR3X6UA+7p7Z2kDaNq7GKdHDmbl+BgZNcjRwfAGHYErLmnitMnIkXe yPM834CfgyQagGkl9wEVyIZdHfHKAV0SFYyzyj6FHW1emZsNjA0pO1GUdbpFtf1VOdQv tNAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id u18-v6si5102303pgo.142.2018.09.06.04.55.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 04:55:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav110.sakura.ne.jp (fsav110.sakura.ne.jp [27.133.134.237]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w86AwRF1008545; Thu, 6 Sep 2018 19:58:27 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav110.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav110.sakura.ne.jp); Thu, 06 Sep 2018 19:58:27 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav110.sakura.ne.jp) Received: from [192.168.1.8] (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w86AwMWx008518 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Sep 2018 19:58:27 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: [PATCH] mm, oom: Introduce time limit for dump_tasks duration. To: Dmitry Vyukov , Michal Hocko , Andrew Morton , David Rientjes Cc: syzbot , "'Dmitry Vyukov' via syzkaller-upstream-moderation" , linux-mm References: <0252ad5d-46e6-0d7f-ef91-4e316657a83d@i-love.sakura.ne.jp> <201809060553.w865rmpj036017@www262.sakura.ne.jp> From: Tetsuo Handa Message-ID: <58aa0543-86d0-b2ad-7fb9-9bed7c6a1f6c@i-love.sakura.ne.jp> Date: Thu, 6 Sep 2018 19:58:25 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On 2018/09/06 18:54, Dmitry Vyukov wrote: > On Thu, Sep 6, 2018 at 7:53 AM, Tetsuo Handa > wrote: >> Dmitry Vyukov wrote: >>>> Also, another notable thing is that the backtrace for some reason includes >>>> >>>> [ 1048.211540] ? oom_killer_disable+0x3a0/0x3a0 >>>> >>>> line. Was syzbot testing process freezing functionality? >>> >>> What's the API for this? >>> >> >> I'm not a user of suspend/hibernation. But it seems that usage of the API >> is to write one of words listed in /sys/power/state into /sys/power/state . >> >> # echo suspend > /sys/power/state > > syzkaller should not write to /sys/power/state. The only mention of > "power" is in some selinux contexts. > OK. Then, I have no idea. Anyway, I think we can apply this patch. From 18876f287dd69a7c33f65c91cfcda3564233f55e Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Thu, 6 Sep 2018 19:53:18 +0900 Subject: [PATCH] mm, oom: Introduce time limit for dump_tasks duration. Since printk() is slow, printing one line takes nearly 0.01 second. As a result, syzbot is stalling for 52 seconds trying to dump 5600 tasks at for_each_process() under RCU. Since such situation is almost inflight fork bomb attack (the OOM killer will print similar tasks for so many times), it makes little sense to print all candidate tasks. Thus, this patch introduces 3 seconds limit for printing. Signed-off-by: Tetsuo Handa Cc: Dmitry Vyukov --- mm/oom_kill.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index f10aa53..48e5bf6 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -399,14 +399,22 @@ static void dump_tasks(struct mem_cgroup *memcg, const nodemask_t *nodemask) { struct task_struct *p; struct task_struct *task; + unsigned long start; + unsigned int skipped = 0; pr_info("Tasks state (memory values in pages):\n"); pr_info("[ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name\n"); rcu_read_lock(); + start = jiffies; for_each_process(p) { if (oom_unkillable_task(p, memcg, nodemask)) continue; + if (time_after(jiffies, start + 3 * HZ)) { + skipped++; + continue; + } + task = find_lock_task_mm(p); if (!task) { /* @@ -426,6 +434,8 @@ static void dump_tasks(struct mem_cgroup *memcg, const nodemask_t *nodemask) task_unlock(task); } rcu_read_unlock(); + if (skipped) + pr_info("Printing %u tasks omitted.\n", skipped); } static void dump_header(struct oom_control *oc, struct task_struct *p)