Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1741014pxb; Wed, 20 Oct 2021 10:47:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMcIP86Gy0m7mJYJBX0LKlnOaJec4+iw70Rb0x3eKDNPShx/fy9jpxxHdepWQAgZDILm+c X-Received: by 2002:a05:6402:141:: with SMTP id s1mr447181edu.317.1634752060809; Wed, 20 Oct 2021 10:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634752060; cv=none; d=google.com; s=arc-20160816; b=Tc0JIm2+6MaSFiu5mViwNNCbHIf61U6E39uXdrxLAIzKHYPhs/d+cz+EIlS2+m//oM 9bqANQ3xJJjVAs66O8/hVM6edDxQcaY0SF0cYR1ubwHUGlZnlFTG+BQDjgLYtziW/ZmS l7MjilmmBm3koMumCUaIifr5tGnnwA5cR4yTExAbVmuVlrbCjINiw5Gg9Y9zdU1H8Xq6 I+tsJKUCioQzH3IigpD9xQoHxvKJJl5ABmdIfsqhL7PcwDN1qiJih/3NCaZg+EcZoTV1 Fk/T6i0kUzY/exZFJXLw+1AibH/Np3i1SGQ6H5AKA8VmUFnXIz/5lnQrLP8yipn4sPIa JEDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=ZrXqr410dEaVZlxiWBYp2njMwXU3vvlK6fECO64TKlc=; b=VR0tdf35ZpHvBDHTOCpPlnVVV6/jzfxPDOccZ1tAZoQkR2U5DRRzOq/Hr6KtxwXa+t 36mG2vA138kEoo3JA0ubZ56b9DTa0f2XL/HseV7Dte7EduwwvQ75oPRadqZ3HnTiTaqb qAVqHfRmB3EnvxUeF6iuCv4S1Q9xdMNQz9Z+y13QW7Br5ZtmDKgMyhlA6c9/6UfT4Lpn pihkcB9vywHOBVjAiYQeMj3+IrZXTxJqItdyRa3IaKoPVxBKHvigTJMFLVMQyzrlVUh2 xYQ+8ucE0du9+XzYcMf9I+a96e9sDxd8QoutyoVPDxtRt94QffQIRmB/i7TjxH2IVyZc Yu4Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si3498301ejz.88.2021.10.20.10.47.15; Wed, 20 Oct 2021 10:47:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbhJTRrO (ORCPT + 99 others); Wed, 20 Oct 2021 13:47:14 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:43294 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbhJTRrJ (ORCPT ); Wed, 20 Oct 2021 13:47:09 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]:50190) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mdFe2-00EwHS-Kv; Wed, 20 Oct 2021 11:44:54 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95]:47894 helo=localhost.localdomain) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mdFe1-001NdN-JO; Wed, 20 Oct 2021 11:44:54 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Al Viro , Kees Cook , "Eric W. Biederman" , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Date: Wed, 20 Oct 2021 12:43:52 -0500 Message-Id: <20211020174406.17889-6-ebiederm@xmission.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <87y26nmwkb.fsf@disp2133> References: <87y26nmwkb.fsf@disp2133> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-XM-SPF: eid=1mdFe1-001NdN-JO;;;mid=<20211020174406.17889-6-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18qGfvNDey5Nh58/KQ3Bf/D8SdnRQ8Fcy0= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa02.xmission.com X-Spam-Level: *** X-Spam-Status: No, score=3.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,T_TooManySym_02,T_TooManySym_03,XMNoVowels,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 1.5 TR_Symld_Words too many words that have symbols inside * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 317 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 4.0 (1.2%), b_tie_ro: 2.8 (0.9%), parse: 0.67 (0.2%), extract_message_metadata: 13 (4.1%), get_uri_detail_list: 1.05 (0.3%), tests_pri_-1000: 22 (7.0%), tests_pri_-950: 1.07 (0.3%), tests_pri_-900: 0.82 (0.3%), tests_pri_-90: 63 (20.0%), check_bayes: 62 (19.6%), b_tokenize: 5.0 (1.6%), b_tok_get_all: 7 (2.1%), b_comp_prob: 2.2 (0.7%), b_tok_touch_all: 45 (14.3%), b_finish: 0.77 (0.2%), tests_pri_0: 202 (63.7%), check_dkim_signature: 0.39 (0.1%), check_dkim_adsp: 1.60 (0.5%), poll_dns_idle: 0.26 (0.1%), tests_pri_10: 1.70 (0.5%), tests_pri_500: 6 (2.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 06/20] signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL) X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Today the sh code allocates memory the first time a process uses the fpu. If that memory allocation fails, kill the affected task with force_sig(SIGKILL) rather than do_group_exit(SIGKILL). Calling do_group_exit from an exception handler can potentially lead to dead locks as do_group_exit is not designed to be called from interrupt context. Instead use force_sig(SIGKILL) to kill the userspace process. Sending signals in general and force_sig in particular has been tested from interrupt context so there should be no problems. Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Fixes: 0ea820cf9bf5 ("sh: Move over to dynamically allocated FPU context.") Signed-off-by: "Eric W. Biederman" --- arch/sh/kernel/cpu/fpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/sh/kernel/cpu/fpu.c b/arch/sh/kernel/cpu/fpu.c index ae354a2931e7..fd6db0ab1928 100644 --- a/arch/sh/kernel/cpu/fpu.c +++ b/arch/sh/kernel/cpu/fpu.c @@ -62,18 +62,20 @@ void fpu_state_restore(struct pt_regs *regs) } if (!tsk_used_math(tsk)) { - local_irq_enable(); + int ret; /* * does a slab alloc which can sleep */ - if (init_fpu(tsk)) { + local_irq_enable(); + ret = init_fpu(tsk); + local_irq_disable(); + if (ret) { /* * ran out of memory! */ - do_group_exit(SIGKILL); + force_sig(SIGKILL); return; } - local_irq_disable(); } grab_fpu(regs); -- 2.20.1