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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,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 ABFC3C433DB for ; Sat, 9 Jan 2021 21:26:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF94C23A7F for ; Sat, 9 Jan 2021 21:26:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF94C23A7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 37E616B0170; Sat, 9 Jan 2021 16:26:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 307146B0189; Sat, 9 Jan 2021 16:26:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F7488D0002; Sat, 9 Jan 2021 16:26:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 0B93C6B0170 for ; Sat, 9 Jan 2021 16:26:22 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BF14B365F for ; Sat, 9 Jan 2021 21:26:21 +0000 (UTC) X-FDA: 77687520162.22.fish15_0c07fff274fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id A68E618038E60 for ; Sat, 9 Jan 2021 21:26:21 +0000 (UTC) X-HE-Tag: fish15_0c07fff274fe X-Filterd-Recvd-Size: 4744 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 Jan 2021 21:26:21 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id v67so3386366lfa.0 for ; Sat, 09 Jan 2021 13:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=spScs5BI5KiRRQrhecZKN4jkNwdDHtwVKRu7ZMdvkPQ=; b=XLT6s6rsCMercT6qkvbUhtp35zEHZrRmlL47aYyE6c14wSp3tUTSS7M/fAces2aleg ICuOhvvHeVQI5gtBKv5yFjo3hP0RyGTetvCTdq/pmScVPwoJahSt3DRJHPXSE9yB1nnD txjRsr51eIR4g1vQPU0W1Uta3p/u2tO8wN86Ha6HTth1DDR7+87Yb7oA7QgiivR5tsd8 ETIcC7blbrazNWd2f6VbAdRWfKWfzYih7g/3b1U0smQUZzaMqZ2UTAq6lHptUHq0TJae 5Fif2KRsK7F2F00AZtisWEUqV/TbwijcK9ZHIw9G3SjFk/dwfpFilHHlHU0xSbOaVlmu 90Rg== 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:content-transfer-encoding; bh=spScs5BI5KiRRQrhecZKN4jkNwdDHtwVKRu7ZMdvkPQ=; b=D4qA5jCOtqCWv3VYWqUpNJSah6vdN5coCFfZ+sbIhX3JXFU6UCIqDbHEthaWK9hZBT brv3tu5lstXshQZs2nJqE5ZYRwlkxtzvUNKPav84Rlwx8evm7lOVm2qLw9UhNK2o25CY APJn09t4tEstcSQlvld0hMGVJKr71IQj006LWBu+rJUVYpj/KL39Mbdy67aNbaMWtIR1 G9a76X3+FgRCAubr6Qldd/NpxX6KnhbZTaNytYHdt7C49KD45vvko2Bdt7DuaHr5EfUT cODHYNICROOg+/xXD0GKF7/hJ26LD8TczTH002GB/eGNn1b8VOMdVa0I0tsChaI5k92u RnvA== X-Gm-Message-State: AOAM531qhTJCnWNjC8/gXlz4PcD0MwPwct9gy6RNpSCfji8TZz6f653J yL73Mwf1nYU4NXSqibei1k+fNzMX90o41CEtkAr/UQ== X-Google-Smtp-Source: ABdhPJwMMwVLVu0j0Nvz+H/adawTsmdnEhz93v3RChjdhFXmLqXyARbCvh+/qihWD88k1tp1QcVZgSA+vyX4k6yPxQo= X-Received: by 2002:a05:6512:74e:: with SMTP id c14mr4610942lfs.529.1610227579697; Sat, 09 Jan 2021 13:26:19 -0800 (PST) MIME-Version: 1.0 References: <20210109044622.8312-1-hailongliiu@yeah.net> In-Reply-To: <20210109044622.8312-1-hailongliiu@yeah.net> From: Linus Walleij Date: Sat, 9 Jan 2021 22:26:08 +0100 Message-ID: Subject: Re: [PATCH] arm/kasan:fix the arry size of kasan_early_shadow_pte To: Hailong liu Cc: Andrey Ryabinin , Ziliang Guo , Hailong Liu , Russell King , kasan-dev , "linux-kernel@vger.kernel.org" , Linux Memory Management List , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jan 9, 2021 at 5:51 AM Hailong liu wrote: > From: Hailong Liu > > The size of kasan_early_shadow_pte[] now is PTRS_PER_PTE which defined to > 512 for arm architecture. This means that it only covers the prev Linux p= te > entries, but not the HWTABLE pte entries for arm. > > The reason it works well current is that the symbol kasan_early_shadow_pa= ge > immediately following kasan_early_shadow_pte in memory is page aligned, > which makes kasan_early_shadow_pte look like a 4KB size array. But we can= 't > ensure the order always right with different compiler/linker, nor more bs= s > symbols be introduced. > > We had a test with QEMU + vexpress=EF=BC=9Aput a 512KB-size symbol with a= ttribute > __section(".bss..page_aligned") after kasan_early_shadow_pte, and poison = it > after kasan_early_init(). Then enabled CONFIG_KASAN, it failed to boot up= . > > Signed-off-by: Hailong Liu > Signed-off-by: Ziliang Guo OK I see the problem, I think. > +#ifndef PTE_HWTABLE_PTRS > +#define PTE_HWTABLE_PTRS 0 > +#endif Can this even happen? We have either pgtable-2level.h or pgtable-3level.h, both of which define PTE_HWTABLE_PTRS. > extern unsigned char kasan_early_shadow_page[PAGE_SIZE]; > -extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE]; > +extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]; Yeah this looks exactly like bm_pte so it makes sense. If you drop the first ifndef, Reviewed-by: Linus Walleij Yours, Linus Walleij