From mboxrd@z Thu Jan 1 00:00:00 1970 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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 50774C47420 for ; Fri, 25 Sep 2020 23:49:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0211020878 for ; Fri, 25 Sep 2020 23:49:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wUeSqYeM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Vp5m6tCD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0211020878 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U7Me5t/pZrRU7+7KYonI0P/TSlIBy5qdJECALB3gfCM=; b=wUeSqYeMBG41spZvIk1BFLdxz icpJ49X/DmDsIxyhsFzziTwt2WEYcOOvSDubr22QgdKhKgXxVBl97xcdWKpZOZnTuFZAJ3v3pSCTU M7hGXwy5WuBMWMuU14k6H1Pr1b+cyYgus8ABo/O+RhwySXVtimsVbF5GKXNxDslTwmoe2lOU6UZeC ootubnvOwXwaEYhFttcOcHVpq2Jt6dxm/rVX+u84lBBCmu3gI+4KiOs0cTAE6DrDCgIWdBOLsmyZo bAs+pU/8GqVMo6E6Jo6rw2kwOjiA6L6p1DBsnc+zbQAyz7KT1eMNz4000Fq3rAGwiyCyZxSUrBJDI IqTY6fdTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLxRR-0008St-6J; Fri, 25 Sep 2020 23:47:53 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLxRN-0008Rl-Dc for linux-arm-kernel@lists.infradead.org; Fri, 25 Sep 2020 23:47:50 +0000 Received: by mail-pf1-x444.google.com with SMTP id k13so4768845pfg.1 for ; Fri, 25 Sep 2020 16:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Io7hz4IuqZtEpaytzAzCxwSUam0CFx9DS3tqLdxn+Xk=; b=Vp5m6tCDtyV4W/JH0g4qWcc327nWVydhooFj9uwSpVAY0st4EEXpvloPDbNDLUzEge ywH/h1AoxE8vmj64+7NIXyeLfN4EvN1QEEZ1xgXXA/m9O9RMBN8i2YkTSTw3fwHOZvAq g0p+zzkkPf8d2ui3sxADVxcXOjMUhtNwsWnSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Io7hz4IuqZtEpaytzAzCxwSUam0CFx9DS3tqLdxn+Xk=; b=RjcLPPMBu54BLTpW00+kyktLKze6IQ1cOmYckOLGL++abdWFpvdZ1k6Senc2Yz9A+Y I14JkB8GOLbpXJ4/XAYLnX8QJEaO11KKbeyuNp+f1YW/sJQTto1yx9obPZbv7Bj1o42r HUFiqSFdaO24nC0PNmU3r6om/5xt1SJB1FJs9K4HM6K9bYsaSF3JWdBm18tfd8D/YAet E0LCp8N63gANi7+lKRt9tJ3EWr9ojHcRZY2pPh61SZoX40N5+eMThwt5P87CF6rUEDhJ JnMj3BCZ1ZUiFQm65qPM6hng/ChdGNbn2/rKR+x9uw601zo5+Xwir9OMq8qs0DR18Sj3 KuJQ== X-Gm-Message-State: AOAM530R6C73liqqcdt4wd/n9dOSjq2KtBfr30PGJVrAK5b+WscqDjOo cU9XYKQfhK9mn7jZ6BaOv5RdSw== X-Google-Smtp-Source: ABdhPJxEslujd3tp9T1ofdE6n0YODMisS2U8S0qulVyj48Ul/uxdH4vlyBD4bOXB2UljyUZYhZqVDA== X-Received: by 2002:aa7:93a2:0:b029:142:2501:39f4 with SMTP id x2-20020aa793a20000b0290142250139f4mr838077pff.67.1601077666482; Fri, 25 Sep 2020 16:47:46 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q5sm3603706pfb.184.2020.09.25.16.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 16:47:45 -0700 (PDT) Date: Fri, 25 Sep 2020 16:47:44 -0700 From: Kees Cook To: Ard Biesheuvel Subject: Re: KASLR support on ARM with Kernel 4.9 and 4.14 Message-ID: <202009251647.FD8CECD4@keescook> References: <202009251301.A1FD183582@keescook> <202009251338.D17FB071@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_194749_884632_0EDE0602 X-CRM114-Status: GOOD ( 35.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Thomas Garnier , Pintu Agarwal , Arnd Bergmann , Ard Biesheuvel , Marc Zyngier , Kernelnewbies , Russell King - ARM Linux , open list , Tony Lindgren , nico@linaro.org, Dave Martin , matt@codeblueprint.co.uk, "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 25, 2020 at 11:09:10PM +0200, Ard Biesheuvel wrote: > On Fri, 25 Sep 2020 at 22:47, Kees Cook wrote: > > > > On Fri, Sep 25, 2020 at 10:37:01PM +0200, Ard Biesheuvel wrote: > > > On Fri, 25 Sep 2020 at 22:28, Kees Cook wrote: > > > > > > > > On Fri, Sep 25, 2020 at 08:33:59PM +0530, Pintu Agarwal wrote: > > > > > This is regarding the KASLR feature support on ARM for the kernel > > > > > version 4.9 and 4.14. > > > > > > > > > > Is KASLR supported on ARM-32 Linux 4.9 and above ? > > > > > > > > Sorry, this feature did not yet land in upstream: > > > > https://github.com/KSPP/linux/issues/3 > > > > > > > > Here was the earlier effort: > > > > https://lore.kernel.org/kernel-hardening/20170814125411.22604-1-ard.biesheuvel@linaro.org/ > > > > > > > > > Is it dependent on CONFIG_RANDOMIZE_BASE or > > > > > > > > CONFIG_RANDOMIZE_BASE is what is used on other architectures to control > > > > the feature. > > > > > > > > > /proc/sys/kernel/randomize_va_space ? > > > > > Is there any relation between these two? > > > > > > > > No, the latter is about userspace addresses. > > > > > > > > > Is the changing kernel symbols (in every boot), only possible if KASLR > > > > > is enabled, or there is another way it can happen? > > > > > > > > I think you meant kernel symbol addresses (not the symbols themselves). > > > > But yes, I wouldn't expect the addresses to move if you didn't either > > > > rebuild the kernel or had something else moving the kernel at boot (i.e. > > > > the boot loader). > > > > > > > > > I have these queries because, > > > > > In one of the arm-32 devices with Kernel 4.14, I observed that > > > > > CONFIG_RANDOMIZE_BASE is not available. > > > > > But /proc/sys/kernel/randomize_va_space is set to 2. > > > > > However, I also observed that symbol addresses are changing in every boot. > > > > > > > > > > 1st boot cycle: > > > > > [root ~]# cat /proc/kallsyms | grep "sys_open" > > > > > a5b4de92 T sys_open > > > > > [root@sa515m ~]# > > > > > > > > > > 2nd boot cycle: > > > > > [root ~]# cat /proc/kallsyms | grep "sys_open" > > > > > f546ed66 T sys_open > > > > > > > > > > So, I am wondering how this is possible without KASLR > > > > > (CONFIG_RANDOMIZE_BASE) support in Kernel ? > > > > > > Those addresses were obfuscated by kptr_restrict > > > > Is that true? kptr_restrict zeros (rather than hashing) the kallsyms > > view. And besides, the %p hashing was added in v4.15 (but also doesn't > > touch kallsyms, which does all-or-nothing to avoid breaking stuff > > like perf). > > > > Ah yes, good point. But it does look suspiciously like they are being > mangled in a similar way. > > For a 3/1 split ARM kernel of the typical size, all kernel virtual > addresses start with 0xc0, and given that the kernel is located at the > start of the linear map, those addresses cannot change even if you > move the kernel around in physical memory. I wonder if this is an Android Common kernel? I think there was %p hashing in there before v4.15, but with a different implementation... -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel