Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3416730rwa; Tue, 23 Aug 2022 04:32:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5yDB90jNwqLSX+cuRmgBS3vq1bhF9VsRlN1P93z95PRL4UnP14nD9+aJlvfZIPh+cnnBSp X-Received: by 2002:a17:90b:1d83:b0:1fb:6795:5cc9 with SMTP id pf3-20020a17090b1d8300b001fb67955cc9mr1919874pjb.162.1661254371481; Tue, 23 Aug 2022 04:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254371; cv=none; d=google.com; s=arc-20160816; b=FrODc2YQq9GoVBgTvKq8xKI9trtE7AUgM68fZRcT79SFqjQvkQWpqyC5J9uVwHCbZl Sxlcj5pC5C2LGlxFTWPM5qJNQIfcR1mkKXbJ1zDQryz3R4FDNhAv5CphrvJCfDjfMPl9 vZ0siEzM/ISM7tDnidMwvWBfKhBcuyq2Sukn7iFYP+zTAJmcSvzeVXXq6dSs8YJF3GM1 X1ZfHNPYsin7yhWL/uF8dHeBpQMJ0b4z89y61hQh5V9AJMsUqw7UaPNQwIUDvlXMQkkm GhicN9rh6xBvv9hI2vL1oGUU4UgJphN1K9UFInwFLIXn3Jgzf3HYJ2g6a2ZxWkQZ/cav v3IQ== 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=4kuePEELNrO5DeECftQv/PScOzPZo/Zg8/tOHfYRoUU=; b=Za8ZyItfGAPTT/r9U4rm39IvnF38JsWZgvyIiMCVGaYXnPdoIiy4EmXJsKfRqeaTDj 4KkRb19ArVspRih/O3hSPZk7nMSQolaH2UVi6uqbx4OAW1rXxFmuapeP+/udwR1FNzRp 9ytlF1i8vUkf+03aSjMzmleiefQ15N7rXlVeIlP/Ht9XFRyJO4TFfH0M7vPzr0QHLfyr XPW98cz9go1pc07IoZlxbFmK++BAhTa8b+AbgqCKvLVwaT1jjmC4V5+dWPqYsJOymzgo pruaKcrmi/J8IxeqZe54UWyBAb42faJIZRORdrS+63nkFWAoY0bdDzVv0LMis29u7GSZ cdjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2wdoEnJg; 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 u23-20020a627917000000b005360313c324si12523730pfc.103.2022.08.23.04.32.40; Tue, 23 Aug 2022 04:32:51 -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=2wdoEnJg; 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 S1356487AbiHWLDA (ORCPT + 99 others); Tue, 23 Aug 2022 07:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357261AbiHWLBw (ORCPT ); Tue, 23 Aug 2022 07:01:52 -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 4DDDA86FC3; Tue, 23 Aug 2022 02:14:31 -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 D871A60F54; Tue, 23 Aug 2022 09:14:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF3BC433D7; Tue, 23 Aug 2022 09:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246063; bh=fxlNh0LwhOpWUkF19exROe077tMNe7vdcr/NJnAVD5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2wdoEnJgZAOHjE3ZgcYDKyj40L/KOxRUyAMOBcNx3zOlBXstinjTps8m1OAs0PTJX TD09RAkffRaqYQZI1hXBooo1QWafWk6jhOZ72syBrd+6xDqPcTsswu4L8RukKV1AFB 3zVKPXcSotgR9hOXm+j6EsQsMhJJ8ehT/OPSHVRo= 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 246/287] nios2: traced syscall does need to check the syscall number Date: Tue, 23 Aug 2022 10:26:55 +0200 Message-Id: <20220823080109.423177007@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 25ba820ef36bdbaf9884adeac69b6e1821a7df76 upstream. all checks done before letting the tracer modify the register state are worthless... Fixes: 82ed08dd1b0e ("nios2: Exception handling") Signed-off-by: Al Viro Signed-off-by: Dinh Nguyen Signed-off-by: Greg Kroah-Hartman --- arch/nios2/kernel/entry.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/arch/nios2/kernel/entry.S +++ b/arch/nios2/kernel/entry.S @@ -255,9 +255,9 @@ traced_system_call: ldw r6, PT_R6(sp) ldw r7, PT_R7(sp) - /* Fetch the syscall function, we don't need to check the boundaries - * since this is already done. - */ + /* Fetch the syscall function. */ + movui r1, __NR_syscalls + bgeu r2, r1, traced_invsyscall slli r1, r2, 2 movhi r11,%hiadj(sys_call_table) add r1, r1, r11 @@ -287,6 +287,11 @@ end_translate_rc_and_ret2: RESTORE_SWITCH_STACK br ret_from_exception + /* If the syscall number was invalid return ENOSYS */ +traced_invsyscall: + movi r2, -ENOSYS + br translate_rc_and_ret2 + Luser_return: GET_THREAD_INFO r11 /* get thread_info pointer */ ldw r10, TI_FLAGS(r11) /* get thread_info->flags */