From patchwork Tue Feb 19 21:19:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10820797 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 6641F1390 for ; Tue, 19 Feb 2019 21:22:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552AF2D7FE for ; Tue, 19 Feb 2019 21:22:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 533992D84B; Tue, 19 Feb 2019 21:22:25 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E5B92D84A for ; Tue, 19 Feb 2019 21:22:24 +0000 (UTC) Received: from localhost ([127.0.0.1]:55142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwCqN-0004v1-6G for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 16:22:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwCpg-0004bl-T5 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 16:21:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwCpf-0001N1-QK for qemu-devel@nongnu.org; Tue, 19 Feb 2019 16:21:40 -0500 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]:33998) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwCpd-0001Aw-P7 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 16:21:38 -0500 Received: by mail-lf1-x142.google.com with SMTP id u21so15965144lfu.1 for ; Tue, 19 Feb 2019 13:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=phystech-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=XNEQy1HdW/vIbfOTZPCA7zr6n7zz8oyFRbNCPXHsOkc=; b=0llh5/zs1kCPCSiMwN8vwk7Sm9+hvCS/ygE4zFX1qWJT5+KqGA9Amx3bNGez12TdSV FQwMFKDNcgyyCDY7Rd46zfJiZgssIzhFPfQcyFXUk4aaxiDiT0xzcYVHLMvX3nHWR5HR VjSShjejDv7Qv7vfC5LzwJZfmkEQV9sXQ1ZC7ymkbZ7+RkpMEantnSJu9LdQQ9RZUuWd d0c+v45d1SKXRWQS60P5T3bEUtT808ZzXNKt6xOcG0G74OX56xREzqCDY9M1YqYycexM l9TIW/AK+Km/d1a86o5W8VYsgMNVWxjtlEBHU9oClxD7IvFRj+Hx2A1sI+qESRmeUMN5 X8qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XNEQy1HdW/vIbfOTZPCA7zr6n7zz8oyFRbNCPXHsOkc=; b=GUcnpe8zd3abZhZvFI0bRyN/SZMw9ro+tLinr/bRCw7m7dxW5Nlvr93Ba5/J0m5+HJ 8ssqM2ua0jQd+jd+cjHSrRuHN6emYnNAuewWozjZFPtnskmLG3jHBKz4JiWaOsHNxFoU vth+n/mesdMP7krUyFFh5ho0fXCBNWIj8BVsnrTS3iRiAiVcXymtGpilGYKeSIscObe5 gv5H9+FOQ8kDnt7RW7ol4G1aEfzpyii4Z16ic3EOq/JhIH8zledZ7GnsbVyvxETf+xts lCm3s/pT+ZwM4d7XXCp5nb0+tHpZ8LbdDdR108PNC2UeXgTm5N3ms/cfYla84rEnuGhL JnxQ== X-Gm-Message-State: AHQUAubhAvnwhLwhoKnLKxGZJGTq8VAB5mZzfjK9eWnXh4Tb/wQ69bLs OPfQor0RTRGkaEIGfhKvYMVQEw== X-Google-Smtp-Source: AHgI3IbR4oX8NsAyech/WPiWlzVjTrrsnmZoXW9vdO0Y5JjNd3bEiATt23cpOQqnM4yM8oahpTMvVQ== X-Received: by 2002:a19:911c:: with SMTP id t28mr18723684lfd.78.1550611271146; Tue, 19 Feb 2019 13:21:11 -0800 (PST) Received: from localhost.localdomain ([93.175.11.132]) by smtp.gmail.com with ESMTPSA id e18sm1975686ljb.2.2019.02.19.13.21.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 13:21:10 -0800 (PST) From: Viktor Prutyanov To: peter.maydell@linaro.org Date: Wed, 20 Feb 2019 00:19:36 +0300 Message-Id: <20190219211936.6466-1-viktor.prutyanov@phystech.edu> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::142 Subject: [Qemu-devel] [PATCH] contrib/elf2dmp: add kernel start address checking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, rkagan@virtuozzo.com, Viktor Prutyanov , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Before this patch, if elf2dmp failed to find NT kernel PE magic in allowed virtual address range, then it assumes NULL as NT kernel address and cause segfault. This patch fix the problem described above by checking NT kernel address before futher processing. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 1a45eaf565..1bfeb89ba7 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -524,6 +524,12 @@ int main(int argc, char *argv[]) } } + if (!nt_start_addr) { + eprintf("Failed to find NT kernel image\n"); + err = 1; + goto out_ps; + } + printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase, (char *)nt_start_addr);