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 EF3FFC2D0A8 for ; Sat, 26 Sep 2020 16:41:17 +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 83BCE21527 for ; Sat, 26 Sep 2020 16:41:17 +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="ktDKhvAE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83BCE21527 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.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1kMDFi-0002yB-76; Sat, 26 Sep 2020 12:40:50 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kMDFf-0002y0-LF for kernelnewbies@kernelnewbies.org; Sat, 26 Sep 2020 12:40:48 -0400 Received: by mail-pf1-x443.google.com with SMTP id q123so605835pfb.0 for ; Sat, 26 Sep 2020 09:40:46 -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=fB4w4qotUDg8HDR3/XD0HJhEYnwR7rKISTmnvsHnZyAAah9YHsoqAyKZjZOQy16u3L kVg4lhpDb6CYbxO/pXc5JrD/hFIK2Y10d7mIvSEpJ9ZSSVtsi6zbuxlekuhePL1KiYOn jjc+zlzpvKH8+u/g2gbux49cqZNqq4JR5vPk2swGrfcAhk8NfmgIaQAGGoJosEI16+DK PA1ZowSb/FB84y4sAdS6LkRnwijrKlYvxID5hpIi1qLj0Z0dLAvxlFHxBtuYRik0PXCx 7Fcjj/FcL/gRhYdX6oW2lzgVB5qrhh/jUp4rjegP/O27YNSt+F/mq+eF4KvdnJCxAHoU 7EUQ== X-Gm-Message-State: AOAM531QVEcopNtYnlKETpxIQMVy+pCX1Hxi+2sDs+1ye0AbpBpKZk3c l04G5XrSS0whJQuQK2nLE02Mag== 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 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-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.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 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies