Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1117369rdb; Mon, 19 Feb 2024 05:02:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXJz3vNxsBOYslEjeKBnl9oRl6T55MdUW9cnTC52azfp5NxsxxPnU/K2b4q9SAgy24/yZJn18DJ+buX/KSUeHVI/K7bGxYKMTRhjRgjow== X-Google-Smtp-Source: AGHT+IG1Dt1/+238DgenN9k0TTE9+WAbE8eR1zg319BGo34vwo0nJgJw9n/qwvWGESnYLjDlQbKf X-Received: by 2002:a05:6214:248f:b0:68f:8293:c29c with SMTP id gi15-20020a056214248f00b0068f8293c29cmr945669qvb.43.1708347770545; Mon, 19 Feb 2024 05:02:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708347770; cv=pass; d=google.com; s=arc-20160816; b=BDcJzY5lbXYxQAg6p6VBz4FnbbYFaLym+s0AByBw17KZAH2WnrLSjAqX7vyls6rgEt zyFVxGKRFrAHUNI30dEo6Cw9xCJoJO9P8QjC/1AkQ6y3gwezljbrVp+s1RF1PFqUIrUh LuKeFoGLDNOB2PkQIh+vOQmgVaDSrEF/OPWSepI6D02+MPysp2ZiydC5OmTNM30DIe4B MuULqjOy77MJKhN0YU2/PAQXUsVCJbGU6UKFsTg8p1/N13LH08XvYY45HwSVQM4ED5dz UmI6D8tkNlb6Lhtx3eTfM6gTl1IQMX0HkvSY+0bSQaf8RAnfGOe+7F6NMQf0sZBcF7M+ wV0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :references:in-reply-to:from:organization:dkim-signature; bh=TwNcCYcnKDEqL3qwv8hEJSNKkkqFQa2yy0ZaFvuYG/I=; fh=ReBVB4u9dptVVPamk5mhHV9fnQxXQ2AYbo3iO9CZz/Y=; b=ybyl6d5SlqcBypGMeMSOI3dGCtvOIQ+VlpjzSwHZnxjeMGmrRJ3pQi2h6XmwU2cw1T fkP621u3axnmzsbgXV6kpulbhTitd4cn6FNopo8cfna/unb4gLEKkPv2c888SS/4AM1M htC2TAoA/wVEPN3mW5pbRiuTK8bf3u9HMwwJQT76GvciCSDWgGx02iGdBGMACiuA9hvR sckwRot3B50Uq/V0lF11OF7NK1sRExkdx0fQY/8iynlTITP0zlxceXW366yrYnv4sOxD 6orZvnnQAjmfLLcTox5wES8W057gxhKIBDOXoZzbD/SLWJ+u5TnoWG6NZBJC4u/fP0kH 5YDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ExfjIwt2; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kj25-20020a056214529900b0068c5a407f23si6077940qvb.603.2024.02.19.05.02.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:02:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ExfjIwt2; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C6BB41C22B21 for ; Mon, 19 Feb 2024 13:01:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 685953611F; Mon, 19 Feb 2024 13:00:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ExfjIwt2" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF5DE2D610 for ; Mon, 19 Feb 2024 13:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708347655; cv=none; b=NT1NZeHGHpLH/8SdYTB/ZOATjrJ0BJd1LwuDazey4Z3Kq49OnnTImAFfhgnVrrjaxpWTcKmtDFa43dZpsXRsW54YKDFP2368u+we8/5o+nZD7xaQh3KT59jXMlnKtlEA31wex5bW12yekc3slvsCKgvILWewHeLgEuai/sdPrjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708347655; c=relaxed/simple; bh=dHWiwi/4MsahdbBRvdAXd0W5GApiDgwNTSRWlu2vpSE=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=pC8ta1as4i7bjjHp59+Ek+4SzTgbLjA746jSVLsR7drRC1AaKn0AJBo1HXy3oCQcIqUeQXEN92EFT8mADwj3TdzYUBmkhZF4iU0HxfY+t9lz5dtEwVRUeGq3c3OEeyGrklxMOlOpoYWdHNBQAok5zrVFbYmOaL1578Hhm9CbIQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ExfjIwt2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708347652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwNcCYcnKDEqL3qwv8hEJSNKkkqFQa2yy0ZaFvuYG/I=; b=ExfjIwt2QCRlfk78fwAcMeEqTz6RE3XGOt7dTQT9J+dczNb9X3AiRgtwrkmoeA1Xatuv5U oeZNfZqnJpxH+9buycmq6zzpRt+2hS+QMGO8YVqLOufSKptdwUqr2zolJkk1dMbp33GuSq 7pG2tS+HJwRHGKODBClDGV9GIYPiWsY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-401-EKdDHX6EOFScijXKBRs-bg-1; Mon, 19 Feb 2024 08:00:48 -0500 X-MC-Unique: EKdDHX6EOFScijXKBRs-bg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 937BD1C05AA6; Mon, 19 Feb 2024 13:00:47 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14603AC0C; Mon, 19 Feb 2024 13:00:45 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20240217081431.796809-1-libaokun1@huawei.com> References: <20240217081431.796809-1-libaokun1@huawei.com> To: Christian Brauner Cc: dhowells@redhat.com, netfs@lists.linux.dev, jlayton@kernel.org, Baokun Li , linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH RESEND] cachefiles: fix memory leak in cachefiles_add_cache() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <131232.1708347645.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Mon, 19 Feb 2024 13:00:45 +0000 Message-ID: <131233.1708347645@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 Hi Christian, Could you take this through your VFS tree please? > The following memory leak was reported after unbinding /dev/cachefiles: > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > unreferenced object 0xffff9b674176e3c0 (size 192): > comm "cachefilesd2", pid 680, jiffies 4294881224 > hex dump (first 32 bytes): > 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace (crc ea38a44b): > [] kmem_cache_alloc+0x2d5/0x370 > [] prepare_creds+0x26/0x2e0 > [] cachefiles_determine_cache_security+0x1f/0x120 > [] cachefiles_add_cache+0x13c/0x3a0 > [] cachefiles_daemon_write+0x146/0x1c0 > [] vfs_write+0xcb/0x520 > [] ksys_write+0x69/0xf0 > [] do_syscall_64+0x72/0x140 > [] entry_SYSCALL_64_after_hwframe+0x6e/0x76 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > = > Put the reference count of cache_cred in cachefiles_daemon_unbind() to > fix the problem. And also put cache_cred in cachefiles_add_cache() error > branch to avoid memory leaks. > = > Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted file= system") > CC: stable@vger.kernel.org > Signed-off-by: Baokun Li and add: Reviewed-by: Jingbo Xu Reviewed-by: Jeff Layton Acked-by: David Howells