From patchwork Thu Apr 21 19:05:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 12822282 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13BB1C4332F for ; Thu, 21 Apr 2022 19:06:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 966656B0075; Thu, 21 Apr 2022 15:06:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84FCB6B0078; Thu, 21 Apr 2022 15:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A3BE6B007B; Thu, 21 Apr 2022 15:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 4B6AF6B0075 for ; Thu, 21 Apr 2022 15:06:03 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2C919176B for ; Thu, 21 Apr 2022 19:06:03 +0000 (UTC) X-FDA: 79381816206.22.480429A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 2277B140023 for ; Thu, 21 Apr 2022 19:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650567962; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oUgm1roGZlmo/RSKHWbU35ZXLzR9iF1b4LYL8/84k2k=; b=iw1l7RlLaAgIdIHnZVvMKskhBJPPrsH35boflvmPyzTwETvRxTmcMDkrKOiD/TkfniuKlR uQQveWXbrxjlyFyLBKOytitOJvjRwVcxuprn0mxWcuxZY9NJBe1l+nTanCjgfPXsgTgyUX c0VmJvK3v4nmJNtqAEplyxHVXfEcyK4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-5iCbuT0xPWGEZic1BuHduA-1; Thu, 21 Apr 2022 15:05:48 -0400 X-MC-Unique: 5iCbuT0xPWGEZic1BuHduA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94B8D1C05AB7; Thu, 21 Apr 2022 19:05:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.22.16.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88C99C27E81; Thu, 21 Apr 2022 19:05:44 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alexander Viro , Andrew Morton , Nicholas Piggin , Logan Gunthorpe , Hari Bathini , "Aneesh Kumar K.V" , "Matthew Wilcox (Oracle)" , Yang Shi , Miaohe Lin , William Kucharski , Hugh Dickins , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , =?utf-8?q?Andr=C3=A9_Almeida?= , Arjan van de Ven , Ulrich Drepper , Michal Hocko Subject: [RFC 0/3] Slight improvements for OOM/Futex Date: Thu, 21 Apr 2022 15:05:30 -0400 Message-Id: <20220421190533.1601879-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Stat-Signature: ebsgj1pyzrxnezwcyq44pk6d6jxcmesn X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iw1l7RlL; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf09.hostedemail.com: domain of npache@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=npache@redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2277B140023 X-HE-Tag: 1650567960-88020 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: The following 3 patches were developed while working on the OOM/Futex fix. Patch 1: This is a nonfunctional change. The vma_is_anonymous function originally led to some confusion about what the oom reaper is checking for in __oom_reap_task_mm. This patch makes that function name more verbose. Patch 2: Futex cleanup was designed with silent failures. Printing this failure would have led to more quickly finding the issue. This introduces a pr_info if the exit path has any issues walking the userspace list. Patch 3: During the debug process I noticed that the oom_reap_task_mm function was always running twice for the same mm_struct; Once in the exit path and once in the oom_reaper. By checking the MMF_OOM_SKIP we can prevent these unnecissary double calls. I'd like some input from David Rientjes here with regards to CVE-2018-1000200, I want to make sure we are not reintroducing that CVE. Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Alexander Viro Cc: Andrew Morton Cc: Nicholas Piggin Cc: Logan Gunthorpe Cc: Hari Bathini Cc: "Aneesh Kumar K.V" Cc: "Matthew Wilcox (Oracle)" Cc: Yang Shi Cc: Miaohe Lin Cc: William Kucharski Cc: Hugh Dickins Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Darren Hart Cc: Davidlohr Bueso Cc: "André Almeida" Cc: Arjan van de Ven Cc: Ulrich Drepper Cc: Michal Hocko Signed-off-by: Nico Pache Nico Pache (3): mm: change vma_is_anonymous to vma_is_private_anon futex: exit: Print a warning when futex_cleanup fails exit: Check for MMF_OOM_SKIP in exit_mmap arch/powerpc/mm/book3s64/pgtable.c | 2 +- fs/userfaultfd.c | 2 +- include/linux/huge_mm.h | 2 +- include/linux/mm.h | 2 +- kernel/futex/core.c | 44 ++++++++++++++++++------------ mm/gup.c | 4 +-- mm/huge_memory.c | 10 +++---- mm/madvise.c | 4 +-- mm/memory.c | 10 +++---- mm/migrate_device.c | 6 ++-- mm/mincore.c | 2 +- mm/mmap.c | 7 +++-- mm/oom_kill.c | 2 +- mm/userfaultfd.c | 8 +++--- 14 files changed, 57 insertions(+), 48 deletions(-)