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 929DEC433EF for ; Mon, 13 Dec 2021 21:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243495AbhLMV5S (ORCPT ); Mon, 13 Dec 2021 16:57:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243460AbhLMV5Q (ORCPT ); Mon, 13 Dec 2021 16:57:16 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 449BFC0613F8 for ; Mon, 13 Dec 2021 13:57:16 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id y16so20633736ioc.8 for ; Mon, 13 Dec 2021 13:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SMKUwfdVnZa0OC/+PlApSfDHQCaCth1VpxrX4nAiO2A=; b=ic0VaoHZRb6KjXHIJ3P+2qZGi8j7+ESfuWNH5jXxukMRB/UeYCBIULZCpgwxV/LTJA +OuksLZgOljy73DZeiFIyo4CHIHPJRsot81EcZK0HMqGAeved3eeruKibnE1vQFk/QOM 0ZnHOgTJ/J9nu1/ENFbVzXnsXyI5ZDNR5tPOajcwg2HvmLbGbzJD9Y/C2GCOjShgtc1/ m8zmk8F0OOh7T1WzI6zzvRPEppf8y/gAimwGCHf4CxAOxCMk1DjdTCT25IAcxOu9QX03 aACzybsyQxehSm7g4oYLMqdRj6um078xfE58+gEo1TXQCQHiiwN5Dw5NVl3V5rSQJ0zM gvpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SMKUwfdVnZa0OC/+PlApSfDHQCaCth1VpxrX4nAiO2A=; b=hzHvUGUiFh+ZHkF5tas90xEqXh0ehuzocYn4WU4wsKz1W8R9SLhx4OsU2LcjQKmrHN 6fUJVp67XRGRRwK4Y5BnurD1951Y1tibIq+s+qT8oRmdytJfbS4kqmQMwmZzNCXMZ+DL uPgrYlC7q+WNV2/YFrYCywHNZSHaigxOeAFBkKDvurwikjAwcOgxvOsAirgXZXqHD2LU SZsubgAIh9aIE6Z1DL//ylF7LpPUwT7V1fgtas6xppNTGXpe3caiX3u4jbSZsOBxqS3a F3EkyFE7WQbpitJLe1N9Y4ZwLbgmD08wWvCQHayKTx6cK9lTuvARP0xCf3e+xLze1uZo XeTg== X-Gm-Message-State: AOAM531JVkejPilcj80441s1VgvPnIQN9+21JMGlcp11To+kKEoxURMD Fo1PN3XFhDMRRdiHN0qNeGgU8wNKwBSHo/KAnTY= X-Google-Smtp-Source: ABdhPJzEm7BmcDz3kvXaVml6MCEm0bMB1AEfgSyLQveI2p4I5q9R2vEr5vD0+TNs9r9GQeXSfrkedE+vghQ57a6w0dE= X-Received: by 2002:a05:6638:2608:: with SMTP id m8mr562528jat.57.1639432635722; Mon, 13 Dec 2021 13:57:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Mon, 13 Dec 2021 22:57:05 +0100 Message-ID: Subject: Re: [PATCH v2 08/34] kasan: only apply __GFP_ZEROTAGS when memory is zeroed To: Catalin Marinas Cc: andrey.konovalov@linux.dev, Marco Elver , Alexander Potapenko , Vincenzo Frascino , Peter Collingbourne , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Andrew Morton , Linux Memory Management List , Will Deacon , Mark Rutland , Linux ARM , Evgenii Stepanov , LKML , Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 10, 2021 at 6:48 PM Catalin Marinas wrote: > > On Mon, Dec 06, 2021 at 10:43:45PM +0100, andrey.konovalov@linux.dev wrote: > > From: Andrey Konovalov > > > > __GFP_ZEROTAGS should only be effective if memory is being zeroed. > > Currently, hardware tag-based KASAN violates this requirement. > > > > Fix by including an initialization check along with checking for > > __GFP_ZEROTAGS. > > > > Signed-off-by: Andrey Konovalov > > Reviewed-by: Alexander Potapenko > > --- > > mm/kasan/hw_tags.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c > > index 0b8225add2e4..c643740b8599 100644 > > --- a/mm/kasan/hw_tags.c > > +++ b/mm/kasan/hw_tags.c > > @@ -199,11 +199,12 @@ void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags) > > * page_alloc.c. > > */ > > bool init = !want_init_on_free() && want_init_on_alloc(flags); > > + bool init_tags = init && (flags & __GFP_ZEROTAGS); > > > > if (flags & __GFP_SKIP_KASAN_POISON) > > SetPageSkipKASanPoison(page); > > > > - if (flags & __GFP_ZEROTAGS) { > > + if (init_tags) { > > You can probably leave this unchanged but add a WARN_ON_ONCE() if !init. > AFAICT there's only a single place where __GFP_ZEROTAGS is passed. Yes, there's only one such place. In a later patch, I implement handling __GFP_ZEROTAGS in regardless of having __GFP_ZERO present or not, so adding WARN_ON() here and then removing it probably doesn't make much sense. As per what you said in the other message, I've left this unchanged. Thanks! 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 74E66C433EF for ; Mon, 13 Dec 2021 22:29:50 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KCUtyh83DR3qOWCC4EcYiJ76XAt+J7mr2QSZdcUU5Gc=; b=dlzn+o9/FZQUhS IfqCYpzU6Ej+oBgLclsIWejYjMAcDM9IhxAUr72qb4YQ1R6N2iw0VoNNzgmcWQ5qDFi3domlUY+ny YgWHfsLZa4ZG9q2iq7lzCFjxYLOP8BTfQ1+P0qFMXwhj02fQ3FqrmDHERy15n6QBmsUDOQHLmHNMm FESsvM8f15VhnULuPWODoRj1vG/M6RY2wSwWt+vaqWp6iTqpma3fF1MXPnD8m89m29T4uo9GmtmDs nXyDVhHgbAjm5fuvmIZiAeeTBjqtVwIm4SaLJ94RSnEleA/M/2xBdJLJqw1L484j3fwtIUoXbdCeQ LmbspflKalxLP86wKOFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwtnX-00BjcW-AO; Mon, 13 Dec 2021 22:27:56 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwtJu-00BXfr-Ha for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 21:57:19 +0000 Received: by mail-io1-xd2b.google.com with SMTP id p23so20633087iod.7 for ; Mon, 13 Dec 2021 13:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SMKUwfdVnZa0OC/+PlApSfDHQCaCth1VpxrX4nAiO2A=; b=ic0VaoHZRb6KjXHIJ3P+2qZGi8j7+ESfuWNH5jXxukMRB/UeYCBIULZCpgwxV/LTJA +OuksLZgOljy73DZeiFIyo4CHIHPJRsot81EcZK0HMqGAeved3eeruKibnE1vQFk/QOM 0ZnHOgTJ/J9nu1/ENFbVzXnsXyI5ZDNR5tPOajcwg2HvmLbGbzJD9Y/C2GCOjShgtc1/ m8zmk8F0OOh7T1WzI6zzvRPEppf8y/gAimwGCHf4CxAOxCMk1DjdTCT25IAcxOu9QX03 aACzybsyQxehSm7g4oYLMqdRj6um078xfE58+gEo1TXQCQHiiwN5Dw5NVl3V5rSQJ0zM gvpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SMKUwfdVnZa0OC/+PlApSfDHQCaCth1VpxrX4nAiO2A=; b=Nf0vY35bczKJwfY1A4KJ1u6DGe6zNwuBskKGQGxOzY0Nhd5r4kktXiTQ7D8a8/NT7B 0YQR+JVebNjjQ42lunW1vEnGR4GBOJPHXMMJRJIbl9kK+bv4qaQqZCuV7acZbNDw61ED cIgcrgOGLVBLnxa95YZvzniRrcdBfr1ndOKCh7rEqx/DpZ5O1XZimP9q8gx1Jh1MNIq7 yAnxBlfL1y9I0sJPxmDk2UXT9RAJmJS2pSPrWIuBqWpmiLABE/7tPLyRCN0DhaNNeTG/ wpvXXdEps6eOFL0pk0k/BvzTAi+YIezPQoAp04sCFfZicMO6HTToe6UmpSeFQYs7qOCE 3bbw== X-Gm-Message-State: AOAM533kfnkdoAQXLC712vqGLgq2oGZ0WyESSuNI/1Zuw05pTuxmOD74 lbkr8OiAPDpRztLparzTIdcPC5wiUGg7TQX2yyc= X-Google-Smtp-Source: ABdhPJzEm7BmcDz3kvXaVml6MCEm0bMB1AEfgSyLQveI2p4I5q9R2vEr5vD0+TNs9r9GQeXSfrkedE+vghQ57a6w0dE= X-Received: by 2002:a05:6638:2608:: with SMTP id m8mr562528jat.57.1639432635722; Mon, 13 Dec 2021 13:57:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Mon, 13 Dec 2021 22:57:05 +0100 Message-ID: Subject: Re: [PATCH v2 08/34] kasan: only apply __GFP_ZEROTAGS when memory is zeroed To: Catalin Marinas Cc: andrey.konovalov@linux.dev, Marco Elver , Alexander Potapenko , Vincenzo Frascino , Peter Collingbourne , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Andrew Morton , Linux Memory Management List , Will Deacon , Mark Rutland , Linux ARM , Evgenii Stepanov , LKML , Andrey Konovalov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_135718_633033_C733A1A3 X-CRM114-Status: GOOD ( 21.54 ) 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, Dec 10, 2021 at 6:48 PM Catalin Marinas wrote: > > On Mon, Dec 06, 2021 at 10:43:45PM +0100, andrey.konovalov@linux.dev wrote: > > From: Andrey Konovalov > > > > __GFP_ZEROTAGS should only be effective if memory is being zeroed. > > Currently, hardware tag-based KASAN violates this requirement. > > > > Fix by including an initialization check along with checking for > > __GFP_ZEROTAGS. > > > > Signed-off-by: Andrey Konovalov > > Reviewed-by: Alexander Potapenko > > --- > > mm/kasan/hw_tags.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c > > index 0b8225add2e4..c643740b8599 100644 > > --- a/mm/kasan/hw_tags.c > > +++ b/mm/kasan/hw_tags.c > > @@ -199,11 +199,12 @@ void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags) > > * page_alloc.c. > > */ > > bool init = !want_init_on_free() && want_init_on_alloc(flags); > > + bool init_tags = init && (flags & __GFP_ZEROTAGS); > > > > if (flags & __GFP_SKIP_KASAN_POISON) > > SetPageSkipKASanPoison(page); > > > > - if (flags & __GFP_ZEROTAGS) { > > + if (init_tags) { > > You can probably leave this unchanged but add a WARN_ON_ONCE() if !init. > AFAICT there's only a single place where __GFP_ZEROTAGS is passed. Yes, there's only one such place. In a later patch, I implement handling __GFP_ZEROTAGS in regardless of having __GFP_ZERO present or not, so adding WARN_ON() here and then removing it probably doesn't make much sense. As per what you said in the other message, I've left this unchanged. Thanks! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel