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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 35B4AC2D0A8 for ; Mon, 28 Sep 2020 19:52:27 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 769E3206D4 for ; Mon, 28 Sep 2020 19:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; 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 769E3206D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1kMzCB-0003OL-2k for kernelnewbies@archiver.kernel.org; Mon, 28 Sep 2020 15:52:23 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kMzAN-0001uF-3A for kernelnewbies@kernelnewbies.org; Mon, 28 Sep 2020 15:50:31 -0400 Received: by mail-pf1-x442.google.com with SMTP id f18so2066065pfa.10 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=WI+WuxQIoJ3J6wSfwZ6CvtsCbjedHAc5Y1LWziyl9AmhAjCeRWqxnKgwniwlQ1nImY deFf9jQLpjFQ9c2ndOQkkDmxwA1WfWpccpvEoXf8qFAzzaVBYb1jBaVAWGZpKgwky0pn TIaq8yNL0LbtvMDYvhhRdOGz6Srf4CRmVhYpD7zo+F5Ec4Vf8kh0RNBzGyiSCrwktqIc W/Dmsv6mPNAch7WZkwl71mPBWUTLzqtIRrhSxvUUA0yYg/qMLN4DEodEJna0TM09E+Ky v+3VC7O1zPn3VDsaxoSlfTKIfyeZGwIcd5ei0+BIPM/B0yU7Dg3tWWOye0bXJUKBtusT mhKg== X-Gm-Message-State: AOAM533hN8U1AiB4pGQ9WipJtN7sLUfToJcwNDDfpRshyYhCQIJ+s0zw SMcJtsrsmLHu2hS138VfneJvSA== 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: 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" X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.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 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies