Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp592707pja; Thu, 19 Mar 2020 08:01:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vszW4paYcnN3C5lMHbizuuLSm4MrPWGmrH4IZCV3fiuw2mGa4rIokJRMUAOFRvwQCEl+uaP X-Received: by 2002:aca:496:: with SMTP id 144mr2752519oie.121.1584630094476; Thu, 19 Mar 2020 08:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584630094; cv=none; d=google.com; s=arc-20160816; b=bqHPIubbFCucgpY9mZxEO2FIgz8dJaWHafpLEc8FDKwNciHAAGnO7+9IzX6YHJ8UKa e3fW2Y7olv8axjEXwQvzMkuEL1toVv7hTEC49SGTiTmnxvs70PkBlrRLGrKwTMu4SFeK 6CmaXGnQv2txrFZFp7Fmmsn/m3YfpyKV+Z791XtqefCWH7OLvqinNEHpIJkWSLmQdekN XuAKr3ldrY3E/LX8TUIzVym8w2zENeldxT54HcKicBY8XiNwXb6SnrGzcwHgwioOMhBV 5+Rd6r9OQlent0hzgOZ893CEd1FxcoRmhCP/nImW6AlDFIYLz4sXlNo7srQX5rkFn8ar cKiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gAvVj70dEYELhtkpn3fD3cUXgbxTg1hLzjPAa7kI1Ao=; b=TpopKOfs6yIDAMbRZi7Hy5RtMngQj7jKbUvqm310BczOEYFSrTRAOor+3FTeDL67Vm tFFqzB1JBNpNGa+vKiEfb46EZ9tvF0JiBoL2upnUS3r8f2aR9pMZcD04EqUZrf49NZZR uVxm1kHANLe84HN27CPQ6wJElkeHZgMbI3jKkoGPDI448hiWoaCAxaWlXCV23YemvcY8 FKBCnl8bK1we4X6IXjopmr19Y2OblzoRqRBDuHdByP1JRw4HE1YZ8caUXUCpwQACz9gx /9OvzWWQyURaA2toG2/w2PaA/7lnrd6ZUguz9Xz7HMa8KE5Fyf249wRPxRa5UcKJimMB yBFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v81si1159196oia.114.2020.03.19.08.01.13; Thu, 19 Mar 2020 08:01:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbgCSPAn (ORCPT + 99 others); Thu, 19 Mar 2020 11:00:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:50444 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbgCSPAm (ORCPT ); Thu, 19 Mar 2020 11:00:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A5FBAAE48; Thu, 19 Mar 2020 15:00:40 +0000 (UTC) Received: from localhost (webern.olymp [local]) by webern.olymp (OpenSMTPD) with ESMTPA id 4a952f62; Thu, 19 Mar 2020 15:00:39 +0000 (WET) Date: Thu, 19 Mar 2020 15:00:39 +0000 From: Luis Henriques To: Jeff Layton Cc: Sage Weil , Ilya Dryomov , "Yan, Zheng" , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ceph: fix memory leak in ceph_cleanup_snapid_map Message-ID: <20200319150039.GA24696@suse.com> References: <20200319114348.GA72449@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 19, 2020 at 10:41:13AM -0400, Jeff Layton wrote: > On Thu, 2020-03-19 at 11:43 +0000, Luis Henriques wrote: > > kmemleak reports the following memory leak: > > > > unreferenced object 0xffff88821feac8a0 (size 96): > > comm "kworker/1:0", pid 17, jiffies 4294896362 (age 20.512s) > > hex dump (first 32 bytes): > > a0 c8 ea 1f 82 88 ff ff 00 c9 ea 1f 82 88 ff ff ................ > > 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ad de ................ > > backtrace: > > [<00000000b3ea77fb>] ceph_get_snapid_map+0x75/0x2a0 > > [<00000000d4060942>] fill_inode+0xb26/0x1010 > > [<0000000049da6206>] ceph_readdir_prepopulate+0x389/0xc40 > > [<00000000e2fe2549>] dispatch+0x11ab/0x1521 > > [<000000007700b894>] ceph_con_workfn+0xf3d/0x3240 > > [<0000000039138a41>] process_one_work+0x24d/0x590 > > [<00000000eb751f34>] worker_thread+0x4a/0x3d0 > > [<000000007e8f0d42>] kthread+0xfb/0x130 > > [<00000000d49bd1fa>] ret_from_fork+0x3a/0x50 > > > > A kfree was missing in commit 75c9627efb72 ("ceph: map snapid to anonymous > > bdev ID"), while looping the 'to_free' list of ceph_snapid_map objects. > > > > Fixes: 75c9627efb72 ("ceph: map snapid to anonymous bdev ID") > > Signed-off-by: Luis Henriques > > --- > > Hi! > > > > A bit of mailing-list archaeology shows that v1 of this patch actually > > included this kfree [1], and was lost on v2 [2]. > > > > [1] https://patchwork.kernel.org/patch/10114319/ > > [2] https://patchwork.kernel.org/patch/10749907/ > > > > Cheers, > > -- > > Luis > > > > fs/ceph/snap.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c > > index ccfcc66aaf44..923be9399b21 100644 > > --- a/fs/ceph/snap.c > > +++ b/fs/ceph/snap.c > > @@ -1155,5 +1155,6 @@ void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc) > > pr_err("snapid map %llx -> %x still in use\n", > > sm->snap, sm->dev); > > } > > + kfree(sm); > > } > > } > > Good catch. This looks correct to me. > > Hmmm...we'll leak one of these for every snapid we encounter. Any > objection to marking this for stable? No, please do. I assumed it would be a stable candidate already by having the 'Fixes: ' but maybe it's better to explicitly tag it. Cheers, -- Luis