From patchwork Fri Dec 1 13:09:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaiwan N Billimoria X-Patchwork-Id: 10087029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D4736035E for ; Fri, 1 Dec 2017 13:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28BB12A00D for ; Fri, 1 Dec 2017 13:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CFF12A52B; Fri, 1 Dec 2017 13:09:30 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 82CE72A00D for ; Fri, 1 Dec 2017 13:09:28 +0000 (UTC) Received: (qmail 1955 invoked by uid 550); 1 Dec 2017 13:09:26 -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 Received: (qmail 1915 invoked from network); 1 Dec 2017 13:09:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=u8RLlvWYPm3aTSWwugv2VDd9tn2iwKIpqq+rzOGk0bA=; b=ZmCbI1mjGVcJtDZc7pz6bw8AHxbNQRx+/Fk5cMhsiNXLqqpb7JILdOpuY6hzqc2G6j DlZ2i1KyL7ohMlfCLW0FsnY69/2bPBeawUYAeImSTU28b8PTiorvJ2oCO78reMK2jotw vhUdsmtOtLYNWopEADfp6FFvsp4lMIJYKsHnpaHQpx1j4eeGNde1J9DlWTBErM5hCt2e 1FfenMbNllL86aaztZeKI2gTbH4vT1G0DQkeSJngA18dMCWotsWCTAI6ZH5KKXTpQPbg lJUtIB/2F1u5Mzdqz5Rysx12wBPyCJBHRG2+EMZcShA6QuVNkBFwcfTdnHjHM4DWQTNQ OdnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=u8RLlvWYPm3aTSWwugv2VDd9tn2iwKIpqq+rzOGk0bA=; b=P0sGkiBISRRyHUKJFHBuPlSejBay95NT37ZLi4CQhp6h0sGuAcXTxEPto+J8puZ3QZ nPf0ObqVLXEaGnjj7upP6M1iZIA4aUc6IafnPtfodEVhO3gMBq9VXwLk+amuA9HbqVWF dw+6jfR1wbT885mcJRF+xPd0xwVOSz4lEHG2iMRFfqZ3JpkUzMPX8ixPJkPJH8Q2GvVI G6N2h1u3QRZsVtLq6UdXzDfwWs4vKcfA7uY4YualGjzTtUsx+wfMiWGFKwepYIWp7N/4 OWowv/xtgza0C9X7h3pKxz0uLGL4Zo+bXVkTbO6c3it9MADMgKhocoQLjkJ0wcBXbNBR AEdQ== X-Gm-Message-State: AJaThX7IiHJNM8NFQSob8FNqNkHSKLNiXkfsnnGDIrFXUTGYSNAClOYp n5nOwjUNAL1KjaGkYe49CKs= X-Google-Smtp-Source: AGs4zMaAm/aVRTwEcNxpOqD2kLJnM5FIw1WzTPljasaoBRz4DAfJdnc4dobDljL1IWj9wy8CPi7XdA== X-Received: by 10.99.108.5 with SMTP id h5mr6025070pgc.113.1512133753716; Fri, 01 Dec 2017 05:09:13 -0800 (PST) Message-ID: <1512133747.17323.3.camel@gmail.com> From: kaiwan.billimoria@gmail.com To: "Tobin C. Harding" Cc: Alexander Kapshuk , linux-kernel , kernel-hardening@lists.openwall.com Date: Fri, 01 Dec 2017 18:39:07 +0530 In-Reply-To: <20171129204812.GE6217@eros> References: <1511850724-2381-1-git-send-email-me@tobin.cc> <20171128211003.GY17858@eros> <20171129101640.GC6217@eros> <20171129204812.GE6217@eros> X-Mailer: Evolution 3.26.2 (3.26.2-1.fc27) Mime-Version: 1.0 Subject: [kernel-hardening] Re: [PATCH] leaking_addresses: add support for 32-bit kernel addresses X-Virus-Scanned: ClamAV using ClamSMTP Hi, Applies upon the previous one in this thread. Found and fixed some minor issues with light testing on a 32-bit x86. (I realize this isn't an ideal description, forgive me!). Have also emitted a 'noisy' warning on PAGE_OFFSET fallback to 0xc00000000. Signed-off-by: Kaiwan N Billimoria --- scripts/leaking_addresses.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index fcf1ebe0f043..3a8691a642c8 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl @@ -160,7 +160,6 @@ if (!$input_raw and ($squash_by_path or $squash_by_filename)) { if (!is_supported_architecture()) { show_detected_architecture() if $debug; -} else { printf "\nScript does not support your architecture, sorry.\n"; printf "\nCurrently we support: \n\n"; foreach(@SUPPORTED_ARCHITECTURES) { @@ -267,7 +266,7 @@ sub is_false_positive sub is_false_positive_ix86_32 { my ($match) = @_; - state $page_offset = get_page_offset(); # only gets called once + state $page_offset = eval get_page_offset(); # only gets called once if ($match =~ '\b(0x)?(f|F){8}\b') { return 1; @@ -293,7 +292,7 @@ sub get_page_offset } # Allow --kernel-config-file to override. - if ($kernel_config_file != "") { + if ($kernel_config_file ne "") { @config_files = ($kernel_config_file); } else { my $config_file = '/boot/config-' . `uname -r`; @@ -314,14 +313,16 @@ sub get_page_offset } foreach my $config_file (@config_files) { - $page_offset = parse_kernel_config($config_file); + $page_offset = parse_kernel_config_file($config_file); if ($page_offset ne "") { return $page_offset; } } - printf STDERR "Failed to parse kernel config files\n"; - printf STDERR "Falling back to %s\n", $default_offset; + printf STDERR "\nFailed to parse kernel config files\n"; + printf STDERR "*** NOTE ***\n"; + printf STDERR "Falling back to PAGE_OFFSET = %s\n\n", $default_offset; + return $default_offset; } @@ -329,11 +330,13 @@ sub parse_kernel_config_file { my ($file) = @_; my $config = 'CONFIG_PAGE_OFFSET'; + my $str = ""; + my $val = ""; open(my $fh, "<", $file) or return ""; while (my $line = <$fh> ) { if ($line =~ /^$config/) { - my ($str, $val) = split /=/, $line; + ($str, $val) = split /=/, $line; chomp($val); last; }