Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp828876rwb; Mon, 26 Sep 2022 06:26:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ULJjVlL+pen1+701CHQN/Jcel+Dh9/HI78yCdz32Kp78YuGniomEA/VL/1WyYiXHEji0l X-Received: by 2002:a17:907:a0c6:b0:780:bc37:2552 with SMTP id hw6-20020a170907a0c600b00780bc372552mr17820255ejc.314.1664198766652; Mon, 26 Sep 2022 06:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198766; cv=none; d=google.com; s=arc-20160816; b=XYNNx99oAW1Jp6hGnuPL73DqPddmaBlar/vHbx8qmao3+pq6hsAK8EzAAItXf/Nvcj AppPKQ1Ag/KM60ajTuyFQHVbPObZSlB9kzvktczXmWWPNPvd9Ig5CpUJ5hd2USPusE0z QRDKUnafy7l1FeohT5hyg5a5dmPQBaiyBTWGqTf8dB8/H5FtjApBQNrnon9nfdSNsmwe N9entiIyef+gdSY5bmhxv3p0ioVWQf+vRy+KtEvKNRk05TGiPdweHOlQonJtkRZebteM D+LNYdUJzK/q59FKo1rZvznBf5U8+xzzKdvXR2aEkzY32p+Cd1P12iljhm0kNW/sbd6W B3dA== 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=W2XXdGdGtnLc5zckWhmPAe6eS+JFldti4GuR49KxsFE=; b=ecO0u9KpjHSdu1YBHCXtUtHM4cCBAwoRMDmQ+8RPO2VIt1uHWGcVvchHnnwxxl5CYU 3xxFkCW2gGB96El+Ok/RlHShT/jnHm8tl/sCjAxL1kPPjDKK+iy1hV2vShnZbCJOEKLV Rx04Sxqe16a5G0zE8uUlJo58vA5m7aSxSeon1/cCom7aaur3V6AhG2DK6GubFInnJl/C 9a1Id3q/ybKn9jNFFC4B1zCUUvsgN01DNkrw4lVAcZcA20uzNqhsdoda3REHqrPkgnGl DMy/1sl1l5eo8HDQ/mXpQ7KJV3drPqmAOjy1/26PXKrsb4eFgdW+mQ3OSzF/Wo/6QBhn UAdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tiTbE0Ac; 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 er5-20020a056402448500b00457140a6322si5104834edb.283.2022.09.26.06.25.41; Mon, 26 Sep 2022 06:26:06 -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=tiTbE0Ac; 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 S237117AbiIZLCU (ORCPT + 99 others); Mon, 26 Sep 2022 07:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237391AbiIZK7k (ORCPT ); Mon, 26 Sep 2022 06:59:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64635D113; Mon, 26 Sep 2022 03:31:22 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9EC5160A5C; Mon, 26 Sep 2022 10:29:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACD17C433D6; Mon, 26 Sep 2022 10:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188199; bh=zRrMrRABLsN3WrZIDEo2465rJQHnOyEX8cPMpJTlbZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tiTbE0AcM4NFeruLeG1+R98Cj7aPqucYwRWkL9oIq87t155cHFPRJjgpHEgqqSAQt Hlwtie4mud9MKR5Mk0XveKbM6nsOofDgjmMgMIEOYr4GRsj9BTnUQqNPQ3Xz4RT0kp l19JM/HfxaISU2qXjndf5tWUqQXH1hjv+/d6fskU= 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.10 055/141] riscv: fix a nasty sigreturn bug... Date: Mon, 26 Sep 2022 12:11:21 +0200 Message-Id: <20220926100756.441521697@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100754.639112000@linuxfoundation.org> References: <20220926100754.639112000@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 @@ -121,6 +121,8 @@ SYSCALL_DEFINE0(rt_sigreturn) if (restore_altstack(&frame->uc.uc_stack)) goto badframe; + regs->cause = -1UL; + return regs->a0; badframe: