Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp443471iog; Mon, 13 Jun 2022 06:06:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTuv+KM2EB1D3T0VZEg0x/e6WehLlYPzfYp6eRq9HWWM/7buezeqnKBTWUbxpKvOuO6EOQ X-Received: by 2002:a65:5786:0:b0:3fd:7145:ceef with SMTP id b6-20020a655786000000b003fd7145ceefmr40476776pgr.361.1655125525809; Mon, 13 Jun 2022 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125525; cv=none; d=google.com; s=arc-20160816; b=YR2nViV2KLC8kEp5DzQoISK9vtenAw7LGUxrghWDPal6pttdp6cwf+1bQlHFj3AzgT e6TRDSowgvvtlsng/VPJu+wes7/Ew0I4qxftIaQRGK10u0F1irQVjdFjJXEY0vqLy8MM r9mvZG8dnxlPLLCVy7MG2D7sRHq7zQxN4PZMiq2WdAFV2boBQyFnNbh8LBfZW7MwXU8L j5+fFE23ZuNIMuU1VtTZ4ccK3HSSOJ0HK7r+BGhqbe38Fj2NRpw7MoDLHW/Knt/gh89F /4MMckVpHMD1YmvRbt3Dhw4SUKgeBGylj96ixxAfVkPYTxXzDRMB5hh3LQasgHf7Hwlr 4QYg== 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=MJ03mcxBVMBd+OGT8p9YoVotrKUE7fnZidePCPZuqGU=; b=ifeuwG0PTV2LbQC+oSodUVa8LbxSa7oFCzjGmr1zXo/4Em0WjWkVS7uZyQ7BihPLo3 ZBD5lH4BFcMbj/+HjbWJldy5jGpg2drbkDXrlnuNa6ya1k0jvparwUC1SgvlWJmsQVR9 cQbiFBDjeMv5Fm5IbwAAM9cPRN86+kQk4+HOtyuhehA+VZECS81cy/P1Kwd2NgchApdn GMujf/IW0upLOszYl4or00wogBzESZmymlwsdSkrxQKfY1hTvirfn7vUKIgAWw/trM4a 1+Uadrtvl79k3oa3igAo4rlJdjmpCyHN1MQDWQqG5EtRxe/c0FzazgSRGiYeker6RuzB 364Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N9SwkwN7; 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 124-20020a630182000000b003fa63cec349si9407551pgb.832.2022.06.13.06.05.06; Mon, 13 Jun 2022 06:05:25 -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=N9SwkwN7; 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 S1348774AbiFMK43 (ORCPT + 99 others); Mon, 13 Jun 2022 06:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349243AbiFMKyQ (ORCPT ); Mon, 13 Jun 2022 06:54:16 -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 0C3C22F396; Mon, 13 Jun 2022 03:27:58 -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 49D1760EF5; Mon, 13 Jun 2022 10:27:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59E66C34114; Mon, 13 Jun 2022 10:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116077; bh=gyhKNvxoiETnk+TrSOc9Q+QUOEp1CDY03KAvzlYOA1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9SwkwN7NRyz4K/8PWGFyVBKJykf5UIxLxBCU0SP4uTT7QOujNjxBhPsj9AbqafqB 4+ZOUPHwVaZYTLOJLPhF9bu9bVAttrZ8SXlkCGu0cVxA0EwSsmWAwT8O5tJ7BZS+VF 0bBjB+W9wnE0vYZB7hIk3QlyKhdUx+KDzqthKagI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov , Kees Cook , Oleg Nesterov , "Eric W. Biederman" Subject: [PATCH 5.4 008/411] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP Date: Mon, 13 Jun 2022 12:04:41 +0200 Message-Id: <20220613094928.745114205@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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: Eric W. Biederman commit 4a3d2717d140401df7501a95e454180831a0c5af upstream. xtensa is the last user of the PT_SINGLESTEP flag. Changing tsk->ptrace in user_enable_single_step and user_disable_single_step without locking could potentiallly cause problems. So use a thread info flag instead of a flag in tsk->ptrace. Use TIF_SINGLESTEP that xtensa already had defined but unused. Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users. Cc: stable@vger.kernel.org Acked-by: Max Filippov Tested-by: Kees Cook Reviewed-by: Oleg Nesterov Link: https://lkml.kernel.org/r/20220505182645.497868-4-ebiederm@xmission.com Signed-off-by: "Eric W. Biederman" Signed-off-by: Greg Kroah-Hartman --- arch/xtensa/kernel/ptrace.c | 4 ++-- arch/xtensa/kernel/signal.c | 4 ++-- include/linux/ptrace.h | 6 ------ 3 files changed, 4 insertions(+), 10 deletions(-) --- a/arch/xtensa/kernel/ptrace.c +++ b/arch/xtensa/kernel/ptrace.c @@ -225,12 +225,12 @@ const struct user_regset_view *task_user void user_enable_single_step(struct task_struct *child) { - child->ptrace |= PT_SINGLESTEP; + set_tsk_thread_flag(child, TIF_SINGLESTEP); } void user_disable_single_step(struct task_struct *child) { - child->ptrace &= ~PT_SINGLESTEP; + clear_tsk_thread_flag(child, TIF_SINGLESTEP); } /* --- a/arch/xtensa/kernel/signal.c +++ b/arch/xtensa/kernel/signal.c @@ -465,7 +465,7 @@ static void do_signal(struct pt_regs *re /* Set up the stack frame */ ret = setup_frame(&ksig, sigmask_to_save(), regs); signal_setup_done(ret, &ksig, 0); - if (current->ptrace & PT_SINGLESTEP) + if (test_thread_flag(TIF_SINGLESTEP)) task_pt_regs(current)->icountlevel = 1; return; @@ -491,7 +491,7 @@ static void do_signal(struct pt_regs *re /* If there's no signal to deliver, we just restore the saved mask. */ restore_saved_sigmask(); - if (current->ptrace & PT_SINGLESTEP) + if (test_thread_flag(TIF_SINGLESTEP)) task_pt_regs(current)->icountlevel = 1; return; } --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -46,12 +46,6 @@ extern int ptrace_access_vm(struct task_ #define PT_EXITKILL (PTRACE_O_EXITKILL << PT_OPT_FLAG_SHIFT) #define PT_SUSPEND_SECCOMP (PTRACE_O_SUSPEND_SECCOMP << PT_OPT_FLAG_SHIFT) -/* single stepping state bits (used on ARM and PA-RISC) */ -#define PT_SINGLESTEP_BIT 31 -#define PT_SINGLESTEP (1<