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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB66C433F5 for ; Sun, 24 Apr 2022 05:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238268AbiDXFUP (ORCPT ); Sun, 24 Apr 2022 01:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238266AbiDXFUJ (ORCPT ); Sun, 24 Apr 2022 01:20:09 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D732C19C18 for ; Sat, 23 Apr 2022 22:17:09 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id c12so19911974plr.6 for ; Sat, 23 Apr 2022 22:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZFmcLn/pFDeMh7htjVTnOwoz+IWHDFfopBWIvebvgp0=; b=YGE4UXFLnip6exfD2cJSFWxbiaj7cAu6LzDoNlPoMrLOxxldp0fZz7H0jHfW45wkgp jNJCH2lk+KZN5gcKDnTJs0+2mx7jfrn5Z96zDe0oLk1jZGZm4ZmgTiHIIN+46omPKruq 0teFHFOA8bUCBxk6dQNd2OTw+8EOtS9gr5xL4R/MMJtizZ13s2AIMWPTeCdmsDY0zltO t8kahNA2gIF1wDoHq89e7oRgnp900/YNk5lAsMpmC0e6w5eMwgKW0xY0HvQU+fLkXnq/ 0JSHw8BxCY7rl56qY6pOIeHlfFf9Fy9LWEDCUCHJfArtoYg1vNpcyhM1GDOZK7947ozH 7B8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZFmcLn/pFDeMh7htjVTnOwoz+IWHDFfopBWIvebvgp0=; b=n+vqw5QnguQ+QTTxEfwJlQzvEddDPq0SE0l7OIhIMaNT9e9wX8zdTlwV9kg9BszNH6 3LEDYiPt8PaDQNcMl9eF0MgqHPndP63lh2PNTHqgmSUTK5z0RLhzVtq7KThYbxA1OFE7 /Gae3Fcp1aKf2+DxQ4Z/EDQykpAvlu7iWvChi9wtDsEklcdSpFMU+JvpaLhBR1pjcfwz 8H0etAS8/3E1EdFEYOyCtKzaq4Vf5Hsjxvtf9MMh0PDldR8rfMGg7mIgrMD4FjM1iaQK Eu4jV8hDgmpOae5wihib7E2xSRs1XhBy0ZBLKJOLHpPyCQszQRkDvetcS0vuOeUlVRz9 Bu5A== X-Gm-Message-State: AOAM531tc+7qEh9xH2+UOW60TyRPiuOqLWWmMOEilW4PuHaunkOm4qxI WzCmK0iuIu7jEQSse50sXmA= X-Google-Smtp-Source: ABdhPJzvC57/wrSdVCHMu1tWX2JdBDgQh+aIgHUgOyKw5Vbvc9NKP12PEMhkj6DEpT0WJv4E0DoC+g== X-Received: by 2002:a17:90a:730c:b0:1d9:3f5:9a00 with SMTP id m12-20020a17090a730c00b001d903f59a00mr8862014pjk.109.1650777429249; Sat, 23 Apr 2022 22:17:09 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id x129-20020a623187000000b0050835f6d6a1sm7109881pfx.9.2022.04.23.22.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 22:17:07 -0700 (PDT) Date: Sun, 24 Apr 2022 14:16:58 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Peter Collingbourne Cc: Andrey Konovalov , Andrew Morton , Linux ARM , Linux Memory Management List , Linux Kernel Mailing List , Vlastimil Babka , Pekka Enberg , cl@linux.org, roman.gushchin@linux.dev, Joonsoo Kim , David Rientjes , Catalin Marinas , Herbert Xu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Eric Biederman , Kees Cook Subject: Re: [PATCH] mm: make minimum slab alignment a runtime property Message-ID: References: <20220421031738.3168157-1-pcc@google.com> 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 Fri, Apr 22, 2022 at 10:40:08AM -0700, Peter Collingbourne wrote: > On Fri, Apr 22, 2022 at 9:09 AM Andrey Konovalov wrote: > > > > On Fri, Apr 22, 2022 at 2:39 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > > > > > kasan_hw_tags_enabled() is also false when kasan is just not initialized yet. > > > > > What about writing a new helper something like kasan_is_disabled() > > > > > instead? > > > > > > > > The decision of whether to enable KASAN is made early, before the slab > > > > allocator is initialized (start_kernel -> smp_prepare_boot_cpu -> > > > > kasan_init_hw_tags vs start_kernel -> mm_init -> kmem_cache_init). If > > > > you think about it, this needs to be the case for KASAN to operate > > > > correctly because it influences the behavior of the slab allocator via > > > > the kasan_*poison* hooks. So I don't think we can end up calling this > > > > function before then. > > > > > > Sounds not bad. I wanted to make sure the value of arch_slab_minaligned() > > > is not changed during its execution. > > > > > > Just some part of me thought something like this would be more > > > intuitive/robust. > > > > > > if (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF) > > > return MTE_GRANULE_SIZE; > > > else > > > return __alignof__(unsigned long long); > > > > Hi Hyeonggon, > > > > We could add and use kasan_hw_rags_requested(), which would return > > (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF). > > > > However, I'm not sure we will get a fully static behavior: > > systems_supports_mte() also only starts returning proper result at > > some point during CPU bring-up if I'm not mistaken. > > > > Thanks! > > Yes, either way we are going to rely on something that hasn't > obviously been initialized yet, so I think we should stick with what I > have since it's used by the rest of the KASAN code as well. > Okay then we should anyway rely on something not initialized at early stage of boot process. And I don't expect much problem on current version. Thanks! > Peter -- Thanks, Hyeonggon 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C81C0C433EF for ; Sun, 24 Apr 2022 05:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0x0IE6zOm0rRPc47SDzdw6LVh+aMNOy5LFGyUxRReYU=; b=trR3y0Rkiwk3qp VTa+YJPVBbuPm0GMvhLNrOXGOgz/Tg8ucPjJjA586nuvrIbBiWQ1NZA4xwn3OFbjvS0Nny7jXigUG U6xw4SZmt8l35LglSnHMqyHH4ckbDbSFNjtEQcd5AnXXtuVQHxxvlRS4xOEKYorSa7aRoiO1sClys cVCpNenjOBy49lYhnivcSk2sTsQMDC6wh42jEvP1a7mlqkG8x7RdyOE8omTBUSV4V3XG/iriqwkVO sJwj6rnB/Lv8sHNqXVul6d2ZmkONj+fgxkQfbjoN1Um9Q1/+48qole+C5RWzt0QJDUJAZO43RXyRi TFKfNemAKnLtIJrol3TA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1niUcY-005oWv-Qr; Sun, 24 Apr 2022 05:17:18 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1niUcV-005oVp-Do for linux-arm-kernel@lists.infradead.org; Sun, 24 Apr 2022 05:17:16 +0000 Received: by mail-pl1-x635.google.com with SMTP id s17so19917597plg.9 for ; Sat, 23 Apr 2022 22:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZFmcLn/pFDeMh7htjVTnOwoz+IWHDFfopBWIvebvgp0=; b=YGE4UXFLnip6exfD2cJSFWxbiaj7cAu6LzDoNlPoMrLOxxldp0fZz7H0jHfW45wkgp jNJCH2lk+KZN5gcKDnTJs0+2mx7jfrn5Z96zDe0oLk1jZGZm4ZmgTiHIIN+46omPKruq 0teFHFOA8bUCBxk6dQNd2OTw+8EOtS9gr5xL4R/MMJtizZ13s2AIMWPTeCdmsDY0zltO t8kahNA2gIF1wDoHq89e7oRgnp900/YNk5lAsMpmC0e6w5eMwgKW0xY0HvQU+fLkXnq/ 0JSHw8BxCY7rl56qY6pOIeHlfFf9Fy9LWEDCUCHJfArtoYg1vNpcyhM1GDOZK7947ozH 7B8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZFmcLn/pFDeMh7htjVTnOwoz+IWHDFfopBWIvebvgp0=; b=AaCYSEVahdZy9moB8or6qaNem+zMRLRWl30w/ep3uS65XNMSD8YvlXvY/bjbgwHdsF yy1YEnHxwGbWDsxGUxmkQHRY1kTZdF8LLtFWQI5RMaSxdIAHOVHKDxDPCFr+r1G21mBy +g/9Sq41aQpkAh/9Oz1OtnCDZYOImljgdSgW9Pc+ew+ySyYbOtqWmgSuL5B/uaUg1Zlc +t1zZfib7nIXPuA0DZk4TZ1qoFCIV7LBhAB1Xw2wPj5DrYqZbb3ZnjRtTz0lTTYeLB2v bdBpppxzwu2MFZ+wjIzqoXtTuFdgAe3YEmnUrYXaf8+Ndv31RBxYaZqbbg5+gmgz8Suf 49/Q== X-Gm-Message-State: AOAM532meF6+dFnaGxMiGH5Hq3LPDTtrYPQYf//GfZTTKGfY7h+5iWjq 6FHkYmyOn3Xx9X6GsBcU97Y= X-Google-Smtp-Source: ABdhPJzvC57/wrSdVCHMu1tWX2JdBDgQh+aIgHUgOyKw5Vbvc9NKP12PEMhkj6DEpT0WJv4E0DoC+g== X-Received: by 2002:a17:90a:730c:b0:1d9:3f5:9a00 with SMTP id m12-20020a17090a730c00b001d903f59a00mr8862014pjk.109.1650777429249; Sat, 23 Apr 2022 22:17:09 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id x129-20020a623187000000b0050835f6d6a1sm7109881pfx.9.2022.04.23.22.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 22:17:07 -0700 (PDT) Date: Sun, 24 Apr 2022 14:16:58 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Peter Collingbourne Cc: Andrey Konovalov , Andrew Morton , Linux ARM , Linux Memory Management List , Linux Kernel Mailing List , Vlastimil Babka , Pekka Enberg , cl@linux.org, roman.gushchin@linux.dev, Joonsoo Kim , David Rientjes , Catalin Marinas , Herbert Xu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Eric Biederman , Kees Cook Subject: Re: [PATCH] mm: make minimum slab alignment a runtime property Message-ID: References: <20220421031738.3168157-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220423_221715_530880_DA21F986 X-CRM114-Status: GOOD ( 28.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 22, 2022 at 10:40:08AM -0700, Peter Collingbourne wrote: > On Fri, Apr 22, 2022 at 9:09 AM Andrey Konovalov wrote: > > > > On Fri, Apr 22, 2022 at 2:39 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > > > > > kasan_hw_tags_enabled() is also false when kasan is just not initialized yet. > > > > > What about writing a new helper something like kasan_is_disabled() > > > > > instead? > > > > > > > > The decision of whether to enable KASAN is made early, before the slab > > > > allocator is initialized (start_kernel -> smp_prepare_boot_cpu -> > > > > kasan_init_hw_tags vs start_kernel -> mm_init -> kmem_cache_init). If > > > > you think about it, this needs to be the case for KASAN to operate > > > > correctly because it influences the behavior of the slab allocator via > > > > the kasan_*poison* hooks. So I don't think we can end up calling this > > > > function before then. > > > > > > Sounds not bad. I wanted to make sure the value of arch_slab_minaligned() > > > is not changed during its execution. > > > > > > Just some part of me thought something like this would be more > > > intuitive/robust. > > > > > > if (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF) > > > return MTE_GRANULE_SIZE; > > > else > > > return __alignof__(unsigned long long); > > > > Hi Hyeonggon, > > > > We could add and use kasan_hw_rags_requested(), which would return > > (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF). > > > > However, I'm not sure we will get a fully static behavior: > > systems_supports_mte() also only starts returning proper result at > > some point during CPU bring-up if I'm not mistaken. > > > > Thanks! > > Yes, either way we are going to rely on something that hasn't > obviously been initialized yet, so I think we should stick with what I > have since it's used by the rest of the KASAN code as well. > Okay then we should anyway rely on something not initialized at early stage of boot process. And I don't expect much problem on current version. Thanks! > Peter -- Thanks, Hyeonggon _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel