Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp828658rwb; Mon, 26 Sep 2022 06:25:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6of+EXh/EJlDIB0VesGHMxfDvVxAqVmJzsQcq+IHC/Jn5XB7/OUwPnUbzjvq6c9ZNrDk0e X-Received: by 2002:a17:907:16a5:b0:782:8fd0:88f6 with SMTP id hc37-20020a17090716a500b007828fd088f6mr14876563ejc.476.1664198753595; Mon, 26 Sep 2022 06:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198753; cv=none; d=google.com; s=arc-20160816; b=FCjR/Ul2Ou90WWXp7EP+BTCkv5gOxOETLKinBFwfXxX0TTJRhZ1hIKoSDdDwWrHK44 SzeVkboiIjClMkx63QRRWapsz9fMeoGokkai8xUGZpxq72lMFu7vcpjiEWzxiIr2/FPj 9k64Ssnv2ljrb2akY1XyLkhbUGrlD8znx1SQDbRVMZjyNgJ+P2fbuSe171Jp+CJOHsTC hEcnQd/71wqfJ5ej3BSzkGh7B3r/l2jFaHVBBmcnYe8J7wY4KOGDf8aYOrwonHrKUize XogXx45Q8JSKZ7SgcJvbHfIEP/HH8Bct0GNcQ4+qIliZhbit0/8GaQN2uRoUyqUGkwUJ GrYQ== 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=P0MpznvU0s3Gr+zd+jXplAzT6ciU8kxifmXiAH7cFL0=; b=ztR3IHzZRatkz9ur3jgsMq5k5DnlLozesq8Z6WAYQPJXDAtAv1+fD5QBKbCLPyoZes WGCepaA2FvQFBviORMfJiqtD/hdgKa/3Rbt0EPgQU0awhkZxzRHx/LCTrZzemiYuF4LK niDrilGtgirFlIR4TZ6CyVexl+ZMTfq8OM3/WF/iOGKi7uU8IfGgLyPaZpe6FxUHuzvx wm3Et+vsUIaUDNLAT0iMw4VFYoilxw8xVDJKhrvZa7F0QTrCwunx3IlsnOGTGwy7gWPA Nv2Lxk3i05X2Uhk6zWyVThWduxLr8yCnTY9VnAT6vf0b7T/EhU+zAVTVhwNVCaiuVuQy lORw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wjSi6Q2T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji5-20020a170907980500b007708617c995si10078347ejc.339.2022.09.26.06.25.28; Mon, 26 Sep 2022 06:25:53 -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=@linuxfoundation.org header.s=korg header.b=wjSi6Q2T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbiIZLlr (ORCPT + 99 others); Mon, 26 Sep 2022 07:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238293AbiIZLk6 (ORCPT ); Mon, 26 Sep 2022 07:40:58 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8154D268; Mon, 26 Sep 2022 03:45:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8C69BCE1101; Mon, 26 Sep 2022 10:44:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26D39C433D6; Mon, 26 Sep 2022 10:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189042; bh=4OhIFTaTvw+Ay+oPVwGCPzJwcA7iAszt7mvg8/EjYfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wjSi6Q2T2Fg8kG5knXz8Ee7PD3txm6c6IZsEBSRHtT0y0Tgt9jx5gU9foYO7y+XOC aYIG8AqdC4YLL61Ru43epFm0AnP347hbSKaoNhwfuVNMOGKpNhTRakSVeCOaxIMsCi Vpiyf3BAec9JLBIy517fX+3RspT30cMcAXEwrtOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Palmer Dabbelt Subject: [PATCH 5.19 054/207] riscv: fix a nasty sigreturn bug... Date: Mon, 26 Sep 2022 12:10:43 +0200 Message-Id: <20220926100809.036039036@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Al Viro commit 762df359aa5849e010ef04c3ed79d57588ce17d9 upstream. riscv has an equivalent of arm bug fixed by 653d48b22166 ("arm: fix really nasty sigreturn bug"); 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 Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/YxJEiSq%2FCGaL6Gm9@ZenIV/ Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/signal.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -124,6 +124,8 @@ SYSCALL_DEFINE0(rt_sigreturn) if (restore_altstack(&frame->uc.uc_stack)) goto badframe; + regs->cause = -1UL; + return regs->a0; badframe: