Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3407188pxy; Mon, 26 Apr 2021 00:37:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoXnzI9JFcHisnGmpIxzWi/4LimP2PhKdQBQIACncF2+kZXoaGNTtgKnw/xvcxvS2osZbj X-Received: by 2002:a63:515:: with SMTP id 21mr876624pgf.178.1619422626275; Mon, 26 Apr 2021 00:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619422626; cv=none; d=google.com; s=arc-20160816; b=SlhJBUMbGNBk/zgUCi77Q0arxGQxlG5HKPkNm+324EOq2T6p5ufv9ZzsA2K/xTHnea dNywagqkDx/uz+ir8VjmAA1pH8l28Xq/kHrxWB0E/2pXbT2/0cmXvTc+eivFROXnjqfA xQxwTPmxZp+ipfghzNwiKN6aQq3umMK/QUPxgS2klKNi16rFqYOy+5pDM40sIGHNB9dN nSJ/B3I4hIglwSqksljFRj+r09Cnb1xhd5UL2suqP9yeeS6QlkADCOwPm0LRHqD8FW/b LKRzfcmhLS8M0xzEoYK5vDVolWZGgbCw+9C8NTQv3R8Jk0mNjyjXoqrvefQ7viLuPS0n LYNA== 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=2+EHK+S4gJ6M7Ek0Mmhhf4YwITf+CVObWGebxJ+oCRs=; b=B0AM26Lu8iX3W+6mgkcu6GPY81iuiJ4vP1TbhMVJPIo0e56qpOnpPUH4NGEz0dpbIS zOLvVLnkpjSrmDmN/p6Am+hL4Qly8mAiaqoDoDXTl0quAuwBXyKxmfVyRKBhEKj5/yRo UzvKTeHfxNxI1ip734tcn5FVM3nyT+XWxCx11xuuYPLDAlUIuR9qgMPXkpZvF1C2SMw/ CTxDNd18cqGfT7Rk5uySVE0OyYbUsyk385CDwimyO3d5OvugI+ekU6m7caE9Pn9lwczi itZ+ZWMbdYM2qtVWy6m05iZNICGo6ufr8L+LF+gFploQUvbyKzyUA/pZl/JHNEMFRkPG Mmhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=esxUFgkt; 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 x18si16231438pfm.308.2021.04.26.00.36.53; Mon, 26 Apr 2021 00:37:06 -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=esxUFgkt; 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 S232881AbhDZHhG (ORCPT + 99 others); Mon, 26 Apr 2021 03:37:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232882AbhDZHgF (ORCPT ); Mon, 26 Apr 2021 03:36:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AEDB6135F; Mon, 26 Apr 2021 07:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422421; bh=mVyWi9XG90EchzaJQHS0kyf10Ks7lxWF4bcLEboImsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esxUFgktd+RxU6FQCWWWpK9Snvj7dcaWysWr6EoYhXJsXelPxiEjlxg6qMCiOC7fl CI5qwwuGfPt2t6fsGQ2gpgaO75Ig+JkCsELBB9cMrbnfseOC6UXz6sLKRl/nJoLr6v O+uxaBfSRltQy0riEYZkET2FBpJMODT+6N50YzTg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fredrik Strupe , Russell King Subject: [PATCH 4.9 22/37] ARM: 9071/1: uprobes: Dont hook on thumb instructions Date: Mon, 26 Apr 2021 09:29:23 +0200 Message-Id: <20210426072818.005764582@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072817.245304364@linuxfoundation.org> References: <20210426072817.245304364@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 @@ -207,7 +207,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, }; @@ -215,7 +215,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, };