Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01B67C433FE for ; Fri, 19 Nov 2021 17:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0DC061B27 for ; Fri, 19 Nov 2021 17:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236813AbhKSRlV (ORCPT ); Fri, 19 Nov 2021 12:41:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:42294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236776AbhKSRlQ (ORCPT ); Fri, 19 Nov 2021 12:41:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E27CE611CC; Fri, 19 Nov 2021 17:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637343494; bh=4rKbk4NlzZTI4czvLnX5Q2qaEfAQvek3EL+aNgzqOTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DD0RIrKk7d1QS2iwHQS5nqb16sksvjNVj3fG7AtwafGrlKDqkEYjALuP3BvnttneJ x4nWPKBCexTArPtRK4B/0/cTvwM+D5kxZZYIN+wduQLNhx272lXF/DrYKPX265HRSg +1JsR3FlrHiaiRQu/UWSB1CTi7iZTapO5lhIEqnQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , Helge Deller Subject: [PATCH 5.10 13/21] parisc/entry: fix trace test in syscall exit path Date: Fri, 19 Nov 2021 18:37:48 +0100 Message-Id: <20211119171444.312607672@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211119171443.892729043@linuxfoundation.org> References: <20211119171443.892729043@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Schnelle commit 3ec18fc7831e7d79e2d536dd1f3bc0d3ba425e8a upstream. commit 8779e05ba8aa ("parisc: Fix ptrace check on syscall return") fixed testing of TI_FLAGS. This uncovered a bug in the test mask. syscall_restore_rfi is only used when the kernel needs to exit to usespace with single or block stepping and the recovery counter enabled. The test however used _TIF_SYSCALL_TRACE_MASK, which includes a lot of bits that shouldn't be tested here. Fix this by using TIF_SINGLESTEP and TIF_BLOCKSTEP directly. I encountered this bug by enabling syscall tracepoints. Both in qemu and on real hardware. As soon as i enabled the tracepoint (sys_exit_read, but i guess it doesn't really matter which one), i got random page faults in userspace almost immediately. Signed-off-by: Sven Schnelle Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- arch/parisc/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -1849,7 +1849,7 @@ syscall_restore: /* Are we being ptraced? */ LDREG TI_FLAGS-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r19 - ldi _TIF_SYSCALL_TRACE_MASK,%r2 + ldi _TIF_SINGLESTEP|_TIF_BLOCKSTEP,%r2 and,COND(=) %r19,%r2,%r0 b,n syscall_restore_rfi