From patchwork Tue Apr 30 11:20:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot for Kobe Wu X-Patchwork-Id: 10923327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83F1992A for ; Tue, 30 Apr 2019 11:32:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71EDC28AAB for ; Tue, 30 Apr 2019 11:32:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 659CF28AAE; Tue, 30 Apr 2019 11:32:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 58B1028AAB for ; Tue, 30 Apr 2019 11:32:45 +0000 (UTC) Received: (qmail 27674 invoked by uid 550); 30 Apr 2019 11:31:02 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 14096 invoked from network); 30 Apr 2019 11:21:13 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x3UBKijg1347492 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1556623245; bh=C3t0slo8rzkJUyCXpbSIjvhOc4r5emWnLyOAWlZs5yE=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=oP4zRwJ1czyBEH/vhk20eXQZMX4bvYf/RyvH0pwHj+FatGAIki+jZf7iKUXseE0+g MmwvV3v6VShRpqHdTi4crfvklL9M8oMScw//xnGmZ4FZBv57s6OwjIBdUTChBQhegZ xrd2drw0VE7S6xl0pGcc2zXYjycv4vU9tBGVi8CEpjkjeo51+b6gwwXJEWyA98qWyC DXbonRhXXR7+kWfRcn8+0EtJZ97P3YRkSD6CtUYh0Oxz3HI4vzFmuQjbexLXBqmbdN bSTWJQUAC2a35+xMFha0zPYYYtYk0wXkqTy5XsmIz9QxYlkVNHpOZTU+ylmhQB1Uwf Nyb67qOnaaoew== Date: Tue, 30 Apr 2019 04:20:43 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f Sender: tip tree robot From: tip-bot for Nadav Amit Message-ID: Cc: linux_dti@icloud.com, kristen@linux.intel.com, bp@alien8.de, deneen.t.dock@intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org, akpm@linux-foundation.org, riel@surriel.com, namit@vmware.com, mingo@kernel.org, rick.p.edgecombe@intel.com, tglx@linutronix.de, dave.hansen@linux.intel.com, ard.biesheuvel@linaro.org, hpa@zytor.com, torvalds@linux-foundation.org, luto@kernel.org, will.deacon@arm.com, kernel-hardening@lists.openwall.com In-Reply-To: <20190426001143.4983-9-namit@vmware.com> References: <20190426001143.4983-9-namit@vmware.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/kgdb: Avoid redundant comparison of patched code Git-Commit-ID: 86a22057127d1c0462a18901421bf1ff89491392 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP Commit-ID: 86a22057127d1c0462a18901421bf1ff89491392 Gitweb: https://git.kernel.org/tip/86a22057127d1c0462a18901421bf1ff89491392 Author: Nadav Amit AuthorDate: Thu, 25 Apr 2019 17:11:28 -0700 Committer: Ingo Molnar CommitDate: Tue, 30 Apr 2019 12:37:53 +0200 x86/kgdb: Avoid redundant comparison of patched code text_poke() already ensures that the written value is the correct one and fails if that is not the case. There is no need for an additional comparison. Remove it. Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Rik van Riel Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190426001143.4983-9-namit@vmware.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/kgdb.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 2b203ee5b879..13b13311b792 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -747,7 +747,6 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip) int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) { int err; - char opc[BREAK_INSTR_SIZE]; bpt->type = BP_BREAKPOINT; err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr, @@ -766,11 +765,6 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) return -EBUSY; text_poke_kgdb((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE); - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE); - if (err) - return err; - if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE)) - return -EINVAL; bpt->type = BP_POKE_BREAKPOINT; return err; @@ -778,9 +772,6 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) { - int err; - char opc[BREAK_INSTR_SIZE]; - if (bpt->type != BP_POKE_BREAKPOINT) goto knl_write; /* @@ -791,10 +782,7 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) goto knl_write; text_poke_kgdb((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE); - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE); - if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE)) - goto knl_write; - return err; + return 0; knl_write: return probe_kernel_write((char *)bpt->bpt_addr,