From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98176C43334 for ; Sat, 4 Jun 2022 18:56:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239914AbiFDS40 (ORCPT ); Sat, 4 Jun 2022 14:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239717AbiFDS4T (ORCPT ); Sat, 4 Jun 2022 14:56:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FAC64F47D for ; Sat, 4 Jun 2022 11:56:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D25BA60F7A for ; Sat, 4 Jun 2022 18:56:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E46BC385B8; Sat, 4 Jun 2022 18:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1654368977; bh=cQb6UkaGXt9FYonsLJxY8W4duDAXDhvFNy6evcEDD2Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Nrww3VMlwpkgWsmsFblPZpuVD5vJl0OksZpNd+fhu0fCnOG9Wgi2ld00UDPt2pDVm Py/Vb9WCmzLwSpaG8+38Ku0qXFcMbmOXYtbMDp9gMQl0Ru3LgDgZBcPmm0zPDBgf76 d2QNDnBZjhYxX0IJ9ip7x5WIb81TNQdpyFMBAlDM= Date: Sat, 4 Jun 2022 11:56:16 -0700 From: Andrew Morton To: zhenwei pi Cc: naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/memory-failure: don't allow to unpoison hw corrupted page Message-Id: <20220604115616.b7d5912ac5a37db608f67b78@linux-foundation.org> In-Reply-To: <20220604103229.3378591-1-pizhenwei@bytedance.com> References: <20220604103229.3378591-1-pizhenwei@bytedance.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-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 Sat, 4 Jun 2022 18:32:29 +0800 zhenwei pi wrote: > Currently unpoison_memory(unsigned long pfn) is designed for soft > poison(hwpoison-inject) only. Unpoisoning a hardware corrupted page > puts page back buddy only, this leads BUG during accessing on the > corrupted KPTE. > > Do not allow to unpoison hardware corrupted page in unpoison_memory() > to avoid BUG like this: > > Unpoison: Software-unpoisoned page 0x61234 > BUG: unable to handle page fault for address: ffff888061234000 Thanks. > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -2090,6 +2090,7 @@ int unpoison_memory(unsigned long pfn) > { > struct page *page; > struct page *p; > + pte_t *kpte; > int ret = -EBUSY; > int freeit = 0; > static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL, > @@ -2101,6 +2102,13 @@ int unpoison_memory(unsigned long pfn) > p = pfn_to_page(pfn); > page = compound_head(p); > > + kpte = virt_to_kpte((unsigned long)page_to_virt(p)); > + if (kpte && !pte_present(*kpte)) { > + unpoison_pr_info("Unpoison: Page was hardware poisoned %#lx\n", > + pfn, &unpoison_rs); > + return -EPERM; > + } > + > mutex_lock(&mf_mutex); > > if (!PageHWPoison(p)) { I guess we don't want to let fault injection crash the kernel, so a cc:stable seems appropriate here. Can we think up a suitable Fixes: commit? I'm suspecting this bug has been there for a long time?