Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4371617pxj; Tue, 8 Jun 2021 12:40:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxonxfjvC9zd569Lahs4j3RhuQvukBwatNchPXQ1PQpx1h8wlTIGkuZuq8UHKWLhb76zqkf X-Received: by 2002:a17:906:fcbb:: with SMTP id qw27mr395497ejb.478.1623181204661; Tue, 08 Jun 2021 12:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623181204; cv=none; d=google.com; s=arc-20160816; b=tsZx7Vm65XOoj+Vt+gg9FLdVFMIRZ9R20IOYoYX0WVKtLkPQa3+mmWza/10pmv2GM8 NKWnJcP1xFXOfWVXaCsOQ2KXG+yatsFIotC+xG2tP4Mkm8CcyGJcpRZW+lFNo2JYp8Yp xjJOt/rlB25MXas40Pr8p98iPfhwR9SiQmqDGGLw3ie3hOzLyDJyw9aNPMMaaC3bLIVr g0m7sGWlQgpko0th6G2XANnPwfp63VS7wiBv8twrvz+SSoQAI8UbjPzrxds176RS3LVg J3oCyO8da08QdmXGErLbxToSxB08l+IM3pxBpVQCPDL9ybyYOzjAJPUstrrgd0z4Akr7 OKtg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B30LN6tRLjQxp1+YWN42Dy+oUkhU8Y6SaxVe7Al/UkY=; b=aL5igt0kgTSQ8PrKwCCOtU0YMxjpzX3JDYwmnS/7TvqM8H0hEi5/jXJWwuzM7TZOgj 4KDLQsoLYTY7IhkE4Np4XIebWryXMYQK/8wF1Ff5Gk7n9T9wAVl07c/RxvuL2orOStud dHPBW9go2oprZ8XzdGnL0UGZsedhOa3mI8xbCn8PRkEyvdXUKp6SQ4pHDHTlhICPayDS Z1lHHGk4pCjLGcCkotZphUIR7BMKNqzEYnVXUZPfDGOdTJgzigZTaAiLsSJy2z7XgcYk xnR0NFSpJ16wdoYXV/cFBYaZfBt0xbq/Jr/U3fTaJEhEWnx3GYrOYdOeV0Yx5XONwjLq OjeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W+9lCCKl; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si473784edx.139.2021.06.08.12.39.40; Tue, 08 Jun 2021 12:40:04 -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=@linuxfoundation.org header.s=korg header.b=W+9lCCKl; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238323AbhFHTfc (ORCPT + 99 others); Tue, 8 Jun 2021 15:35:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238638AbhFHTTb (ORCPT ); Tue, 8 Jun 2021 15:19:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E624F61432; Tue, 8 Jun 2021 18:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623178337; bh=oI1Gcw5iYbmyceXcrYOim1sfboeXONWKu14l+TQTLQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+9lCCKlroMhaFNeKXCFSAPCCR+UpCVCtIGxf/2CZcU92GEJohcFnF4urIXKH11g4 BH6b3QVlfS3NPN+h/eaDfT1hSDzPcJiHFUjBbxwD0oMjJ2WWDGeDIVkiX5lMAKKFFo vJxw1wGmdcw+Y5NWPJ/3ExbQ9nALOOmDjTqGSxaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Eric W. Biederman" , Jiashuo Liang , Borislav Petkov Subject: [PATCH 5.12 158/161] x86/fault: Dont send SIGSEGV twice on SEGV_PKUERR Date: Tue, 8 Jun 2021 20:28:08 +0200 Message-Id: <20210608175950.794678689@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175945.476074951@linuxfoundation.org> References: <20210608175945.476074951@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiashuo Liang commit 5405b42c2f08efe67b531799ba2fdb35bac93e70 upstream. __bad_area_nosemaphore() calls both force_sig_pkuerr() and force_sig_fault() when handling SEGV_PKUERR. This does not cause problems because the second signal is filtered by the legacy_queue() check in __send_signal() because in both cases, the signal is SIGSEGV, the second one seeing that the first one is already pending. This causes the kernel to do unnecessary work so send the signal only once for SEGV_PKUERR. [ bp: Massage commit message. ] Fixes: 9db812dbb29d ("signal/x86: Call force_sig_pkuerr from __bad_area_nosemaphore") Suggested-by: "Eric W. Biederman" Signed-off-by: Jiashuo Liang Signed-off-by: Borislav Petkov Acked-by: "Eric W. Biederman" Link: https://lkml.kernel.org/r/20210601085203.40214-1-liangjs@pku.edu.cn Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -836,8 +836,8 @@ __bad_area_nosemaphore(struct pt_regs *r if (si_code == SEGV_PKUERR) force_sig_pkuerr((void __user *)address, pkey); - - force_sig_fault(SIGSEGV, si_code, (void __user *)address); + else + force_sig_fault(SIGSEGV, si_code, (void __user *)address); local_irq_disable(); }