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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BD6BC433F5 for ; Mon, 28 Mar 2022 01:37:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 692158D0002; Sun, 27 Mar 2022 21:37:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6420E8D0001; Sun, 27 Mar 2022 21:37:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BBC38D0002; Sun, 27 Mar 2022 21:37:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 3AD068D0001 for ; Sun, 27 Mar 2022 21:37:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 15378120D1E for ; Mon, 28 Mar 2022 01:37:32 +0000 (UTC) X-FDA: 79292082744.01.5687A07 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf01.hostedemail.com (Postfix) with ESMTP id 70F0F40035 for ; Mon, 28 Mar 2022 01:37:31 +0000 (UTC) Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-2e612af95e3so133058977b3.9 for ; Sun, 27 Mar 2022 18:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vdyfkkOtVcY9wMmcQ9hL8yLIG6KQpQUvBHwAp6nqkPs=; b=Rfi7hxBhwncJcA6UrsQIGEghkipmREBwWT98w90zq3S+ccieDw4MAGLwBjXxOVeKCT 553yC0w6J0Jf0t61aWYg8zg9mXKcga5oC/L7X5Mj9i0PR/bl+p3VyVnSNZwa8+b2Rvzx uO6W/pYbEg9FNTK/dB7hiDqblVbBWjgVfo1l/3nS4i0Jh5oK7BI3JoDMV1YQdERYXWlp JKwjCTbD1sZ7In5mHKAluWV1Wo3VLtMdgKmOd/DWhLerVTgUA2+uXQJmcP/7KowMt3gZ FtSp/qHu5aDq/0OIPIwrWA04SEXCL5rO8oduIAR/udmgv/E+fmGkFuqPRX3LHt5CKmK7 0Uhw== 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=vdyfkkOtVcY9wMmcQ9hL8yLIG6KQpQUvBHwAp6nqkPs=; b=cK7ZCbEEK8cw4zArw+YWjkckLHUSpRlPB2zy0mXYka7Y0j09+M8sOXwQJtnFxwmVuu X/ZS8PeBLSF5apsW5/A21MzcysCpVKeV4pIKbFoGsWBKrRjRZ0bYD3Or8k/X+khX5zjX j1Lgar/2E3QsOO+YeQONL6zbEGnEi6ujrawU/x2XXhHc3VYEUWa7mQAD0jKOadwI12vf s6uGgouqkkCOrKw2ByQpFkkaDueyvut9LUEGoGPKXjG/WmcdGtnRjooK7JH0UP9IkQlz +ou3JrY/3fO+8J7P4NveaUdTf1oUSBHZbmE4Z6NsHoz/RuPNZLQ/x4stGUxFIPC8HaiA pSlw== X-Gm-Message-State: AOAM5326TabC6+sIEZT2l5c3WESk2T1TO0MYf9f2Cxoz5eSb/cW33jcg cFPpNKNvN7rjuaiilyI1M0VQKU118Lg7LeYQHuphTg== X-Google-Smtp-Source: ABdhPJy9+BoSaiENb1bphoFlDEWLJCsHmooE2AvZ2h/Awh7on9o4cO/L7l+jsKSOG4PmHwsule42OZw35AzFcgduwlY= X-Received: by 2002:a0d:f685:0:b0:2e2:22e6:52d7 with SMTP id g127-20020a0df685000000b002e222e652d7mr22805715ywf.418.1648431450769; Sun, 27 Mar 2022 18:37:30 -0700 (PDT) MIME-Version: 1.0 References: <20220327051853.57647-1-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Mon, 28 Mar 2022 09:36:52 +0800 Message-ID: Subject: Re: [PATCH 1/2] mm: kfence: fix missing objcg housekeeping for SLAB To: Linus Torvalds Cc: Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , kasan-dev , Linux-MM , Linux Kernel Mailing List , syzbot Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 70F0F40035 X-Stat-Signature: f8ctwmeeaob1tcrpjiqn6h58gt3thypd Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Rfi7hxBh; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-HE-Tag: 1648431451-990054 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 Mon, Mar 28, 2022 at 5:08 AM Linus Torvalds wrote: > > On Sat, Mar 26, 2022 at 10:19 PM Muchun Song wrote: > > > > The objcg is not cleared and put for kfence object when it is freed, which > > could lead to memory leak for struct obj_cgroup and wrong statistics of > > NR_SLAB_RECLAIMABLE_B or NR_SLAB_UNRECLAIMABLE_B. Since the last freed > > object's objcg is not cleared, mem_cgroup_from_obj() could return the wrong > > memcg when this kfence object, which is not charged to any objcgs, is > > reallocated to other users. A real word issue [1] is caused by this bug. > > Good that this looks sorted out. > > Patch 2/2 seems to still be up in the air. The patch not only causes > build errors, but it looks really very odd to me. > > In particular, you do that loop with > > __SetPageSlab(&pages[i]); > > in kfence_init_pool(), but that is *not* where you set the > MEMCG_DATA_OBJCGS, and instead do that virt_to_slab(addr) dance later. > > That looks very odd to me. I think the two should go hand-in-hand, > since that __SetPageSlab() really is what makes it a slab thing, and I > think it should go together with setting the slab state correctly. Right. It is a little odd. I'll improve it in the next version. > > Finally, is there a syzbot report for that second problem? No. The second bug does not trigger any oops, so it is hard to be seen. It is just my code review. > > Anyway, should I apply this PATCH 1/2 now directly as the solution for > the dentry issue, or should I wait for that second patch? They seem to > be related only indirectly, in that the problems were both introduced > by the same commit. > I think you could apply PATCH 1/2 now. PATCH 2/2 is another issue not related to dentry issue. Thanks.