Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp726723pxb; Tue, 5 Apr 2022 20:33:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQce+khQn8oMAtDqr1qxx2lgiilYOGmO2o3vYEzo8I6RIJk5v5JONkH/t/ZkEbqxvDnLpk X-Received: by 2002:a17:903:18c:b0:154:9ee:ced3 with SMTP id z12-20020a170903018c00b0015409eeced3mr6566208plg.170.1649216012385; Tue, 05 Apr 2022 20:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649216012; cv=none; d=google.com; s=arc-20160816; b=o7NGOleG+QVW5qcSHcGfVb85XfHhLdW5rq1hA1P06v1Z2pxUy4p4OKpHmxo2sxqaKM UihNXcNyy7sfJMUx3A0hHcdRntPffC2gaAP/Aq7XzsfARYIidv34BRdodnSPWWeFfNro QWe6EUXhPIjAzyK+ZxXsl92zrTEzM1d7NWA9ntPyJBXtb7pv/OHRdEDs8ck2H/8j3567 OfeH1sGEzH9V39BgbJJSZ9MdvVUVcrv2Q0T8Z3St7toqmRMl283Bwd5v7x+7oHJllTNV x8QEMbzsyslj0e5Am/cD2ghBLgEUeyaCB2xbqyrXUyWd/uMpHnNlnLnBdwvF+nKNnM06 RNkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KpjtgYnfQ5WgT2jaLTqZ7VMVRC9YoZKS7GiN3JZbjWA=; b=R562fjdFcmEfQH3hpqNjsadnzAzLVO/u1Dqk6rvEs8VKR0ixXmOrAxKR8+XSbWlJDM ZCPOcpcvgGjJBp+BvaXDi7zNLVRkLqrHY4DnHL98gJoFunr1dSypVrvpEjkhfsPPlYUV 0ZdkqgWyaREMbDqsGZN8f7R9EJ2kTMLxsqGzRqNKflEHgnfldhu5FkZW1NQDDL07ZHD6 HIIVepcQo0mBYIJ040ZmXxONdMGzD3JTaB4EUqNsPOPSxIF9tGAXAyLB9qamIuAq6cb6 r/yofhJjUN0LlMrrR9sdkbLWFQjYabkkWfCxxvs2lesQgngGf7SRyChFB5Ey61gCEhGU JAPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=00rhudUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pj2-20020a17090b4f4200b001c6ad84f9absi4150362pjb.48.2022.04.05.20.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:33:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=00rhudUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E13512C9EE; Tue, 5 Apr 2022 20:04:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbiDEHlf (ORCPT + 99 others); Tue, 5 Apr 2022 03:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231786AbiDEHlS (ORCPT ); Tue, 5 Apr 2022 03:41:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FCC4B87E; Tue, 5 Apr 2022 00:39:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C167615CD; Tue, 5 Apr 2022 07:39:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96BB5C340EE; Tue, 5 Apr 2022 07:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144356; bh=O3jGIdgoaaz5pXBTGHclq98t3wbo3iwsr7Zql23OkKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=00rhudUIoRIA2v/V7GrpmAWGdeK0aV53tBKrRshw+VMc/4s2wKNpe+VBgWdD/buRn ar+qAz0wLVqLwhim4rZI+up87vcEPzJAPzGTWfHCbGE9fbDkttVZo/kfH7+cU+nqYy UveOPrqm9ROhtwsJU7ZqsMUX+aOk/SBSunGsAjhw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f8c45ccc7d5d45fc5965@syzkaller.appspotmail.com, Muchun Song , Dmitry Vyukov , Marco Elver , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 0006/1126] mm: kfence: fix missing objcg housekeeping for SLAB Date: Tue, 5 Apr 2022 09:12:33 +0200 Message-Id: <20220405070407.720979901@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 From: Muchun Song commit ae085d7f9365de7da27ab5c0d16b12d51ea7fca9 upstream. 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. Link: https://lore.kernel.org/all/000000000000cabcb505dae9e577@google.com/ [1] Reported-by: syzbot+f8c45ccc7d5d45fc5965@syzkaller.appspotmail.com Fixes: d3fb45f370d9 ("mm, kfence: insert KFENCE hooks for SLAB") Signed-off-by: Muchun Song Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slab.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/slab.c +++ b/mm/slab.c @@ -3421,6 +3421,7 @@ static __always_inline void __cache_free if (is_kfence_address(objp)) { kmemleak_free_recursive(objp, cachep->flags); + memcg_slab_free_hook(cachep, &objp, 1); __kfence_free(objp); return; }