Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3474639rwa; Tue, 23 Aug 2022 05:29:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR553hm6MABUI4lyTnygfBUrXdlvE3Vvhi/AszBIBTtolUBrVI6+9/juBwbqCjjWoyTzV9eo X-Received: by 2002:a17:906:8475:b0:73d:97f9:47ea with SMTP id hx21-20020a170906847500b0073d97f947eamr2616614ejc.695.1661257746505; Tue, 23 Aug 2022 05:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257746; cv=none; d=google.com; s=arc-20160816; b=ToTKftvdxQlJuRaj+U1eiA20wn5LKhHRSjqGYV0wn6EK6wiXCVt4XdnjfV3Lr/XIPV rpZRZF1eava0qXraPjwrdXmUAxCd2w+GgtQvY5wF+ohHHJfHf9kqNiNA01ydBF2a9Xds UkRsV48ceuvDA26mUdtoho5qkoHCsjczPiYpBbRIlMcC7rbxWGt8Pqy8hIoFJkidPHZ4 ve6OizK2CCEg567xlsX+NaXUmsjazCIXkrtYk0jrNloRw19owbJ6DhGyh11xoKLnBl0w z1h37hOnM+a4h3SDLxLrPvp1DoUwrX26dOT3UY2XP/WHA6rQMmIFTJn81WmahelylIDG B6qA== 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=NICjwE8kvX8Mz+euvbOgREOdRqSCcEkFz5P4B4Zc8GQ=; b=jqlyiYkEhBxUIrTpjwVfY8t5gZaouPo5NFum+cEsRlbHIbvS8eQyxjCGFE2osZjXCp kxdBkpEtvelThvzlWLNrfARxwMvBKnZIYw3scS1KfbX6JOvmPpzZYibp05dStydVEmiC bOtxQ5twG1gPrRbKRmylHTlD5J4uqYpvnoJqWJnzxmkKb0Zmm/r9czf+I0ascHrQLHOr Xb4aSYHPIc9lFX3Us5IxM+LTBLWCKnPSJRrVOqMGJDfNc+qXnmXPikxKejfSipE1WgQ9 h3qwj9PfVsJf18nhupiu2cYFVMcnJNc2AqEsbq6xgbZPXS5/oGTFyMLZ5j6UhGgQyA7j +y3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iMHYqbjA; 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 t29-20020a50ab5d000000b0044691fbf10dsi1769474edc.117.2022.08.23.05.28.40; Tue, 23 Aug 2022 05:29: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=iMHYqbjA; 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 S1357119AbiHWK4b (ORCPT + 99 others); Tue, 23 Aug 2022 06:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356994AbiHWKwu (ORCPT ); Tue, 23 Aug 2022 06:52:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C359ABD6A; Tue, 23 Aug 2022 02:12:57 -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 9821D60F54; Tue, 23 Aug 2022 09:12:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DDE1C433C1; Tue, 23 Aug 2022 09:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245973; bh=UlzcKidXqLG4HmGSEd5gPKAWOKksFX8ym+DBmzhofjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iMHYqbjATnTNp3WW1N/FA9j8Gtdm2GSWf3RDa5wONZ2x6t7ZvDWLZkO+Zryly67Tj lG5SlVw3fpJ3VVyPRLjxDnx5T6kBlEsZ3vyKKGJUm3/gDPuONr6A7JlvXezAeTagDh WDOb9Q/donnNuypI1wQropOM/z5MTiPdTeNEI8UU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Dinh Nguyen Subject: [PATCH 4.19 249/287] nios2: add force_successful_syscall_return() Date: Tue, 23 Aug 2022 10:26:58 +0200 Message-Id: <20220823080109.556316374@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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.1 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,T_SCC_BODY_TEXT_LINE 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 fd0c153daad135d0ec1a53c5dbe6936a724d6ae1 upstream. If we use the ancient SysV syscall ABI, we'd better have tell the kernel how to claim that a negative return value is a success. Use ->orig_r2 for that - it's inaccessible via ptrace, so it's a fair game for changes and it's normally[*] non-negative on return from syscall. Set to -1; syscall is not going to be restart-worthy by definition, so we won't interfere with that use either. [*] the only exception is rt_sigreturn(), where we skip the entire messing with r1/r2 anyway. Fixes: 82ed08dd1b0e ("nios2: Exception handling") Signed-off-by: Al Viro Signed-off-by: Dinh Nguyen Signed-off-by: Greg Kroah-Hartman --- arch/nios2/include/asm/ptrace.h | 2 ++ arch/nios2/kernel/entry.S | 6 ++++++ 2 files changed, 8 insertions(+) --- a/arch/nios2/include/asm/ptrace.h +++ b/arch/nios2/include/asm/ptrace.h @@ -74,6 +74,8 @@ extern void show_regs(struct pt_regs *); ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\ - 1) +#define force_successful_syscall_return() (current_pt_regs()->orig_r2 = -1) + int do_syscall_trace_enter(void); void do_syscall_trace_exit(void); #endif /* __ASSEMBLY__ */ --- a/arch/nios2/kernel/entry.S +++ b/arch/nios2/kernel/entry.S @@ -213,6 +213,9 @@ local_restart: translate_rc_and_ret: movi r1, 0 bge r2, zero, 3f + ldw r1, PT_ORIG_R2(sp) + addi r1, r1, 1 + beq r1, zero, 3f sub r2, zero, r2 movi r1, 1 3: @@ -276,6 +279,9 @@ traced_system_call: translate_rc_and_ret2: movi r1, 0 bge r2, zero, 4f + ldw r1, PT_ORIG_R2(sp) + addi r1, r1, 1 + beq r1, zero, 4f sub r2, zero, r2 movi r1, 1 4: