Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp52035iof; Sun, 5 Jun 2022 20:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhzjNulpgON85/ar74XfkI2JDk7CLRZ3nt6R3Cyb+D69YPteQCiuzvhEH7+f+4Y9BQLbup X-Received: by 2002:a05:6a00:1305:b0:512:ebab:3b20 with SMTP id j5-20020a056a00130500b00512ebab3b20mr22151018pfu.82.1654487417632; Sun, 05 Jun 2022 20:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654487417; cv=none; d=google.com; s=arc-20160816; b=K6eXFQAIZ5I2d0XXlDpRbbK7Ede0hKaBe2W8gRaVHfsszLTj3PqwMO6QVsvk6MccmH qelTYYqlIyAwO9x5py+BgDO5zAcgJHq1p6PmllsVaqeXJcLV6C7IfPtqMaXp0CkKsgBd zxleaHcpVp4zzXXzt4LTfbF+rkfaPGGc+FzPoW2NW7XUz2h/2JS6be0LFwuW3PJ3L1uf 6IvIpfk/eky1/5U2LYPZENtuq7jhhk9Gtr/lB7Mi8V78/bqtVA+PDc5KRyCjS21/fhvq 6VAaBIhD+mgtbhVqlMTGXHSiUv08rzDmV75ESs16jDZy08TZt9eh6HAyFq9WXY/rbw2h ZLuA== 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=ribiLlYawPUqvw3Gs6z82Q533HUu4CysdFuhYAX2/Q4=; b=P2lippD69LnjlpClOZWaASnV5sG+qYb1B4LsrJC5gb3Gd2qmn2Wp38Wwm/lJEyVlq3 C9l1DmK7LdH66t0rvBhpzyJe/z5UB5adkkJ7GdvsDAeMVLOYs9z8wWoESqt52oyv7/DJ h3T5hQVXdUB72M9GUW7fUY3XhAQ/Dy8oks8WfC3xoz8SN0Z0ih7vHt72/YnNSEXFzX3o rtRcTUiB165m3BjUPKV5rMY9EYV2EFbL9DhKZFq6s/d8reKQTP9ye06cKjOIkHLrA4Wd oMLkQg7crQKMSmP1xOVfftSJtP1sW/V4o8OUzzsHmbdMZF5bQtKKfB01czqr3vbQBvAh a2kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Nrww3VMl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j3-20020a170902da8300b00162039486e4si10088336plx.319.2022.06.05.20.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 20:50:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Nrww3VMl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3664B98; Sun, 5 Jun 2022 20:42:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239839AbiFDS4Z (ORCPT + 99 others); Sat, 4 Jun 2022 14:56:25 -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 X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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?