Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp624941imn; Tue, 26 Jul 2022 05:21:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sWj2pVMQLnNFxy4Bc3sy16zvr2tq7eNwY8UlkBXJx/em4VZ+h3CqTVf1XHc7FGiH785vct X-Received: by 2002:a05:6402:414b:b0:43b:6b1a:c230 with SMTP id x11-20020a056402414b00b0043b6b1ac230mr18364968eda.42.1658838117103; Tue, 26 Jul 2022 05:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658838117; cv=none; d=google.com; s=arc-20160816; b=YF3WYZ4FMYAMrg0MeMXNoM/1Vh6BHm+8ZsTgtD3qV01fscl/jOI14O01mzgEqPjTyF FjqsSNLJRp8WohQctICnu6curtiES7pEReDqawJnTsyMLQVTMxwo6UkTMdzCYvv+KJE1 7Cdupjg8Ts9Fq0/8UB9haNEoGLwOpcskkXcqFsmF8JxZBZ47eEs84QsUKKJGGIOFspOU /f5TJECTF3DaFEOEJdMg0918TurfAallaashRmfu4z7aSleugpMHkFVAb+yZFrpTJ/N2 mjgwcthdtrthh7pUaSbto0bK2IyHHgvKy70LyCnsRCEbU0q6+IeHAssIzpUiHxVxVxwI XQkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oFxbdUTxOSfpkrpCjQtHF0t41MaySwoFvQqoE727Q9s=; b=GOFgdBETxutL61cFz1QRmy2NX7Jfifj+RIyE1ddugUmKfAUEjz1LIkFQkOuDPwrG43 ijPdk4iwAK9SC3Cx8TtrmYIX5/i9GPFfzV+QZ/NXgfPsr1Rxv9bLYX8qIj0Hhp1tbB9q OFIij4mhna9pjnMB4IlvMYo7KNK3zsnpiJFXDNyiKj39D069TQTm6uhrtm46qGQNvIrl df7/arxj8iQjmpLc8yPXEq+GHhDTabGqFQ1c8HLx9ffQStReUUZ59pGpZ4g7hyCAYusk 3cx+Y9YSwBIjeKXufp2u8B3DuPJWS4Ja5ZDbK9Z7/SAOEJfvdtg2XdY7SDqeARnw4EZF eBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="ZGY9/QLu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk32-20020a1709077fa000b006ff8cd702e8si16174870ejc.29.2022.07.26.05.21.32; Tue, 26 Jul 2022 05:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="ZGY9/QLu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbiGZMFB (ORCPT + 99 others); Tue, 26 Jul 2022 08:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232953AbiGZMFA (ORCPT ); Tue, 26 Jul 2022 08:05:00 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 616CA2559B; Tue, 26 Jul 2022 05:04:57 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1C7C41FCE9; Tue, 26 Jul 2022 12:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1658837096; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oFxbdUTxOSfpkrpCjQtHF0t41MaySwoFvQqoE727Q9s=; b=ZGY9/QLugeGs5TEHzW25VmqHmJuYByAfJlkb76S3UNSN4HgP+VCyNv6rsIwc0TGYxqityd FpRMqa8MH5sWTBr6YUxTbsYre82gDHy66GSwnYHn79prhInjqCCjAQegLcTZq6WzewNPIH FYTBKcUNgXeCttkiOg+N8dsfIQdtdHw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F140613322; Tue, 26 Jul 2022 12:04:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vudbOGfY32JFdAAAMHmgww (envelope-from ); Tue, 26 Jul 2022 12:04:55 +0000 Date: Tue, 26 Jul 2022 14:04:55 +0200 From: Michal Hocko To: Tetsuo Handa Cc: mm-commits@vger.kernel.org, syzbot+2d2aeadc6ce1e1f11d45@syzkaller.appspotmail.com, shakeelb@google.com, roman.gushchin@linux.dev, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: + mm-memcontrol-fix-potential-oom_lock-recursion-deadlock.patch added to mm-unstable branch Message-ID: References: <20220725220032.B4C30C341C8@smtp.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 26-07-22 20:31:17, Tetsuo Handa wrote: > On 2022/07/26 17:14, Michal Hocko wrote: > > As we have concluded there are two issues possible here which would be > > great to have reflected in the changelog. > > > > On Mon 25-07-22 15:00:32, Andrew Morton wrote: > >> From: Tetsuo Handa > >> Subject: mm: memcontrol: fix potential oom_lock recursion deadlock > >> Date: Fri, 22 Jul 2022 19:45:39 +0900 > >> > >> syzbot is reporting GFP_KERNEL allocation with oom_lock held when > >> reporting memcg OOM [1]. Such allocation request might deadlock the > >> system, for __alloc_pages_may_oom() cannot invoke global OOM killer due to > >> oom_lock being already held by the caller. > > > > I would phrase it like this: > > This report is difficult to explain correctly. > > > syzbot is reporting GFP_KERNEL allocation with oom_lock held when > > reporting memcg OOM [1]. > > Correct. But > > > This is problematic because this creates a > > dependency between GFP_NOFS and GFP_KERNEL over oom_lock which could > > dead lock the system. > > oom_lock is irrelevant when trying GFP_KERNEL allocation from GFP_NOFS > context. Therefore, something like: I meant to say there is a dependency chain potential_fs_lock GFP_NOFS oom_lock GFP_KERNEL potentiaL_lock oom_lock > ---------- > syzbot is reporting GFP_KERNEL allocation with oom_lock held when > reporting memcg OOM [1]. If this allocation triggers the global OOM > situation then the system can livelock because the GFP_KERNEL allocation > with oom_lock held cannot trigger the global OOM killer because > __alloc_pages_may_oom() fails to hold oom_lock. > > Fix this problem by removing the allocation from memory_stat_format() > completely, and pass static buffer when calling from memcg OOM path. > > Note that the caller holding filesystem lock was the trigger for syzbot > to report this locking dependency. Doing GFP_KERNEL allocation with > filesystem lock held can deadlock the system even without involving OOM > situation. > ---------- But this sounds good as well. Thanks! -- Michal Hocko SUSE Labs