Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1655612pxb; Fri, 20 Aug 2021 10:33:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0TYaPeJGBEpL/KIbkqu+uegsNDVtfZwWUcXDuxwIRGYqk+ChpeSedyYo+bNJcSrqEfqkw X-Received: by 2002:a17:906:f8d5:: with SMTP id lh21mr22303927ejb.6.1629480800886; Fri, 20 Aug 2021 10:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629480800; cv=none; d=google.com; s=arc-20160816; b=ExZAMOC3Hic/lcNgzt5cTu0BgnN7Js0B22Q1zIKbchMrJFrY8QXqnEjAmpk/VAr2A+ uoPKrLDuIFkv9iY2MqJapr4o+OdDMOhQhp047d6CQcq59UQQxRjwY0FhFlPWG00q4ev5 Zos/db7g8SU0exx8fdtG/5CUxitFEfC7vKn0YtfxQiubd2TbunWRTBAT2GVV6XsHOzgS M6MldXoK+A6z6tTrWbhDqJVYeaUOYLvHKszJMag8LXDlVxWuBadZSUkYootcUIVKAWy+ X9w2B7NIe5z46qdQpug9oERfK0AQAld/rxQO9z/eYBImPfVvTZ/WuwOsKWlGdXEog73T ko8Q== 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=lRij2bTpSGXVMDbhycmb3su8DPnygSPG8qvXt1BdmMQ=; b=GHWJ3y1tg+OnIoJ91kNycJvvzCIrzs4G8qsH5/flKIfJEmh1fCYJaeFKCrO1HDyiD4 R9rDc1O2vjEHE5dKHssR22J+msw+csvcJGgcG58D4RbaVUEO2gyPg9FjgfWG0WziqoAl Yqboiw+Faaivd7oeq5SFebn3Hx3g63Mv34Ya3ApbgLsjKB8uHjEvNGhohB93D8ANQi5I MNczLgchqbT/XQkrwohIzgrL9I50NHip24/J4oZT+2ff9hXBMnWhS0vTx2d0ArqStOKA QYM3fXmlEctzX8xkoNoo+SKq71D6h4XkfkRUO+CheuSeOETbfVe141GtRVMNW3BOqSfT PJ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=GaEhMARj; 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 y2si7130498ejr.90.2021.08.20.10.32.52; Fri, 20 Aug 2021 10:33:20 -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=GaEhMARj; 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 S234436AbhHTRbv (ORCPT + 99 others); Fri, 20 Aug 2021 13:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbhHTRbt (ORCPT ); Fri, 20 Aug 2021 13:31:49 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DD0C061575; Fri, 20 Aug 2021 10:31:11 -0700 (PDT) Received: from zn.tnic (p200300ec2f107b00196adb237f9ce365.dip0.t-ipconnect.de [IPv6:2003:ec:2f10:7b00:196a:db23:7f9c:e365]) (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 4F8881EC0589; Fri, 20 Aug 2021 19:31:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629480666; 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=lRij2bTpSGXVMDbhycmb3su8DPnygSPG8qvXt1BdmMQ=; b=GaEhMARj8xGVHTj7bt43VnhjzJAALO983uuEfnVXcY7iemcXn6D2JzdeM5GpM5554eoedj 83L3SI19//s9Uf/driz3PyNsPgczirOiDKay/8/uEylpeovTWgsGglPxWYZn6L4uDnHyKB 4vZ6J6dPquVkf5++AYKhlLsuBQkTbeg= Date: Fri, 20 Aug 2021 19:31:43 +0200 From: Borislav Petkov To: Tony Luck Cc: Jue Wang , Ding Hui , naoya.horiguchi@nec.com, osalvador@suse.de, Youquan Song , huangcun@sangfor.com.cn, x86@kernel.org, linux-edac@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] x86/mce: Avoid infinite loop for copy from user recovery Message-ID: References: <20210706190620.1290391-1-tony.luck@intel.com> <20210818002942.1607544-1-tony.luck@intel.com> <20210818002942.1607544-2-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210818002942.1607544-2-tony.luck@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 05:29:40PM -0700, Tony Luck wrote: > @@ -1287,17 +1291,34 @@ static void kill_me_maybe(struct callback_head *cb) > } > } > > -static void queue_task_work(struct mce *m, int kill_current_task) > +static void queue_task_work(struct mce *m, char *msg, int kill_current_task) > { > - current->mce_addr = m->addr; > - current->mce_kflags = m->kflags; > - current->mce_ripv = !!(m->mcgstatus & MCG_STATUS_RIPV); > - current->mce_whole_page = whole_page(m); > + int count = ++current->mce_count; > > - if (kill_current_task) > - current->mce_kill_me.func = kill_me_now; > - else > - current->mce_kill_me.func = kill_me_maybe; > + /* First call, save all the details */ > + if (count == 1) { > + current->mce_addr = m->addr; > + current->mce_kflags = m->kflags; > + current->mce_ripv = !!(m->mcgstatus & MCG_STATUS_RIPV); > + current->mce_whole_page = whole_page(m); > + > + if (kill_current_task) > + current->mce_kill_me.func = kill_me_now; > + else > + current->mce_kill_me.func = kill_me_maybe; > + } > + > + /* Ten is likley overkill. Don't expect more than two faults before task_work() */ "likely" > + if (count > 10) > + mce_panic("Too many machine checks while accessing user data", m, msg); Ok, aren't we too nasty here? Why should we panic the whole box even with 10 MCEs? It is still user memory... IOW, why not: if (count > 10) current->mce_kill_me.func = kill_me_now; and when we return, that user process dies immediately. > + /* Second or later call, make sure page address matches the one from first call */ > + if (count > 1 && (current->mce_addr >> PAGE_SHIFT) != (m->addr >> PAGE_SHIFT)) > + mce_panic("Machine checks to different user pages", m, msg); Same question here. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette