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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 273FBC433EF for ; Sun, 3 Oct 2021 16:27:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BBC8061AF9 for ; Sun, 3 Oct 2021 16:27:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BBC8061AF9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 62AD06B0071; Sun, 3 Oct 2021 12:27:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B40D6B0072; Sun, 3 Oct 2021 12:27:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42F23900002; Sun, 3 Oct 2021 12:27:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 3491B6B0071 for ; Sun, 3 Oct 2021 12:27:43 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E4D348249980 for ; Sun, 3 Oct 2021 16:27:42 +0000 (UTC) X-FDA: 78655657164.09.7CF93F6 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by imf16.hostedemail.com (Postfix) with ESMTP id A61F9F00036A for ; Sun, 3 Oct 2021 16:27:42 +0000 (UTC) Received: by mail-io1-f47.google.com with SMTP id h129so17584548iof.1 for ; Sun, 03 Oct 2021 09:27:42 -0700 (PDT) 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=U5w14pACpoxsQ3TFrs7KmyZVY7r/vaDnkMZUZO1ngik=; b=MXjrW9mY+a/gXFgLG6oQScrnY0uleIHBIcH9doKJKaK1+66Z3XPGlHC1yGYKZJ7upQ GRO1je7knBI7usd9rQ9oQGx2iNhC8vC3F0w7G9G3IgmiLkpgug27fp5RTlVuGK1MREHm hjX1vfP1qukT9Mcba/dSw7m1pMSFECYCIvy3tUNIer2u1PCVae+ZhKpBk9cH9aDv7XLq 8Tn/w5K/ERUb8eyfS7OezaRjrfnH7g5oiEdIs2J9khCX5nca43xko5mnDhlgElGZk2ZX u+ndPrDlb3+WXdO24WfDhdncWjSD2xY4Au+Fxv/SRyvt/6GB5z4VH3W4016eFQGWzhas ZKDQ== 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=U5w14pACpoxsQ3TFrs7KmyZVY7r/vaDnkMZUZO1ngik=; b=I9Tmv7PogtsVh63SHfpey3jRUzVCMDrxj/4uli2Pm+Irrfn0I9EuJsB5AsaUhJn+N5 xPt+r0ynzrmgPc+qFOul2KkzxH6QsgHcsexwNQ4adGXsqTOYLWB0sj4tpDf8wQ3GMqOK Rg3xGUaxYGQgb8E/m0hnMiGL0YR0QJdj9yAB0RbVqVWKw0X8cluVdj/mHW56K4NiDjt3 Bi7Y/FZJdXfKcRTDwhsgNwn8NR3zEh++VkXs+vOgzLVdXD5Lb7Po4tFOzvFtBBelzs8M DrOPhJy8rUWOTwW3YPeZ6QDYok/1mrxu+LzZ6U1/X2cuPkj+JWD/Fqd+np6o9KWAB7Cb brZw== X-Gm-Message-State: AOAM533MqwEXI1LSrEgMcOc9LKnbQT5ajG45XrJFbTbxEs8Pv/LYknzZ r/1r2KwrWV7JpsaVS8+agUok/1U8o7qe6rq9mOc= X-Google-Smtp-Source: ABdhPJxVrz3rT6h1KZm+9SHUacnquEAHScQiTtCF8pHLENV9hptvWJl26PtoqE7yl5R+Y0mNFafi6gfZjEA9ZDrzX5g= X-Received: by 2002:a05:6638:16c5:: with SMTP id g5mr7339293jat.130.1633278462090; Sun, 03 Oct 2021 09:27:42 -0700 (PDT) MIME-Version: 1.0 References: <20211001024105.3217339-1-willy@infradead.org> In-Reply-To: <20211001024105.3217339-1-willy@infradead.org> From: Andrey Konovalov Date: Sun, 3 Oct 2021 18:27:31 +0200 Message-ID: Subject: Re: [PATCH] kasan: Fix tag for large allocations when using CONFIG_SLAB To: "Matthew Wilcox (Oracle)" Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , kasan-dev , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: A61F9F00036A X-Stat-Signature: j6as8m18sscifs1y7b8fwm9qmomr7ch5 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MXjrW9mY; spf=pass (imf16.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.166.47 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam06 X-HE-Tag: 1633278462-35432 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 Fri, Oct 1, 2021 at 4:42 AM Matthew Wilcox (Oracle) wrote: > > If an object is allocated on a tail page of a multi-page slab, kasan > will get the wrong tag because page->s_mem is NULL for tail pages. > I'm not quite sure what the user-visible effect of this might be. > > Fixes: 7f94ffbc4c6a ("kasan: add hooks implementation for tag-based mode") > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/kasan/common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > index 2baf121fb8c5..41779ad109cd 100644 > --- a/mm/kasan/common.c > +++ b/mm/kasan/common.c > @@ -298,7 +298,7 @@ static inline u8 assign_tag(struct kmem_cache *cache, > /* For caches that either have a constructor or SLAB_TYPESAFE_BY_RCU: */ > #ifdef CONFIG_SLAB > /* For SLAB assign tags based on the object index in the freelist. */ > - return (u8)obj_to_index(cache, virt_to_page(object), (void *)object); > + return (u8)obj_to_index(cache, virt_to_head_page(object), (void *)object); > #else > /* > * For SLUB assign a random tag during slab creation, otherwise reuse > -- > 2.32.0 > Reviewed-by: Andrey Konovalov