Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3293277rwa; Tue, 23 Aug 2022 02:08:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR7DFyL/9eLX/u44oAiRe3Iu5PN+gFo7+srsblEQbb2ablhx8L34Jk1iSRTSppIQgnvOxesX X-Received: by 2002:a17:906:7952:b0:73c:e38b:5642 with SMTP id l18-20020a170906795200b0073ce38b5642mr13499886ejo.582.1661245725971; Tue, 23 Aug 2022 02:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245725; cv=none; d=google.com; s=arc-20160816; b=w564y/qy6IcM6nq2U4eJdM71cYCyE41QLjA8TYdn2WdZj/iJpXOATzsdOxZtOu9fDH kw8q4baJeGtVgSKyweaBgQJYaw3+LZ1Gu8YHMDtnvW54Mws06qUq03gyFdstsvJbw+kK wt1jG9MHCciE1/KJW4yBgkvvfN6QoV18j0W2+Tn9UyNIQoMKsRO0ROxk4gUeoXw2+ajf L8zHVvlpUlrnOT/jRUUN2p8KD2SzrMGDUj6a3O/YR2YsqYIt8KgYGOuSFREC8tiVoE7+ cpX7lUtQt4VddczDFybx5ZBbEvxqAcKTjIApVl8suG3pgTFxtgJcw5maCqdy1iPSgl2x /44Q== 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=RF/pZ/xzUoDAkXS48LQnhdscUmLqmEhea6awJtYU1LPFCVM0lryKlImwg3dBlKipbe UBUV1TswxD7G7ThtH2U+iM1gAtziWnukA3xe7RdkcLhXjQt4XW9me2Z9hPj8/qnZ56UU 6ySIVV9kX7yRN+j1kA/HdwX45hJlrd7Dm58jDv0Pv1Sd4LkRKzj/AAVJLX02/bsIQ0vl GKYY/At1sjQkaYbSZBNmMGzInKq/x+JwjSW7T3e4PTp6TbFCb1YU0hZjzMPwGpR2NM2t EKYEwad+obBSElP/a6KBjPSGDm53jTyTii7+R6FfVvu6Sc4dKvIkpOpxjAUqbW06TLU5 qpgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1kbk+onf; 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 m11-20020a170906848b00b00730a9386823si9353849ejx.1009.2022.08.23.02.08.17; Tue, 23 Aug 2022 02:08:45 -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=1kbk+onf; 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 S1345931AbiHWIpR (ORCPT + 99 others); Tue, 23 Aug 2022 04:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344922AbiHWInX (ORCPT ); Tue, 23 Aug 2022 04:43:23 -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 785DB6E2C2; Tue, 23 Aug 2022 01:20:52 -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 EE65261367; Tue, 23 Aug 2022 08:20:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED536C433C1; Tue, 23 Aug 2022 08:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242800; bh=UlzcKidXqLG4HmGSEd5gPKAWOKksFX8ym+DBmzhofjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kbk+onfIiZY/cWbb194lOiE6bhDKsq3DowCYlgHGSFGcAIgMPz2v5v2gFxfEpkeD Y9QhEGn8nBIf61hzpOu0b/BPVhO33+sZ3h+oXEvIAjdqw/v+xfTGch1GftYe3k7XVA D8InHKGdkdqxp8Scf+r/kJ+ENVf6tmqQE5WxNcmQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Dinh Nguyen Subject: [PATCH 5.19 171/365] nios2: add force_successful_syscall_return() Date: Tue, 23 Aug 2022 10:01:12 +0200 Message-Id: <20220823080125.368529246@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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: