Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp646059pxy; Thu, 22 Apr 2021 10:05:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEaTzuutW2jMGIqkq5xsRHPH/KQSyiO53/945OhYA8X7qOwBZni4uxrzH67wavz79VGBtn X-Received: by 2002:a17:906:b191:: with SMTP id w17mr4552139ejy.200.1619111129895; Thu, 22 Apr 2021 10:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619111129; cv=none; d=google.com; s=arc-20160816; b=RZTsfilv0LxdOC+RQlddbgH93iVT/cghTsmBEsoR8c7qdOrp8R5QKM9KiiYJi3t69q NRTOLTuvJ3QJPPcvOyp1Eywn98TRUFZCb8NEbn1TRwK1FjS3TT9ZKi5TCsmuAhkRbdy0 DYs3skYqjc/KbweGkHTyVL6VSnQPlthji3oi45bdlUS2SkqfH7oawNdpYU1XHaCfRljh Gn3erBqqlkOM7N86Rb+esaFGaKEiMUq9/3oqB07MbMgCPw3fNfJyUbcaJjKQK1OxYny4 6tKYJe9ijpugM0Ex5xJrypemo00trcKoOOruHkBlaRZcJeZmKYVt79jTbtLYIU2Te08M ZgOg== 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=+EX3N/gvFrXpHJ1GEsmaOZJTZVcILi5Ui/2IEpF961c=; b=BIDjYxCBULU3NoLAsksLZUBBXwNST4XrFd3+2IO3q6C9mtg1VbqibOn9lZFEH+yJ7s POMMLNt9CJY1q3H9FMuXWcNE7r+7QAXwnBh4UGg7l6HgXl9+Gkuq1UKgRisAdBO3scal sdWhYG7IIZBkJbErBQJARsM+J+xEFMUKxQOVq9Q9j55kADL0hxKkYG7qXypGKgXwg0GE dm0qyvSwxiraV+ovKchbskkZbSJh8iWTQK8YU/E6j1xuOQVyjZeDyD4n+ETlru4JnRJe r+DeaauJwfsx5dvUEOoXT2zS53mSzIwhuDOJWJvei3v1mUx2zpNccqKCUO1Ah/v51ojG do5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Ruz8oZT5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si3064364edl.342.2021.04.22.10.05.05; Thu, 22 Apr 2021 10:05:29 -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=@alien8.de header.s=dkim header.b=Ruz8oZT5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238255AbhDVRCB (ORCPT + 99 others); Thu, 22 Apr 2021 13:02:01 -0400 Received: from mail.skyhub.de ([5.9.137.197]:55840 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbhDVRB7 (ORCPT ); Thu, 22 Apr 2021 13:01:59 -0400 Received: from zn.tnic (p200300ec2f0e2900329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:2900:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C35CB1EC0288; Thu, 22 Apr 2021 19:01:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1619110880; 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:in-reply-to:in-reply-to: references:references; bh=+EX3N/gvFrXpHJ1GEsmaOZJTZVcILi5Ui/2IEpF961c=; b=Ruz8oZT5ljaG7POpeRKhqRJ2oTx6qlTGn4bIJR/c6b0WLmknBSxWwgbTFZtQXGdkpj+uk7 qO/oUfLFknqx5c+AYUsLtv3LkuYpfbGSLpiQjKfG+23/p5ld/tzAWfFnnbr0k32BCizy9O pp29t2GrGqwTcZGklOO5O7f2ujufDU4= Date: Thu, 22 Apr 2021 19:01:18 +0200 From: Borislav Petkov To: Naoya Horiguchi Cc: linux-mm@kvack.org, Tony Luck , Aili Yao , Andrew Morton , Oscar Salvador , David Hildenbrand , Andy Lutomirski , Naoya Horiguchi , Jue Wang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/3] mm/memory-failure: Use a mutex to avoid memory_failure() races Message-ID: <20210422170118.GC7021@zn.tnic> References: <20210421005728.1994268-1-nao.horiguchi@gmail.com> <20210421005728.1994268-2-nao.horiguchi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210421005728.1994268-2-nao.horiguchi@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 21, 2021 at 09:57:26AM +0900, Naoya Horiguchi wrote: > From: Tony Luck > > There can be races when multiple CPUs consume poison from the same > page. The first into memory_failure() atomically sets the HWPoison > page flag and begins hunting for tasks that map this page. Eventually > it invalidates those mappings and may send a SIGBUS to the affected > tasks. > > But while all that work is going on, other CPUs see a "success" > return code from memory_failure() and so they believe the error > has been handled and continue executing. > > Fix by wrapping most of the internal parts of memory_failure() in > a mutex. > > Signed-off-by: Tony Luck > Signed-off-by: Naoya Horiguchi > --- > mm/memory-failure.c | 37 ++++++++++++++++++++++++------------- > 1 file changed, 24 insertions(+), 13 deletions(-) Reviewed-by: Borislav Petkov -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette