From patchwork Fri Jul 18 22:51:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 4588151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7D55EC0514 for ; Fri, 18 Jul 2014 22:54:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8CAB20103 for ; Fri, 18 Jul 2014 22:54:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3CDF200C1 for ; Fri, 18 Jul 2014 22:54:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8H10-0005go-W6; Fri, 18 Jul 2014 22:52:34 +0000 Received: from mail-pa0-f50.google.com ([209.85.220.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8H0y-0005ed-HW for linux-arm-kernel@lists.infradead.org; Fri, 18 Jul 2014 22:52:32 +0000 Received: by mail-pa0-f50.google.com with SMTP id et14so6196389pad.23 for ; Fri, 18 Jul 2014 15:52:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=1qTdf5jnndLXS9oDgZxvYmD5daAyxp7PgTgslF7hUGY=; b=lPD5P2Pf8oSvm9In0/qFF+pozT5RZkXAK/EvLHg53ZI7rZgv/38FNYnESzkDnJVrVz +iW+kUwU9cmBb+61emVeyI6IWnfIbZX72AvDSejPvnwks53jUCgY+fZ8xsM5ORHcLWRe lcF0pqN27Rtl0gTJiDsKTjPAgzsEt1HTr8FKNZmrkBM36QqdAgBg7IHF18Zpgk+o4xSE 60tlBelT29As0gKwtTx8UcDGgeA34/P0A2AMkBxG54JfR7VnpP9JjcWt8AHptmzBeK35 FsZGnQwlsICO1DUrLwwHWircgYDhDyw3801+Cq1s+H2Xrrz5f/ePPVXunJpWnxD6JE0L SOuQ== X-Gm-Message-State: ALoCoQktIo9t0crCCaD8w+Ttlrss+24buaQzv1LBj25cWbudyAeQJAmeG+hIVqTlPhkKvFtaEd9T X-Received: by 10.66.254.166 with SMTP id aj6mr8764629pad.11.1405723931177; Fri, 18 Jul 2014 15:52:11 -0700 (PDT) Received: from mew.guest.dropbox.com ([205.189.0.165]) by mx.google.com with ESMTPSA id zc10sm27545271pac.46.2014.07.18.15.52.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 15:52:10 -0700 (PDT) Date: Fri, 18 Jul 2014 15:51:31 -0700 From: Omar Sandoval To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: Don't oops when userspace executes kgdb break instructions. Message-ID: <20140718225049.GA11937@mew.guest.dropbox.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140718_155232_598163_F154EA19 X-CRM114-Status: GOOD ( 10.18 ) X-Spam-Score: -0.7 (/) Cc: linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't break into kgdb when userspace executes the kernel break instructions (KGDB_BREAKINST and KGDB_COMPILED_BREAK). The kernel will oops in kgdb_handle_exception. Signed-off-by: Omar Sandoval --- The following program will immediately cause a kernel oops: .globl _start _start: udf #65006 @ KGDB_BREAKINST arch/arm/kernel/kgdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c index 778c2f7..a74b53c 100644 --- a/arch/arm/kernel/kgdb.c +++ b/arch/arm/kernel/kgdb.c @@ -160,12 +160,16 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr) static struct undef_hook kgdb_brkpt_hook = { .instr_mask = 0xffffffff, .instr_val = KGDB_BREAKINST, + .cpsr_mask = MODE_MASK, + .cpsr_val = SVC_MODE, .fn = kgdb_brk_fn }; static struct undef_hook kgdb_compiled_brkpt_hook = { .instr_mask = 0xffffffff, .instr_val = KGDB_COMPILED_BREAK, + .cpsr_mask = MODE_MASK, + .cpsr_val = SVC_MODE, .fn = kgdb_compiled_brk_fn };