Received: by 2002:a9a:4c47:0:b029:116:c383:538 with SMTP id u7csp1184877lko; Tue, 13 Jul 2021 19:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmfkv5S8XBzMPyrfXHP0PU9YuURj6iZ+gHzIz6lpXzwazPDz3vizh/aUEM3Fr0wpPal87I X-Received: by 2002:a17:906:4a8d:: with SMTP id x13mr9221750eju.349.1626228226300; Tue, 13 Jul 2021 19:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626228226; cv=none; d=google.com; s=arc-20160816; b=JBMss5VOogxDW8LA/oGgMNppfd0JUMp4RAs7gWVGq8MZevGYklRRxsKjHo4jQhQTcO U8kflX2cNlL5lLjKD2Vsx45fLTtUFKqHKIVnHjdUEOab5FvEZjYUD4XUVCta+MZOSwx+ oYO2PAIGL1IePoWz41vR7GDEScN8BR6R5dpmpBd5hx6rErHVMZU16HhH746LAhbCUaQw TYWKxz+CnLq9tcXZnatL44Z3QcdCOrpf1vZ6cZHTsUROHRegmrYxXU5R2DV+6pqrXmVZ 0kpUQGsLeZO5eG4n1UXbhYCAAte3Unmi/QvIRAfEmyIRPgs2SXrIheOX+5URoRvw8aoh K9HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=8y7e7/8znzi/BwnTe6m5jekna4tN17KZJck+GcPURH0=; b=wV2pcMyq71TVN65twr8f3z15qc6jcsveiPawlFbPl1RBbfPVMSP207vYqmNphr88E/ /X7cH3sFVxm+g/GHbSqn2iTl8BO09ApskwJak80d/QNW5A3+iCjIqV+rKvrxwbgp8OJ2 Qw+7fA5MLBsm8TU7PwU1BvjtlwuH0e5xA2/nq3oX7+LfID8W0rGbNCVqy9QHUcheO7OP c13mYdkOIaL8rxFs5/fxRDE1hDg/TB5xmANJWoiUib9Amxeh+H4tyWPogn9Rbsjo5OrE YG7z5sTh4MXX+KHcUy5WcB3hycCrQBT+TKApV9dYe2OLGuPVpZYtYg/O/qGh2EziYZhx EQog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=VFWoWTFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si846731edo.200.2021.07.13.19.03.22; Tue, 13 Jul 2021 19:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=VFWoWTFw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237379AbhGNCDn (ORCPT + 99 others); Tue, 13 Jul 2021 22:03:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:52102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237371AbhGNCDn (ORCPT ); Tue, 13 Jul 2021 22:03:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 863E9611AB; Wed, 14 Jul 2021 02:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1626228051; bh=AkOidA3H+o7OOm9lbz6dv5CMrVs5hpCplVZ49A0VwOU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VFWoWTFwq47USqbLc/QWVkGSaNuMO669OvDqmpaQo6FVilGhqE4eMtxF0H4tiYRC0 yQpP+APTgO82U1BYrwCx8u5gLQpiGuLAUsRS1s/x6o1fP3BmYM2Xkw02i5yKbfsm+5 JRZ494JRU8Www/Eoa3tUkJYmSO49eo8iL8ouWph0= Date: Tue, 13 Jul 2021 19:00:51 -0700 From: Andrew Morton To: Sergei Trofimovich Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kees Cook , Alexander Potapenko , Thomas Gleixner , Vlastimil Babka , bowsingbetee@pm.me Subject: Re: [PATCH] mm: page_alloc: fix page_poison=1 / INIT_ON_ALLOC_DEFAULT_ON interaction Message-Id: <20210713190051.5d841c9269cf7cddf1731e5a@linux-foundation.org> In-Reply-To: <20210712215816.1512739-1-slyfox@gentoo.org> References: <20210712005732.4f9bfa78@zn3> <20210712215816.1512739-1-slyfox@gentoo.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Jul 2021 22:58:16 +0100 Sergei Trofimovich wrote: > To reproduce the failure we need the following system: > - kernel command: page_poison=1 init_on_free=0 init_on_alloc=0 > - kernel config: > * CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y > * CONFIG_INIT_ON_FREE_DEFAULT_ON=y > * CONFIG_PAGE_POISONING=y > > 0000000085629bdd: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 0000000022861832: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00000000c597f5b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > CPU: 11 PID: 15195 Comm: bash Kdump: loaded Tainted: G U O 5.13.1-gentoo-x86_64 #1 > Hardware name: System manufacturer System Product Name/PRIME Z370-A, BIOS 2801 01/13/2021 > Call Trace: > dump_stack+0x64/0x7c > __kernel_unpoison_pages.cold+0x48/0x84 > post_alloc_hook+0x60/0xa0 > get_page_from_freelist+0xdb8/0x1000 > __alloc_pages+0x163/0x2b0 > __get_free_pages+0xc/0x30 > pgd_alloc+0x2e/0x1a0 > ? dup_mm+0x37/0x4f0 > mm_init+0x185/0x270 > dup_mm+0x6b/0x4f0 > ? __lock_task_sighand+0x35/0x70 > copy_process+0x190d/0x1b10 > kernel_clone+0xba/0x3b0 > __do_sys_clone+0x8f/0xb0 > do_syscall_64+0x68/0x80 > ? do_syscall_64+0x11/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > > Before the 51cba1eb ("init_on_alloc: Optimize static branches") > init_on_alloc never enabled static branch by default. It could > only be enabed explicitly by init_mem_debugging_and_hardening(). > > But after the 51cba1eb static branch could already be enabled > by default. There was no code to ever disable it. That caused > page_poison=1 / init_on_free=1 conflict. > > This change extends init_mem_debugging_and_hardening() to also > disable static branch disabling. > > ... > > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -840,18 +840,22 @@ void init_mem_debugging_and_hardening(void) > } > #endif > > - if (_init_on_alloc_enabled_early) { > - if (page_poisoning_requested) > + if (_init_on_alloc_enabled_early || > + IS_ENABLED(CONFIG_INIT_ON_ALLOC_DEFAULT_ON)) { > + if (page_poisoning_requested) { > pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, " > "will take precedence over init_on_alloc\n"); > - else > + static_branch_disable(&init_on_alloc); > + } else > static_branch_enable(&init_on_alloc); > } > - if (_init_on_free_enabled_early) { > - if (page_poisoning_requested) > + if (_init_on_free_enabled_early || > + IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON)) { > + if (page_poisoning_requested) { > pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, " > "will take precedence over init_on_free\n"); > - else > + static_branch_disable(&init_on_free); > + } else > static_branch_enable(&init_on_free); > } > I'm thinking this is sufficiently serious and sufficiently reported to warrant a cc:stable backport. Agree?