Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2559825pxb; Mon, 19 Apr 2021 08:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnLep5Zr965hFKQAJEptH32qX5JKw+Rl9fZ4Hr14NiziCo8Dsj4Ho5/0qaooHScZw+4G62 X-Received: by 2002:a17:906:6d48:: with SMTP id a8mr23130424ejt.92.1618845932368; Mon, 19 Apr 2021 08:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618845932; cv=none; d=google.com; s=arc-20160816; b=RnTqcKFK4PyqQFz2zTnypMB5nAx3cdefW6Sxi0iSRnPveRqmg6/s1sxGZaYv8zYEiV zxkUP+aQ0qzsO3gYCPQgsUNHgZfeLMc2Psj5NApcr8bMG1M/RAj4nqgTt83SA1jxt1vu VXOBLPRtFFfTxvwZJocHcqIMJ+mi/wt/ORdzou86uycLb1k4Lje4k2eeKVgmoETLvzmm O3i+4T+lIFOe33dhPJt8Xv2FpJFWGncbuA3kKr3tloZ1PsHH7UQ/acKlZxzGUlOR3eLu WYCmYNN6mInBzRiACAVxxUTtqMjPLo6I+j+Pt0yb/ICt3b6iBbohX5xMoN0Co3N7rkhQ SAhA== 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=GRwtluSuLv4un9sUSuPK/Nxuf7cxh+36vKVaz1PRW5k=; b=mpOnNkxEFKUhXBxKTXaSFg7dYjHgiZM1Y/zOe7Bz3m1X45BVF9NeEDGOLSs8ue8Jzy YOpkWnrRxvPEqFCyosV7w8C24hWi3bJGxymVG4HdigfGF3pILnl56nz5C7zdXpuD5WGN CIwC3um5rhuYLY9Bfazpy/pMzV3jll2oLN6AZA5qRe1IKB46Yw3cyalHaepj4EBFF5ib eZwGwNHNxoVb81vrVZGrxkURAEDeOuvA+lv4Q6XjuBM5nC+gGuaMMoZbNtaYtxFnt3kI cWsxHKricmtIOaqUXr0Hq62+0FN36r0qYCsgbkpO90ZWN4oimG1tXZE2eZS5B8GHfu92 Yhgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ejth4XGb; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si11869070ejc.744.2021.04.19.08.25.08; Mon, 19 Apr 2021 08:25:32 -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=@linuxfoundation.org header.s=korg header.b=Ejth4XGb; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240519AbhDSNR3 (ORCPT + 99 others); Mon, 19 Apr 2021 09:17:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:47286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240484AbhDSNOQ (ORCPT ); Mon, 19 Apr 2021 09:14:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65DCB613C9; Mon, 19 Apr 2021 13:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618837967; bh=Byr+fhg5Lf5vgurkOuCBRAGK4/82Kv6/CDnJUn53+ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ejth4XGbNE8dw0/l6YeKBoQewJAbJPjRm16zyY1THDq/MnMdgO94qKnwb0KTZbcwo LKkJM5O8Y89AaQzwhQsHZHPlLXRe6WssFIb0jjwbkPHs7ltT7BHapaSxGCqQyrKfJs mOs0Wx+xsjO8ZrTFWgkiVuKPZr01NRb95RrzFH0k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fredrik Strupe , Russell King Subject: [PATCH 5.11 119/122] ARM: 9071/1: uprobes: Dont hook on thumb instructions Date: Mon, 19 Apr 2021 15:06:39 +0200 Message-Id: <20210419130534.209813854@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130530.166331793@linuxfoundation.org> References: <20210419130530.166331793@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: Fredrik Strupe commit d2f7eca60b29006285d57c7035539e33300e89e5 upstream. Since uprobes is not supported for thumb, check that the thumb bit is not set when matching the uprobes instruction hooks. The Arm UDF instructions used for uprobes triggering (UPROBE_SWBP_ARM_INSN and UPROBE_SS_ARM_INSN) coincidentally share the same encoding as a pair of unallocated 32-bit thumb instructions (not UDF) when the condition code is 0b1111 (0xf). This in effect makes it possible to trigger the uprobes functionality from thumb, and at that using two unallocated instructions which are not permanently undefined. Signed-off-by: Fredrik Strupe Cc: stable@vger.kernel.org Fixes: c7edc9e326d5 ("ARM: add uprobes support") Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/probes/uprobes/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm/probes/uprobes/core.c +++ b/arch/arm/probes/uprobes/core.c @@ -204,7 +204,7 @@ unsigned long uprobe_get_swbp_addr(struc static struct undef_hook uprobes_arm_break_hook = { .instr_mask = 0x0fffffff, .instr_val = (UPROBE_SWBP_ARM_INSN & 0x0fffffff), - .cpsr_mask = MODE_MASK, + .cpsr_mask = (PSR_T_BIT | MODE_MASK), .cpsr_val = USR_MODE, .fn = uprobe_trap_handler, }; @@ -212,7 +212,7 @@ static struct undef_hook uprobes_arm_bre static struct undef_hook uprobes_arm_ss_hook = { .instr_mask = 0x0fffffff, .instr_val = (UPROBE_SS_ARM_INSN & 0x0fffffff), - .cpsr_mask = MODE_MASK, + .cpsr_mask = (PSR_T_BIT | MODE_MASK), .cpsr_val = USR_MODE, .fn = uprobe_trap_handler, };