Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1115609pxb; Thu, 23 Sep 2021 18:59:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBNCL6BDoOFEp+UxGGcFp3uRb2NfjybQyNahuGGWQE2JTBWVZ4o9nr5RPZuyCEJhvjsMwz X-Received: by 2002:aa7:c0ca:: with SMTP id j10mr2258163edp.146.1632448756198; Thu, 23 Sep 2021 18:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632448756; cv=none; d=google.com; s=arc-20160816; b=m9xoA0qooxrUB3+sHvs5TBeadq+Kf5tYEaAQF4W2+NovbWc7nwDMfBJQ69/l0qUWj6 M4y/+ZWx0ERuBQG4olajlQCxUo0+sIvD9NReZAU2OkXDLau7edi2ledeU28ZbXLCd8l8 Ri5hmb6RYJjLV7+MRxVkOe4i8aHWii6C7GZtvqy6CuxTUlRhcIIG1sf+plh0QHNYy2Zi 2/yKpIoaPnHeO9Sv7AS0CNfbcbXAvuAOyWMrPDOzHoW/aBzhjrJrlSjywWpLGeHRdDeY Y5YqZzd+iBVALnz2HtLNP+hWprsnn3OIm0j1DnF2/SRJPI3oj+/2N44Rtk7hynQJlvuz Dp4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=1FvkSP+Bn/XC3cMc+6WU1RydCrP69XtweyAY7tq6Lew=; b=qr+OgtpG+LglU/k79K5KGBCIPj2/q+U+rf+CQnxZjltHhM54I3eDe2GRdyvxOTt/Vd zE7g8D++i+gFVO56GD66TjAVWzpEcXe0l/zWiyUvX5evecPDHtHAkSsP2MahHBN2bPZB mCwILl0zAoGqCXMEgMQKjN2fPaQwX21q8QrL/Ts71irJO7JHLHcVPQ5YM86AkxvSrB5I ZsxjhsGPlAErtag2HYGEeD69uWdy0lFLLg9mt63in6+HNifvBIEvbn4lcGILsWH841LK 2DeaZ7HLItlxyatW26yZN53Qb62swz5KLATRhIifn3X5OKMXd8eI7slU9Lc3zxy6I68C dLUg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp16si4267616ejc.236.2021.09.23.18.58.52; Thu, 23 Sep 2021 18:59:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243799AbhIXB5E (ORCPT + 99 others); Thu, 23 Sep 2021 21:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240863AbhIXB5D (ORCPT ); Thu, 23 Sep 2021 21:57:03 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5696FC061574 for ; Thu, 23 Sep 2021 18:55:31 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTaQx-006pXk-LM; Fri, 24 Sep 2021 01:55:27 +0000 Date: Fri, 24 Sep 2021 01:55:27 +0000 From: Al Viro To: linux-riscv@lists.infradead.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org Subject: [PATCH] riscv: fix a nasty sigreturn bug... Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org riscv has an equivalent of arm bug fixed by 653d48b22166; if signal gets caught by an interrupt that hits when we have the right value in a0 (-513), *and* another signal gets delivered upon sigreturn() (e.g. included into the blocked mask for the first signal and posted while the handler had been running), the syscall restart logics will see regs->cause equal to EXC_SYSCALL (we are in a syscall, after all) and a0 already restored to its original value (-513, which happens to be -ERESTARTNOINTR) and assume that we need to apply the usual syscall restart logics. Signed-off-by: Al Viro --- diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c index c2d5ecbe55264..f8fb85dc94b7a 100644 --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -121,6 +121,8 @@ SYSCALL_DEFINE0(rt_sigreturn) if (restore_altstack(&frame->uc.uc_stack)) goto badframe; + regs->cause = -1UL; + return regs->a0; badframe: