Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2478241pxb; Mon, 19 Apr 2021 06:43:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpenppF+sJBUG/w+KCLk6SP3I/JR4cwGmA9z4SZYxOHv+FmMHrp64RMYCX58gr2QZ7dTcA X-Received: by 2002:a17:906:4881:: with SMTP id v1mr2983012ejq.383.1618839813306; Mon, 19 Apr 2021 06:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839813; cv=none; d=google.com; s=arc-20160816; b=XGYxfn5ya3vd0U6vT25JcFE9aJxcTFYaq8Ume2jJkRA6rgwcmu5bd09cWJ33ut4O31 SneC8hIJLd1t3Xhuv9UrwOwHDVTBLfVPosYR/nUUk6oR/X3/f1yFrozJ6p0SKoXBKNXb O1qiEIdvZzyeYe0xyhiSEh2Dtoqrb2k1JIm+3UU+sjFyX2G5IH0iWoLjmXJDYf82s1Ts KU+gzSjqSlBYP5EG5DZaVKjhdrhw+6z6cOUeOvkpH0sPax2vUkxTZ8AessGZq+rODT4k G5yK4+vCk9hfTB1gc+6DXsQPDoDaeF9yzjqCQBSFIfC8xNWjGThkZuLZbweZ2PrBrpM5 axuQ== 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=A3fnJUqLUUuXctjvUAIbn9N+EDWcF3yIW8aKJnM3B0EYjMpJE5SEI22DHjfxsFY2sR km5jcuD1HPes4HTLmRMjgsZYxd0WyzhETal1Mwg3CxCcuaCuSVkdHuzNYSz7G7HMT+13 IuirYnMBvkLG8LPaI3JTmBAoUS67N+ZS8FMr6onXNoumDCC3ZxmLwCSuavmxJqGuXQmQ 5pT1GtEKMwMf4Em+zKPgB4s02K/CAg5UQ7f6gHBdB/fiIgi1lLKq14iV/7MuQaGWJz/V mNSIgRF+CfKldYPxTLiw0wzDhoi/Vggumxm4vCsB/qw++pV0VxWdCxPlZfCP0mJ/skBo 7jdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sKH4XM1u; 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 a18si12188329ejb.116.2021.04.19.06.43.09; Mon, 19 Apr 2021 06:43:33 -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=sKH4XM1u; 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 S242510AbhDSNjV (ORCPT + 99 others); Mon, 19 Apr 2021 09:39:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:34806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240998AbhDSN0F (ORCPT ); Mon, 19 Apr 2021 09:26:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26D38613E2; Mon, 19 Apr 2021 13:21:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838469; bh=Byr+fhg5Lf5vgurkOuCBRAGK4/82Kv6/CDnJUn53+ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKH4XM1u2yJrovzQ+dVybK1PaBT7Rb/++OwLhlp2hfp4+1cvOA3wi9l6Zq7uPaP9s fAiohNU6xI/PzKISzq76tuv3bxjTti4uAPzUQI1cu0SJjIOQdo5MeNNQJw0e176K4R gvaNvMJ86TjWX9FwNHjRNwqCx2klYmSrUOVdV4S8= 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.4 72/73] ARM: 9071/1: uprobes: Dont hook on thumb instructions Date: Mon, 19 Apr 2021 15:07:03 +0200 Message-Id: <20210419130526.166823795@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130523.802169214@linuxfoundation.org> References: <20210419130523.802169214@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, };