Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp864897pxx; Tue, 27 Oct 2020 02:20:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWvq8C3Gp1+gDSY18HuTAxAD5huxA151/K8Ax9Q0XxUk5iEJfxhb97BC5kuRsxRXOzLhhc X-Received: by 2002:a05:6402:32f:: with SMTP id q15mr1207548edw.230.1603790403804; Tue, 27 Oct 2020 02:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603790403; cv=none; d=google.com; s=arc-20160816; b=jH/8OFKxuDqZ/bl/D8PrJlIIeQzOB1M48ZK+OEPx74trNdyeAyfTg77I7akTh1+tJz cDMNLBxrGDWKptscCBEgYJ0GFIOerzOXK4TFNctyLNcQ0xgWwCG9pW9HlI7G5r0VnHWK esgeV8uCchxdsouQpt45QETk4vnMLviSb27pUdGManemSTT61E4j/G3EO9OToQOjoyJ0 stsQDHFMFVp0qiOGQywtXVdO/yMmJv0ztUc9vEYNjQXSggpbIAr3X6m/OqbTr+huk6gt rrjq2LTkxXcSrx7BAw0u9zfui6Kzwnxner7y94JjW8rOBs006S5oQmTwrjgd6UOzuyZr 0law== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fjpSDzciY7tuC6p8R+bpOLpNPgWJUZK2VOd9trIl/UY=; b=OVFzoHThjps4UQKA6C41bRTulQJAC5LsWwqI53Taiq1MyhP28o88jLali+LXC7LMKQ oNay3NDtcykLVXVbG+xMlTFi6wLq8GI2NJpt4WXLnaLskY2ICOSOA/o/I1V7ylJuKdvN 3HWxqecSdmCDXqu25vQ4JnWzvann9X3d0xaXJOVH5hNWCWLkJnx9pP1/CSug9YULL9jO 615ZNHbDcdIDu8RAd2epUOcUeB08nBp7M914SM+rc5bXUd3aApjRv7A99SKvN+BNN1Hb uu7AOCdcri1Se2YJeRP8oaQwyCVxV8PA9DcsS5ToTIFAcX4DcLMjBMXDVj4XAVFM7iNn LwPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m2CugDGR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si308978eds.191.2020.10.27.02.19.41; Tue, 27 Oct 2020 02:20:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m2CugDGR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408667AbgJZXtV (ORCPT + 99 others); Mon, 26 Oct 2020 19:49:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408617AbgJZXtM (ORCPT ); Mon, 26 Oct 2020 19:49:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DC3B2075B; Mon, 26 Oct 2020 23:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756152; bh=U4B/0X6tZ+S10/tnV+8pBx5isrKe4N4+lJJrH4AokzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m2CugDGR8OpZg7p5CJQGgGpEsCuuQZ+TOqo9OjhjMXvkSjikNbjQMkJmkvdmz4AVc 7MBjvvD/GVs5+k/7XL3Mo9NWIyPU8SFXLTGkj6FWYaeXNwLTfajpNdv1oo9gzquveW xufd3vbXtn4JvlUeTJNNSyRCpB42am9pL8VUq+GU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ravi Bangoria , Pedro Miraglia Franco de Carvalho , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.9 005/147] powerpc/watchpoint/ptrace: Fix SETHWDEBUG when CONFIG_HAVE_HW_BREAKPOINT=N Date: Mon, 26 Oct 2020 19:46:43 -0400 Message-Id: <20201026234905.1022767-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ravi Bangoria [ Upstream commit 9b6b7c680cc20971444d9f836e49fc98848bcd0a ] When kernel is compiled with CONFIG_HAVE_HW_BREAKPOINT=N, user can still create watchpoint using PPC_PTRACE_SETHWDEBUG, with limited functionalities. But, such watchpoints are never firing because of the missing privilege settings. Fix that. It's safe to set HW_BRK_TYPE_PRIV_ALL because we don't really leak any kernel address in signal info. Setting HW_BRK_TYPE_PRIV_ALL will also help to find scenarios when kernel accesses user memory. Reported-by: Pedro Miraglia Franco de Carvalho Suggested-by: Pedro Miraglia Franco de Carvalho Signed-off-by: Ravi Bangoria Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200902042945.129369-4-ravi.bangoria@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/ptrace/ptrace-noadv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace-noadv.c b/arch/powerpc/kernel/ptrace/ptrace-noadv.c index 697c7e4b5877f..57a0ab822334f 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-noadv.c +++ b/arch/powerpc/kernel/ptrace/ptrace-noadv.c @@ -217,7 +217,7 @@ long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_inf return -EIO; brk.address = ALIGN_DOWN(bp_info->addr, HW_BREAKPOINT_SIZE); - brk.type = HW_BRK_TYPE_TRANSLATE; + brk.type = HW_BRK_TYPE_TRANSLATE | HW_BRK_TYPE_PRIV_ALL; brk.len = DABR_MAX_LEN; if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_READ) brk.type |= HW_BRK_TYPE_READ; -- 2.25.1