Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp468581yba; Sat, 13 Apr 2019 05:44:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3OqldcEPWXAvGIZFtw9U1ayd0hN+YOouqJQ+RHVFTB/bkdxqNm4iURYlDtQWj75Dscw3A X-Received: by 2002:a17:902:820e:: with SMTP id x14mr63330371pln.207.1555159463771; Sat, 13 Apr 2019 05:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555159463; cv=none; d=google.com; s=arc-20160816; b=P/3KH+qjmaHYKbUzJO7XfdCKaOG4Udq9Ojyh4lcSnPmFQGys54ZFIbswIWgOJBjG/u HMAdht7Xs5tDEDE2BtKO2LNVzsgoN2lPoME0j7qH8mh+gTaQjNe9dlNM31TlWogKFQdK pZcdUc/MZU933ewCQCXRNUllIahaPzP9+TIUqXCv5+WtbDQ6q5GFXwhy55U65Hk+OR05 6P0HkG427lK6tnzktSpmv457IIr3xWq1K1rsyXaslTOY1Z02ZNBLuKuRsw4NGfeYC1n6 15tfID73nMEUNNEbiGjyqyy21MZdFgECw1+fjj6+BkXLKHcfS0vzQvOeuP/8OxeT6N/B ug3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=L6UEuPciT2jqWTP9u8f+boXyu7qcE24vOwqg8IPOLBQ=; b=kcObTgx2F99rg0jNtzf0QHkbcZCyNKCHu4I2J9l8BfFMld+EqSBjZTxOLtBCYhR4Kk 1z+ENQatuUH8W+iP2FP+rr32WKt9hdvMszmlroGBjDRuVJIiBc0H1Di6UY+T0DouO6HI 6mrjwEq6lZjUuYu6rWblx8veDzpzQEPJqucmdDwHoy1FBu1C7oqqhOvvdXOgF/utDfCJ HUBR0Ho3uwPSBfpx9yXbZp8cVESvmpC1HbBWisRxOxEM7Uto6QM2zim3izB66G0WOBy2 xKgpcT2pqfxQB1b+Zx5yriPZjNCeJX453gv5iR9SyVJxYNSmlkEBrzPcsDLhqS9hyAZf aIfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=b7w+cAg2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f13si39365130pfh.37.2019.04.13.05.44.07; Sat, 13 Apr 2019 05:44:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=b7w+cAg2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727066AbfDMMlq (ORCPT + 99 others); Sat, 13 Apr 2019 08:41:46 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37229 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbfDMMlq (ORCPT ); Sat, 13 Apr 2019 08:41:46 -0400 Received: by mail-qt1-f196.google.com with SMTP id z16so14357756qtn.4 for ; Sat, 13 Apr 2019 05:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=L6UEuPciT2jqWTP9u8f+boXyu7qcE24vOwqg8IPOLBQ=; b=b7w+cAg2sYAWe2k9qDCj1ghA8QsHvYLg3glnJV4ifZwvrdgkuJ1+wO/NVYhDFPP9Td tBIeA4UMm/JMQOMSnXrUj6Z5V6J4TWNRArHiM2Rw332Vpgp360iHkHkr+Mw3u0FlRtre 7NhrrjdsdXsBLk/OpVQoIzAGLuK62BZvMl2ck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L6UEuPciT2jqWTP9u8f+boXyu7qcE24vOwqg8IPOLBQ=; b=MycODdvW/BI1cXy3JarEczde1nprU+syF3US5sA+n14RdxSz1d5fmW1Wi2mB+wUmB8 YmM3KU1uJ4V7gJhxu3HRDzLnTmA8aP6dX1vMtkg3SuqpXjuOAaL/g/asZXsdtyqHGw5x Oj/tfYEndvExk9No1Mb7hJHmWRu5TBkY8CBwhebHY6hVz9oaRSoSBHvJg4m0rG0jZIiz dOQ2pXRR5YY2W2qvjXO0C5buovyQ6IrF+UtlgbviSCQL6cn057Iu7TTf+/fivuuP+ABw aLoulHgBa/QfQykMUW2noq1/kX7QJowk18ILKn6O2e9ga/TuVolQ9Vq3EOBY7VszSYZW 86JA== X-Gm-Message-State: APjAAAUIJHw5GasaLo90Fuh1bT4xwn5NkS8cI+TsauDCr0/Da5tPa7uL XRkYD1w7x9AS0W8QFRLy9/j9dR6eOJRfrif6aQM03A== X-Received: by 2002:ac8:304a:: with SMTP id g10mr51433930qte.118.1555159304853; Sat, 13 Apr 2019 05:41:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nicolas Boichat Date: Sat, 13 Apr 2019 20:41:33 +0800 Message-ID: Subject: Re: [PATCH] arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region To: stable@vger.kernel.org Cc: Ard Biesheuvel , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "markus@oberhumer.com" , "linux-kernel@vger.kernel.org" , Yueyi Li , Guenter Roeck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear stable maintainers, I encountered a similar issue on a 4.19.33 kernel (Chromium OS). On my board, the system would not even be able to boot if KASLR decides to map the linear region to the top of the virtual address space. This happens every 253 boots on average (there are 0xfd possible random offsets, and only the top one fails). I tried to debug the issue, and it appears physical memory allocated for vmemmap and mem_section array would end up at the same location, corrupting each other early on boot. I could not figure out exactly why this is happening, but in any case, this patch fixes my issue (no failure in 744 reboots with 240 unique offsets, and counting...), and IMHO the ERR_PTR justification in the commit message is enough to warrant inclusion in -stable branches. The patch below was committed to mainline as: commit c8a43c18a97845e7f94ed7d181c11f41964976a2 arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region and should be included in stable branches after this commit: Fixes: c031a4213c11a5db ("arm64: kaslr: randomize the linear region") i.e. anything after kernel 4.5 (git describe says v4.5-rc4-62-gc031a4213c11a5d). Thanks, Nicolas On Wed, Jan 16, 2019 at 4:38 PM Yueyi Li wrote: > > > > On 2019/1/16 15:51, Ard Biesheuvel wrote: > > On Wed, 16 Jan 2019 at 04:37, Yueyi Li wrote: > >> OK, thanks. But seems this mail be ignored, do i need re-sent the patch? > >> > >> On 2018/12/26 21:49, Ard Biesheuvel wrote: > >>> On Tue, 25 Dec 2018 at 03:30, Yueyi Li wrote: > >>>> Hi Ard, > >>>> > >>>> > >>>> On 2018/12/24 17:45, Ard Biesheuvel wrote: > >>>>> Does the following change fix your issue as well? > >>>>> > >>>>> index 9b432d9fcada..9dcf0ff75a11 100644 > >>>>> --- a/arch/arm64/mm/init.c > >>>>> +++ b/arch/arm64/mm/init.c > >>>>> @@ -447,7 +447,7 @@ void __init arm64_memblock_init(void) > >>>>> * memory spans, randomize the linear region as well. > >>>>> */ > >>>>> if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) { > >>>>> - range = range / ARM64_MEMSTART_ALIGN + 1; > >>>>> + range /= ARM64_MEMSTART_ALIGN; > >>>>> memstart_addr -= ARM64_MEMSTART_ALIGN * > >>>>> ((range * memstart_offset_seed) >> 16); > >>>>> } > >>>> Yes, it can fix this also. I just think modify the first *range* > >>>> calculation would be easier to grasp, what do you think? > >>>> > >>> I don't think there is a difference, to be honest, but I will leave it > >>> up to the maintainers to decide which approach they prefer. > > No it has been merged already. It is in v5.0-rc2 I think. > > OK, thanks. :-)