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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 8A424C2D0A8 for ; Sat, 26 Sep 2020 16:40:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47EFD21527 for ; Sat, 26 Sep 2020 16:40:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ktDKhvAE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729920AbgIZQkq (ORCPT ); Sat, 26 Sep 2020 12:40:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728504AbgIZQkp (ORCPT ); Sat, 26 Sep 2020 12:40:45 -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 D27C5C0613CE for ; Sat, 26 Sep 2020 09:40:45 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id n14so5814540pff.6 for ; Sat, 26 Sep 2020 09:40:45 -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=7e0Ffrwn9v4gwzlKso2h5MvGkrn/JrEHZKg5opwz4OY=; b=ktDKhvAEHwe8lJt6SyzjuD8ysDLH+ZaxKivr7vSNNqfjlMbAkjrRKcjx9FQhBSRv2g avVO6We7wuZu3KPJ1xtiaUSR48eerv6COZCBFaITK0GSQ8hc3sJGryngsQzidOm+8D5k K9RV5zZ17LXhsmdQkw6qPdp9sxLwH/NiksOMc= 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=7e0Ffrwn9v4gwzlKso2h5MvGkrn/JrEHZKg5opwz4OY=; b=rnI5RG/vXlh55c/UXwekuDHHzAEOEzkn3nQRJiPCOQjOH4sRvWml4oVhCFNz67gdGh htmooQILAC+XVkPJai96vf3xN0G+HC0JOyIj9xLMinLigTujgrcvVpn5dAiuRcARxKqV 46cH9O0VijsYeVHJAHsdQgqoLuCxeKpP1+nfIRYOq6sUgZPcvTrlrli1LU6f/ffv4W5l lmtdHtZc03i+EmJLlqT6GHRWDIlLlSlDxs6S1JRLN+b21QuBX11zDmf2BQ+3MxJkHmjA ME1/p1MA8oZkjOHYV56mwwEguxa3jiRQV/IhfI93r1QjmkO89/AFeslVEmO5yXYBIxZj 8PLg== X-Gm-Message-State: AOAM531rOUt01GPbb2hzbU/oEGkJZHkSrYyIC5yW24eaJM+bYJveGlGj NipV+7+Yhng+STtwtAlNrhpKRQ== X-Google-Smtp-Source: ABdhPJxEv3B43fDRIw9oQj67xt/6OOVTGXX9ohHp1ciUHnbEei28ePC/Ydj30i0xIBeY58/VxlmDhQ== X-Received: by 2002:a63:5043:: with SMTP id q3mr3179390pgl.293.1601138445354; Sat, 26 Sep 2020 09:40:45 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h1sm2216562pji.52.2020.09.26.09.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Sep 2020 09:40:44 -0700 (PDT) Date: Sat, 26 Sep 2020 09:40:43 -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: <202009260933.C603CD8@keescook> References: <202009251301.A1FD183582@keescook> <202009251338.D17FB071@keescook> <202009251647.FD8CECD4@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 Sat, Sep 26, 2020 at 01:28:02PM +0530, Pintu Agarwal wrote: > On Sat, 26 Sep 2020 at 05:17, Kees Cook wrote: > > > > > > 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... > > > > Hi, > Thank you all for all your reply and comments so far! > Here are some follow-up replies. > > >> What device is this? Is it a stock kernel? > This is a Qualcomm Snapdragon Automotive board one with Linux Kernel > 4.9 and one with 4.14. > > >> Is the boot loader changing the base address? (What boot loader are you > >> using?) > Ohh I did not knew that the bootloader can also change the base address. > I think it uses UEFI. > How to check if bootloader is doing this ? > BTW, both 4.9 board and 4.14 board, uses same bootloader. > > >> 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. :) -- Kees Cook