Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5658506pxb; Mon, 28 Mar 2022 15:37:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVFrHUmNpxRO4xSee/WT/Y0ZPIbjnKRbCeqze0WgleKtwMg6AFlWphXtN9XLEpFVxcUpVb X-Received: by 2002:a17:903:32cf:b0:154:4a39:295d with SMTP id i15-20020a17090332cf00b001544a39295dmr27586142plr.40.1648507032128; Mon, 28 Mar 2022 15:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648507032; cv=none; d=google.com; s=arc-20160816; b=eQF7K+0YKM1uu0FaonLmbnDAQCcQjmJJLxBu1ns0QGmk2LwQyVFGlKBE7/QLc515t7 aJ4fFWppGQistXl5utUD+8R4G9OA4Ey9Wxzz4TPnAd8QQVZS8N/G8/GoE97wRsYr5zvb EeBzODm4AAidJXir47OvrmUxZ4yyGoZKEevLgNbAOgxXfDIDbAqCkjPBcTvekjpuXSaI Z9eEfU0gT5NZ6uFmVvWgK179Q/3/WQ1QsF9WV9djZpPJo6QwQJ5xi6gJ/p3xhPRK1ekw He1DHBRPuvi9gbvWIT897FO4Ts1fxg0m5an52E0Icvrhvrpf5UZjll6kFYkHR6eQUcSx 8rbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vdyfkkOtVcY9wMmcQ9hL8yLIG6KQpQUvBHwAp6nqkPs=; b=pl9zuvThEyNv+M2j0PV7O+8svikuwp3KCr6EBnSfs0cGOc9Xfos2bblkt6NOCfSd6O rMwMnwITTNK4deKtYossvuKcyWES8M2AFxWD/yztpfZ73l2+RmxD6ZO97wRN9HXgQd5G h7+adR1qD3AmMGqYQddsBaJU7HrjCywIxCW4mPx9TN8LHDHIYgGAPwVMZNrXZfm+B+Oi 57L841FbZ78NAjIYeM2NQQAlNAdwJNthct/0Vkems5JTqhR9+vPw5yJ6kNYG/wg2aO+y VKQ0LS3+REJ7xUP85ALtL5MFGvoe05CDvC5Bj/f2CBmHzSXhLNTNKvGa34Cgd7RpuvbB Uhqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Rfi7hxBh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y1-20020a170902d64100b00153b2d165cdsi12939625plh.469.2022.03.28.15.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:37:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Rfi7hxBh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 900F11DF86F; Mon, 28 Mar 2022 14:45:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233833AbiC1BjM (ORCPT + 99 others); Sun, 27 Mar 2022 21:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbiC1BjL (ORCPT ); Sun, 27 Mar 2022 21:39:11 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2774F9E2 for ; Sun, 27 Mar 2022 18:37:31 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-2e592e700acso133361877b3.5 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=vdBce7yC1iu26ZqvP/3hzKd9gh6Oq3cojY9B4ct5A8QG69PehYw7OdOjeFhmWbJEMc nCo87MEbozZ012BLh+F/5T3Sk6oSE82C9MWoz0xD5gtMpyh/4AGXjJsD0WoeC14JkHNc OQzMsyvUgG4kLJn04tLScincgJ+Jf6d0JbaOU1cQsoZVpdW8n+T3Vm4LNdCOkHEfs2AY wRi2hiO0cXtLEkg0Lh/RCUU65GnKE9et+b02TmHoCalYswLFlEg4GtOf6UqLe5fQCaBu 7uyIDmsE4FBlJ3TiejYuRwmHXs5Ikqxw+Xyqe2vbf/EYElmHcEYozjSYH4HXoCaIoQcT Z24Q== X-Gm-Message-State: AOAM532+V4EfzhWvHSsUD9/o1Ipgr2kYnhqs1KuxSgjtgkoo85WfZLDH kp2QXK0TZnHLQSTZb2pPgPtzDOluOO35VczIAYs5zA== 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.