Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp666845pxb; Tue, 5 Apr 2022 18:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzels2tK9nAl+IsltdAk76PlrHOF+YnNcYsZgIXZJ+NOdnSpTJwh4uCOHNAHxu/pzJxtSP6 X-Received: by 2002:a17:907:6e2a:b0:6db:c440:532b with SMTP id sd42-20020a1709076e2a00b006dbc440532bmr6085788ejc.95.1649206801466; Tue, 05 Apr 2022 18:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206801; cv=none; d=google.com; s=arc-20160816; b=J1p9HsdgzuDJfCxqJlm7J6lHxhKiM30SqZDs/2lTxFm/GsDVKeMlwqX6Sv2jjgB8ke 61hpwoUy78hrFvNf75x/zUzs/Q+ILXi4ydga1U+PczymUPIFbBpzkdSny5EcDILc07s+ axmNqaKHu4QtU4RQhz3th+d+faCk2xnru16HATwIKKzpAHP6pdpdeWphQivyQLtBEtj6 uihXTiTVIp5NDzz0sCACw4ETlBUEXVsdPgNzSOdo1QA2HCjXcuGJLTT9tMBbMnYV7Ssa UiTR0X/5wkhXR37CBTMkSCxNN3fCGbyAeqMu0+fPp5p12x3lQZmQtRjMN/GqCsrKmuTh XcHQ== 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=2SimPAKs09uy8D1bdYGJtcXQo+ox9gaZUx+lBrFq0+k=; b=eFgVCtngi4CDBhPMxbPYffl9gE253SHhAUy2RDtCf8Hsvj8CB1Q3cdxh78JULz87Kf Jxb0BgOx7a7S9y1KATwSyZVR9QS7he2kEb+3qQ2IMWPW1u8iKZZT148B9h8V++ys6wnT P+Q+BCVsYrfgmmbbHqwNksigh7be1h8D+mJLk9uWAsCy2k/VppDKJdDIPSDGmybQJrLG YsaflfYbr1z7nZEoDXgKe4dCcPlO47JuBRjWadNn/2HkuxrhbBY2DKMpHcDH845sCy+5 k47klLL7OEDVplVt6uG4P+RODyGwBicd3LJIK/q9McxKantFAzX1DgKUVqaNSU+KdUY0 c9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B99IpNuD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id we23-20020a170907235700b006df76385c5bsi6329379ejb.251.2022.04.05.17.59.36; Tue, 05 Apr 2022 18:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B99IpNuD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237932AbiDEOda (ORCPT + 99 others); Tue, 5 Apr 2022 10:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238743AbiDEJcp (ORCPT ); Tue, 5 Apr 2022 05:32:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC7C2709; Tue, 5 Apr 2022 02:19:59 -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 2921161654; Tue, 5 Apr 2022 09:19:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E083C385A3; Tue, 5 Apr 2022 09:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150398; bh=YUCc5UqSEUaFbLJxDPjS3UTbOuylShiOg0+98LUc49c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B99IpNuDbtcSg8RjORkuJmwcD1vKs3ECnJwn/mxUUMKovGZYuNnxk+loWGhcciYe4 wuhG+axQ7fcQNpQuPF5C/XQqKMZ++OVot4lrvGD5+ZKzXeKlfluD2Qt3mFXL5AoYYk MkjeOL/gkdQvItuH5lGwOEw7NMDyhxjpluoXTlB8= 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.15 006/913] mm: kfence: fix missing objcg housekeeping for SLAB Date: Tue, 5 Apr 2022 09:17:48 +0200 Message-Id: <20220405070340.002225263@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -3429,6 +3429,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; }