From patchwork Fri Jun 19 14:31:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 224256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F491C433DF for ; Fri, 19 Jun 2020 14:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F6E620A8B for ; Fri, 19 Jun 2020 14:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577633; bh=fJO8fHnBcnDtUp6PCEnbtaSTCLAD7BEUJgnPM31buks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Ie9fbIOVwDMWnSzZ3rOCD37XDLnmGQCGcIzITgnK+bKrIWRHba2/i/fBt+GJV17oX 19pbXl374lbVh8nrWnZPh/ARDGsdKvuCScVMXJnPsUIpWlm0Tjy2wIa1kqsyE8N6Dj 7/MVwFLAvywoSfd3hpyAN3Ww4mVs7Lmam26yEcVs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388159AbgFSOkc (ORCPT ); Fri, 19 Jun 2020 10:40:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:58418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388146AbgFSOk1 (ORCPT ); Fri, 19 Jun 2020 10:40:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E99302070A; Fri, 19 Jun 2020 14:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577627; bh=fJO8fHnBcnDtUp6PCEnbtaSTCLAD7BEUJgnPM31buks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/HxibU/Vx3iovKnXxJ7JxyP+Jwa3AX3ZmzK2QAA9HheOfGawVR/aaRs7emlrS8MO elQUWaNSHYvqNcqaP+MCCqs08YrMwTiaUMM4s0Q2FtkuyyEbEtBkeb7++BIzp18MGA IibhNONt720d7D15AD0ZbfsMCcEkMKGyDdP4Gop0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleg Nesterov , Fredrik Strupe , Russell King , Sasha Levin Subject: [PATCH 4.9 005/128] ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook Date: Fri, 19 Jun 2020 16:31:39 +0200 Message-Id: <20200619141620.422726711@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141620.148019466@linuxfoundation.org> References: <20200619141620.148019466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Fredrik Strupe [ Upstream commit 3866f217aaa81bf7165c7f27362eee5d7919c496 ] call_undef_hook() in traps.c applies the same instr_mask for both 16-bit and 32-bit thumb instructions. If instr_mask then is only 16 bits wide (0xffff as opposed to 0xffffffff), the first half-word of 32-bit thumb instructions will be masked out. This makes the function match 32-bit thumb instructions where the second half-word is equal to instr_val, regardless of the first half-word. The result in this case is that all undefined 32-bit thumb instructions with the second half-word equal to 0xde01 (udf #1) work as breakpoints and will raise a SIGTRAP instead of a SIGILL, instead of just the one intended 16-bit instruction. An example of such an instruction is 0xeaa0de01, which is unallocated according to Arm ARM and should raise a SIGILL, but instead raises a SIGTRAP. This patch fixes the issue by setting all the bits in instr_mask, which will still match the intended 16-bit thumb instruction (where the upper half is always 0), but not any 32-bit thumb instructions. Cc: Oleg Nesterov Signed-off-by: Fredrik Strupe Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index ae738a6319f6..364985c96a92 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -227,8 +227,8 @@ static struct undef_hook arm_break_hook = { }; static struct undef_hook thumb_break_hook = { - .instr_mask = 0xffff, - .instr_val = 0xde01, + .instr_mask = 0xffffffff, + .instr_val = 0x0000de01, .cpsr_mask = PSR_T_BIT, .cpsr_val = PSR_T_BIT, .fn = break_trap,