Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3473621rwa; Tue, 23 Aug 2022 05:28:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kpz2eK+8YS8i/i5+ujf7l6oSc/w6leKbO3Wekd/YeEbwB5ZXRo6GOOpsc6DuiX5iHbAq2 X-Received: by 2002:a63:1a53:0:b0:41f:5298:9b5f with SMTP id a19-20020a631a53000000b0041f52989b5fmr20223270pgm.244.1661257690523; Tue, 23 Aug 2022 05:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257690; cv=none; d=google.com; s=arc-20160816; b=KpT6RPBHPin/DjJbrwZfJduW+8z8GZcAY4UG+HmHruBV+fkSpgfcdkTAstAqOdXjbg njd7o/cRalS4l1elW8i6beVVDbYfMCgcKFmlhZekyGKeEbieM5TBJLwHzSBlfTogEHae FiMTsCrAh+sG4rUY6ws67o1fuTI1PcJ5EGBF7eCyqLcNrgp2fFua1LNlMxX1K+SNfvUO q26GY/ZG9jwN3PQlmrtxypPIogs81Wo0A/b+iRb8B7gEqLCSv91opMhKRjUR8YXGIW+X 9bNBtKMBS/HHIfP6Sn22Wo/q4FQ+j4f8u2CS7aaiZzu5YwuaWJldDLOjce9e5rTqPkZD 7KHA== 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=pW1K3U+DqeAavedg5ByadFr1TdlYbLMF/bePKW5akG5lviPtWz/cARvLm38M7l7wns wEEbnLq1aGYII8/aGov7RpmVsFvap9zJGkwWBXk3X6SnUwxkfnW8vCQ3+qY3aZRQ7X8L t3YDqr/17JCcAMUyHHeboXKZ+iNoZdLL8cl+ZPPxC9aG0dtucKA2n9hh88qGpUh+/X4P b/Bbh1vktomIYNAZmsXi0Bs5UqYVxHfkNp7RA3a/uyBvtSPIim81MFmQxdGnkj1lfrWs 0c6+WVVLZ1NFVzH8jmuWES5ANiwwqrytDvqOO7lfEU/Z6OU65f2WGH6Bn7JsSO/9K/vs HQng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2AkRMm35; 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 k127-20020a636f85000000b0041b8696d9e2si13854151pgc.88.2022.08.23.05.27.59; Tue, 23 Aug 2022 05:28:10 -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=2AkRMm35; 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 S1353823AbiHWKSW (ORCPT + 99 others); Tue, 23 Aug 2022 06:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352417AbiHWKHc (ORCPT ); Tue, 23 Aug 2022 06:07:32 -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 DE6D34A813; Tue, 23 Aug 2022 01:54:14 -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 7C40C614E7; Tue, 23 Aug 2022 08:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DA5EC433C1; Tue, 23 Aug 2022 08:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244853; bh=UlzcKidXqLG4HmGSEd5gPKAWOKksFX8ym+DBmzhofjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2AkRMm350zKwdMSalu8qz6JCvfRMeIBgOOm2RkaFxL6zD3HwvuXQxu5wxCsdLGHGs Zrt3Q4pHioDH1+fS1eSWVCYUrfQ7RnvIA/0roeaZ+dKAijzRUCd3kRmyS9xmBvJXpL sVMqpOTC/zzCnjSUMHrLw97W7u8hcppJ+KNRrJ1A= 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.14 202/229] nios2: add force_successful_syscall_return() Date: Tue, 23 Aug 2022 10:26:03 +0200 Message-Id: <20220823080100.858856218@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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: