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.5 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 E92B8C2D0A8 for ; Mon, 28 Sep 2020 19:52:07 +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 5F5152065D for ; Mon, 28 Sep 2020 19:52:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RtltLeKB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DqDoWsT0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F5152065D 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=P3VJyQzP6DK6EqpGDpzYQlJNsWVFWRTU+r0xJ0e3NI4=; b=RtltLeKBoTyHtkl8YI0DnJPT8 1lcFI4x27hZa9ZcEnQ8wy5+/mFCe779b4rt8VrMvV61k3ErZWz0TqVaj0stjTck/9lkcULuZXcfOz vKlZ0+VN+FRuWCswmMqZ2EanhQhtc+0E7CT6dceRbr/YbLCgnSs35Y34PtDTWKGteAdwaIu15itdn p0hPkxzxdL4erm2AwVMsDSg2qiRbz8F5DtOWl+DVneA7PN9M679seEqAlAhIiQb++Jp6BplQPQEz0 ySQSDRK5ujZ3J8P0Bm1pXVmZ6yxeORDCh1GRSvyN45Dwhm8MS52ikatGWue1o7hOP7Tjc22LGEUuH M7AYEicrg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMzAR-0007Zu-AH; Mon, 28 Sep 2020 19:50:35 +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 1kMzAO-0007ZI-6B for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 19:50:33 +0000 Received: by mail-pf1-x444.google.com with SMTP id q123so2106152pfb.0 for ; Mon, 28 Sep 2020 12:50:29 -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=NqGk7vDyMCAYS8I0sgrwIKxqUFOoutHt+GIsW8/pgQc=; b=DqDoWsT06mOCMfIx6LctUTHasONJ7on/4G6nmmzsxGhrlqdoj3LaatYg4kcZmhdPGB hSUbmWlK9gRdKLfGy9LIor3kAeQjbQo6ZZRACf7OrHSvjKG+M1TT4gSRNg7lVJUwl5CL dYiWoZjxH36IntLebqXhNCliD1Kd0jP+VJBoA= 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=NqGk7vDyMCAYS8I0sgrwIKxqUFOoutHt+GIsW8/pgQc=; b=rd+uyfuhlJXR/LRQ5QZfoT5GUGxzxtb2tpRrpl6L9l9Jmv56Uo8IJqiygWoVm9lBW0 TIl5DafRaN4UZonhPFer9VikjC+73oVo1Nm4P91o7YlNDYOAovrXpmqjc7/DK1fs+BCq ouPSXGkCrPH9H+IM8NNevSTHfRZWojN/AVWu19MnDWgRy9tjta5Y+lrSJYjWaTCfPcMb nByTGd+WfsZqBbgrQqV+uhGc4Shu5aUEcdW/JT31ov/duxhogEsbv8pC1GyOPmuoLF/S /OZmFtXh949qJh2MTNSExFYvour9OwnLefN86qmVm2zbO2h8t4Ot917Fxtm8cx4by/zD Nd+A== X-Gm-Message-State: AOAM530f4B6LkIATHJK6MoSwFyrWtAo/wzlfFgK7aJaj1s6QlFBQEvKS coCwAGkFEfxW+8dIe4pVWui9Iw== X-Google-Smtp-Source: ABdhPJzFoE1z3csOguwYxTy5MCxiW4q9PSri9tP2w2oD+oE/SdmrU1HJhQYA+xffFi8Douas2i3D2A== X-Received: by 2002:a63:e504:: with SMTP id r4mr498143pgh.431.1601322627926; Mon, 28 Sep 2020 12:50:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x4sm2569463pfm.86.2020.09.28.12.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 12:50:27 -0700 (PDT) Date: Mon, 28 Sep 2020 12:50:26 -0700 From: Kees Cook To: Pintu Agarwal Subject: Re: KASLR support on ARM with Kernel 4.9 and 4.14 Message-ID: <202009281248.6F601005CA@keescook> References: <202009251301.A1FD183582@keescook> <202009251338.D17FB071@keescook> <202009251647.FD8CECD4@keescook> <202009260933.C603CD8@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-20200928_155032_232090_3B552B3E X-CRM114-Status: GOOD ( 33.92 ) 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 , Arnd Bergmann , Ard Biesheuvel , Marc Zyngier , open list , Kernelnewbies , Russell King - ARM Linux , Ard Biesheuvel , 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 Mon, Sep 28, 2020 at 07:41:13PM +0530, Pintu Agarwal wrote: > On Mon, 28 Sep 2020 at 19:15, Pintu Agarwal wrote: > > > > On Sat, 26 Sep 2020 at 22:10, Kees Cook wrote: > > > > > > >> I wonder if this is an Android Common kernel? > > > > It uses the below kernel for 4.14: > > > > https://gitlab.com/quicla/kernel/msm-4.14/-/tree/LE.UM.3.4.2.r1.5 (or > > > > similar branch). > > > > > > Okay, so yes. And this appears to have the hashing of %p backported. I > > > cannot, however, explain why it's showing hashed pointers instead of > > > just NULL, though. > > > > > > It might be related to these commits but they're not in that kernel: > > > 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing invalid pointers") > > > 7bd57fbc4a4d ("vsprintf: don't obfuscate NULL and error pointers") > > > > > > > ==> The case where symbol addresses are changing. > > > > > > > > kptr_restrict is set to 2 by default: > > > > / # cat /proc/sys/kernel/kptr_restrict > > > > 2 > > > > > > > > Basically, the goal is: > > > > * To understand how addresses are changing in 4.14 Kernel (without > > > > KASLR support)? > > > > * Is it possible to support the same in 4.9 Kernel ? > > > > > > Try setting kptr_restrict to 0 and see if the symbol addresses change? I > > > suspect Ard is correct: there's no KASLR here, just hashed pointers > > > behaving weird on an old non-stock kernel. :) > > > > > > > Okay. Thank you so much for your comments and suggestions. > > You mean to say, setting kptr_restrict to 0 may avoid changing symbol > > addresses in 4.14 ? > > And, sorry, I could not understand the thing about this "hashed pointers". > > How can I check this behavior in source code to understand better? > > Is it possible to give some reference ? > > I wanted to disable this hash pointer on 4.14 kernel and check the behavior. > > Also if possible, we would like to make this similar change on 4.9 > > kernel as well. > > > > Okay, I found these changes in 4.14 kernel: > https://gitlab.com/quicla/kernel/msm-4.14/-/commit/e63732dbfe017aa0dbabac9d096b5fde8afbd395 That's an out-of-tree patch. The one that was backported to 4.14 from 4.15 that does %p hashing is this one: https://gitlab.com/quicla/kernel/msm-4.14/-/commit/ad67b74d2469d9b82aaa572d76474c95bc484d57 > Are we talking about this? > I cound not find this in 4.9 kernel. Note that I still can't explain what you're seeing. /proc/kallsyms shouldn't be affected by these patches -- I would expect it to either report the true value or 00s. > I will disable kptr_restrict and check or, I will enable > CONFIG_DEBUG_CONSOLE_UNHASHED_POINTERS and check. I would start with kptr_restrict=0 and see if that changes the contents of /proc/kallsyms. If it does, then it is the hashing. If it doesn't, well, we're back to square one. :) -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel