Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3269448pxk; Mon, 28 Sep 2020 12:52:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyovdevqWQchAfGfxNAY0xnJBRZrY082WQFaI2TJH88iA2iwR6UhvLxE/BhK7droceA+wkp X-Received: by 2002:a05:6402:17fc:: with SMTP id t28mr3667397edy.244.1601322740484; Mon, 28 Sep 2020 12:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601322740; cv=none; d=google.com; s=arc-20160816; b=E172bmZqReIzN9DH8cd1mWjPzKQQ+oJ3ix5Vohf54cHLNnUpCfk9rViNvaS9+jbtvz 2A6AR5XRmHxKHVfDv8+2fp0Iwt20dM8B2c6hCM1FmohX7u1pxe3X5DycD0QoDrmGbAt+ OpWtP2Bk6xwc0Ibjve+iQGJ8RT/mmb/nuC9ayBWRhfDn7KlyJDh4WlVTyuYClC6lEahR UHe2aSBj6nCWSOUQXQbc3eRPIjBiGxgVSiTogM/SGb4TbMPRwRf6m5CL0wjoxbGu0gm4 zPtO3R0ruzFCJExkrW/Z1fqiA8QBvNT3TZYHRfEL9an+s2J0Mspsxg83tPZRIl4/1UNr 0hcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NqGk7vDyMCAYS8I0sgrwIKxqUFOoutHt+GIsW8/pgQc=; b=B4a/OAZBMXcU5juGV/AWFsZryF4y333gjpA4vgHwd37QF5FABtnDpCoRz2/ddtt3DX VDa5v/NJJpFCDdOpLICF+rBk3VkZZZMHlr4qT1mZggSYiEzcZlKPplDxWcGVqoKD4sAg aYmUfmC0fXuGkYZVMpi0f8BSg2+cIdGZmbKZcL94EYtOCuc0V86fRDHMVVcoiJdo/5sW Eovyd9y80z/O5nhiYFp2tCB4e4cO9MCgoh7TKDEV2dPJABaoAy1CnU7ju6OK0/AqJMbj QAbvo8FgXuWcR5QTmWRKG8ZOlsrI5NWxOngVsuI6s8/2lpDrocEJ4v1fN6eRnA4Sb1us cSLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DqDoWsT0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si1288158edb.495.2020.09.28.12.51.58; Mon, 28 Sep 2020 12:52:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DqDoWsT0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgI1Tu3 (ORCPT + 99 others); Mon, 28 Sep 2020 15:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgI1Tu2 (ORCPT ); Mon, 28 Sep 2020 15:50:28 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9248EC061755 for ; Mon, 28 Sep 2020 12:50:28 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d9so2092774pfd.3 for ; Mon, 28 Sep 2020 12:50:28 -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=ido93POw8JGMVI5MMBEZ1dHVmAWD6/JvOlh6riQrl7fF/zCi+j9d0Uzkwb42xIiVWt CVxD1IA5+6NxpZHAl16HwmHNpwxw7dXlGIyQzMmlI0sSBELxavK6ZJov+SmuOtozIilb JTcUkqMfUbVXhirqV/M82jItkavPDGqZQXBmQFI9Lx4OiHsP6SmuQ6OZa5BfCRDNvInN 1KicixLfGwCIMkouxB2clCo+kIipQJQLMCJiRoyrCH7lxWY18TneSAMAqO2Sa+ZjzWbV ssUB3qLklr0D+IDlmksZg9f6WTtYcXPLbwG1/7NDJ8qx4a7GMUktt5RoL6Pr4pP1f0Yi ctiA== X-Gm-Message-State: AOAM533I2OO/2FdGFhTu67k5R24sIaPOIExym/LkVu/ht5yRdVOr+iz7 aA4sLpTvVKuXgLW6nwvrSNAU0w== 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 Cc: Ard Biesheuvel , Mark Rutland , Arnd Bergmann , Ard Biesheuvel , Marc Zyngier , Dave Martin , Kernelnewbies , Russell King - ARM Linux , open list , Tony Lindgren , matt@codeblueprint.co.uk, nico@linaro.org, Thomas Garnier , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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