Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1242412rwn; Thu, 15 Sep 2022 12:34:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YIeQ0FD/62voGtZvX1PAVDDCwptVb631BkJckqgQRvE1cn9EvvdjIveBf04I7rp8UjnM4 X-Received: by 2002:a05:6402:2201:b0:44f:443e:2a78 with SMTP id cq1-20020a056402220100b0044f443e2a78mr1181533edb.76.1663270463701; Thu, 15 Sep 2022 12:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663270463; cv=none; d=google.com; s=arc-20160816; b=Guw2VEaZ00CrQm8f4dzvm6Okyq88droN5jvap8QBK/jqrdQ+H6F9pkKH7S9qq7nphf adtuONX9bU0QEWbazuJEKzMAGs+vWIcvoCYQRcaAzm4wYIDsFD2dxFJDJ1L/ztWzfLGf Mc5xGlSxMohdJqzy6hrpESQTMYdSAD8P42k9BAHBm5iZHw3G6wWV8dKYD5Ggw9PDQeaO JRudWVp6ApV0HxlLxpEkhcrthl45ywqLC1CAf5b96UeRqRTrOGDYoWzJ2+hVVXAy7ZC2 I5nZk8jhh3gX9zdSQN0WLGFP65vUSxz5xNcvbNI5HXvhIrhSS/Irrrwjapv/oMiQLkBW hKBg== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=nzN4TyiTu/X8WAurRhkbXC36H2L4MWW2PoQoLXhqLcE=; b=WuUTYSS5fUbwOIuKoBsuRrA8NntHlIGWhEajN/LbcrKyxUi8gPthc5uNwWJVXDm03M amk/h/PicmHuVX2t1Q+wFFgnt8e3EgqPF1Zi/V3LQl1NpUDR5pahqNWezarBtfvoo3Mr ynN8zx5FRrpKUENSU6vaw8xlgdf6cnpmxlck0B//8HVtDMcgX06e5hw8kzUtKMJ+OETZ LsxNTUTMs+DMOC8ZZDu32Fy4MRzGnHOoq5Jef6eBX81bMVDdfCIbd1i0b7xEUPyjMt7y AD3L/6aDVgP4PEW0g5I8c6fIV3CcdBD5lfODcxy+Rvv5ma1PuXKp5owoMcQW3UNU9eYD Y5CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=LZDW87FS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb40-20020a1709071ca800b0077b1d8d772bsi17935645ejc.34.2022.09.15.12.33.53; Thu, 15 Sep 2022 12:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=LZDW87FS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiIOSsk (ORCPT + 99 others); Thu, 15 Sep 2022 14:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiIOSs3 (ORCPT ); Thu, 15 Sep 2022 14:48:29 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8D09C1F2 for ; Thu, 15 Sep 2022 11:48:23 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id b23so18922243pfp.9 for ; Thu, 15 Sep 2022 11:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date; bh=nzN4TyiTu/X8WAurRhkbXC36H2L4MWW2PoQoLXhqLcE=; b=LZDW87FSIwPstY1qzL4UsH73KhoyRifwSXjD+rWJo8ryGkYwNJedTxWXbrRqpGmdWs 3mL+jU2nvuEC2N2CpSSKqAKzIGAyXHRQc1xqr39T3sIxIC4wSy12/JYHHT9XwJ4zjBWk kiYqOdLDESYNv55bWp29QjiXG5a97teLGK+wRlvZc6BF3L6xWhSnAQescnqTChcPywvu Rm5uxKCXp5/giu+k3wm/uunVGS8yR23XEymAsBddd9mEcrbKbEch7xc7psMnRNmplqjx lbMLwwAIFHYTqdSqQS5OU6z8Iw72MBhK+dwpOYcoG+eDgHzq1MKTFjeu5lxONyR0ti5b C7wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date; bh=nzN4TyiTu/X8WAurRhkbXC36H2L4MWW2PoQoLXhqLcE=; b=HyoAcnzxDF9K9BNvY3WXC0v+QFlNOIWMcvCmKmt/QUPCT1+7j07ynPKLsYuo6YertQ pB2Bq1brj7oN5LQiXw5Ft+yQB4qWp6AFvwBcrE+8cTS1dxSoqcaOVxYXx1TzYrgagzB4 3pC+LHzo6d1i5b940Oj4bytQt+KEeRsNWw4RQ/kbyxOf+P9RupR8A2JoELnzZVYomuxf aSRZT1JC5uBXhD9ixzLXNRXPp7iZ9/b01YBvZx1e0bf0DmAwxgpn9qWjsJTvXpHGyvEr FcHuXTCmexe9ZjnHXB3TBiU4SGtflbqxNAkg7eVLhfKKHvyXez/eoMSxYd2+sSxNMLPP AtPg== X-Gm-Message-State: ACrzQf2jm/Jk/lbzkUTEkhS3e81HLLIzuo4w0vyb2aUT1j8iBz16SiKN /yDoyj5Oj9vftUSHRvY3Dp/ikQ== X-Received: by 2002:a63:1304:0:b0:439:ac9b:34af with SMTP id i4-20020a631304000000b00439ac9b34afmr1062185pgl.464.1663267702450; Thu, 15 Sep 2022 11:48:22 -0700 (PDT) Received: from localhost ([172.58.176.196]) by smtp.gmail.com with ESMTPSA id l11-20020a17090a598b00b001ef8ab65052sm1996135pji.11.2022.09.15.11.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 11:48:22 -0700 (PDT) Date: Thu, 15 Sep 2022 11:48:22 -0700 (PDT) X-Google-Original-Date: Thu, 15 Sep 2022 11:47:59 PDT (-0700) Subject: Re: [PATCH] riscv: fix a nasty sigreturn bug... In-Reply-To: CC: Linus Torvalds , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org From: Palmer Dabbelt To: viro@zeniv.linux.org.uk, ajones@ventanamicro.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Ping? Does anybody have objections? AFAICS, the bug is still > there... Sorry, something's gone off the rails with email and this thread doesn't show up in my inbox (not even any of the replies). I tried to patch together this reply manually so hopefully it works. This is on fixes, thanks -- trying to debug this one would have been a nightmare. > On Fri, Sep 24, 2021 at 01:55:27AM +0000, Al Viro wrote: >> 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: