Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp588824iog; Mon, 13 Jun 2022 08:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7XAB2Ol84znDH8PKBvrFiGO7MvF8BVEkfRJAOPVSSjuWasPONDvGwwEZzHvKpRFcYZy7t X-Received: by 2002:a05:6402:2921:b0:42d:e086:fd10 with SMTP id ee33-20020a056402292100b0042de086fd10mr377410edb.254.1655134883749; Mon, 13 Jun 2022 08:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134883; cv=none; d=google.com; s=arc-20160816; b=MQii5R2CZdujdCmpmf+ocpcDtVos6njQmZPfz44ntlLiUU6qJ3ElWi0Wekdp8K2sRH xOHldy1cNVwPRm/ZIQkFN9vIBbkfNrAJScq2JE1mOA1AqF176L5skaeTjusQYU0+IYzH Jn8jU7k5U5D00FBGD+GTHYBnyDEd9hy5gN1LwIjdtxj5hv6b76CRdFLigj3xb/1heLVR NE/VYCDLKGy7jvxsJACfOcQSFUz4jmaWqi/Y5G+ZDsQio/szEBwOyIPIQUliPQ7ci2bc Kl8w23g8qqc5qRCPvOAmQj9Wpuj8fiGK0kmMMt9iKowXEhZzj2Y4elHhUIe5Ke/bPLvB CBwg== 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=BfB30ovv/M6+UIb1fYedc46THXLPm6dw2jV1lq/8FGk=; b=VQoe1LiMwFLKM1eR+kjL2w2lRNAyWCtLyfpwz7+MI2V9xYo9fD9jst9qwnihbLmbYq UxXdB3oVuZUT3D0fUPFiHazCoU39v2tY3axcxQ6eLOUJySINObYG0HkwDXVtJt6WUZaq UB6nqeztRlW7Bkxgm4wv46BKLQ1fp38r5YdSY4UTRJrwg5p07NftOvr9RR3UCIGaii8H m6HpxgdW5yq7xvHrqw41C9heO9byujdcfDfpBdnPNQYcMPsPcIanDaYGOpbRe3BLjGk6 Qjiu2N2iFkDDJe/hjJcxaRHF1S0miGkGqGoM0mBMK5lFnxREa/VgmsmNHvN7+EDwPwOJ /EcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YPPHYSlQ; 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 nc12-20020a1709071c0c00b007117f5643c5si9556468ejc.267.2022.06.13.08.40.59; Mon, 13 Jun 2022 08:41:23 -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=YPPHYSlQ; 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 S1345169AbiFMKfp (ORCPT + 99 others); Mon, 13 Jun 2022 06:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345053AbiFMKdz (ORCPT ); Mon, 13 Jun 2022 06:33:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA0727FD5; Mon, 13 Jun 2022 03:21:59 -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 B053E60AEA; Mon, 13 Jun 2022 10:21:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B964DC34114; Mon, 13 Jun 2022 10:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115718; bh=brhw5xYnVa2tXsvuUIt7E9SYRYpa+zTktYSX5ZoQUT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPPHYSlQs3TRpWigj3ziGEa+blKAo1RB8YBNS7+FzXjRCmqdXHLSRE5qXGvv4NH3A SswzaBabBgmVO0G8enk3sG9lfcdtOQw4p1mssH3RKija6iCxQuvm9SNKtsFLyhZQXJ YP2vIlds89AgSAkKfgDnWMBToHGZqQWLEioXQ/CQ= 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 4.14 004/218] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP Date: Mon, 13 Jun 2022 12:07:42 +0200 Message-Id: <20220613094909.333855456@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@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 @@ -35,12 +35,12 @@ 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 @@ -459,7 +459,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; @@ -485,7 +485,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 @@ -40,12 +40,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<