Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1399500pxj; Fri, 21 May 2021 13:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxENEAJZfC0Q81LFVsELFggg3kUADbPo7cVp4NDLKu/e/OSHsxZNUgavoymhLDZKOBdOPcS X-Received: by 2002:a05:6602:14c4:: with SMTP id b4mr623152iow.82.1621628283364; Fri, 21 May 2021 13:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628283; cv=none; d=google.com; s=arc-20160816; b=oO2UsiLWl5h/YyIjYjvRKF7Px7t0kh2osCcHS/34pkcKj00WG3Wsjwn0ROv8LaXUH+ HqPIoMI+lOezcFKyyZXriVev8l/WRWHx5nIkrDHiYHUBvwK8PqYiIVT8g3A82Ovq8QUC t/tJN3hwZGiwakCRYwKS8m7VJUmZ+bb8ZOtCqEMTQyRd2nmeDCwKLO+zwoTllzHh+pmx ktIe1bFU6hFrkdNls/j6Yl+TsJ4CCRKMRSuPI5IBwOUz2yi5/Lg9qeQGUGjEZ8j16ZlP cgPWtNGtN5FwSrS7YstYreoQxS+zPjyjMzVwddviZMAFfQBbDqgcgY1+24avCB328R3t y7ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=e6+XJSHXA8XNVby08llcPKqE8a8WGLyDBftd7jNjE9o=; b=O2TJGrtZkDj9U6JtcGehnYdh/6qHrj81QskVnsX6VkP15N7LHWrTVF1PTg2mJt2e5t ke7STi+4SB+kA0eHLZNcpVENrytuoMw7TcNZ7e670NCDrZvJTdQeo5HypbRruKECXr8A dmEyV5d9x/FiMtKdp73gLEfob/Ne3gw0WbOpfdVqgv0KrLQusLWw03jZMwzR97qeiUtK 8MC4DZWpbCnxtb3OD5aw1lx1zGaHhQLWjlOXusjdzn6rLnWDbODpwCEnR1wa669orw0W cwmkyEEgRq+5xi9C3Ve97QY3ahYf8l82r/TMWbkVJNnI4YP46fmdk4ZPkANmuJG3XLvr RWWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si7014193jat.42.2021.05.21.13.17.43; Fri, 21 May 2021 13:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236319AbhEUOaa (ORCPT + 99 others); Fri, 21 May 2021 10:30:30 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50762 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231279AbhEUOa3 (ORCPT ); Fri, 21 May 2021 10:30:29 -0400 Received: from callcc.thunk.org (c-73-8-226-230.hsd1.il.comcast.net [73.8.226.230]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 14LET2XQ006110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 May 2021 10:29:04 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 797F3420119; Fri, 21 May 2021 10:29:01 -0400 (EDT) Date: Fri, 21 May 2021 10:29:01 -0400 From: "Theodore Y. Ts'o" To: Alexey Makhalov Cc: linux-ext4@vger.kernel.org, stable@vger.kernel.org, Andreas Dilger Subject: Re: [PATCH] ext4: fix memory leak in ext4_fill_super Message-ID: References: <20210428221928.38960-1-amakhalov@vmware.com> <459B4724-842E-4B47-B2E7-D29805431E69@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <459B4724-842E-4B47-B2E7-D29805431E69@vmware.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, May 21, 2021 at 12:43:46AM -0700, Alexey Makhalov wrote: > Hi Ted, > > Good point! This paragraph can be just dropped as the next one > describes the issue with superblock re-read. Will send v2 shortly. Thanks; for what it's worth, I'm going to be editing the commit description anyway; it's really helpful during the patch review to understand how you found the problem, and how to reproduce it. However, the commit description when it lands upstream will include a link to this mail thread on lore.kernel.org, and so including a long stack trace isn't really necessary. I'm going to cut it down to something like this: ------------------------------ ext4: fix memory leak in ext4_fill_super Buffer head references must be released before calling kill_bdev(); otherwise the buffer head (and its page referenced by b_data) will not be freed by kill_bdev, and subsequently that bh will be leaked. If blocksizes differ, sb_set_blocksize() will kill current buffers and page cache by using kill_bdev(). And then super block will be reread again but using correct blocksize this time. sb_set_blocksize() didn't fully free superblock page and buffer head, and being busy, they were not freed and instead leaked. This can easily be reproduced by calling an infinite loop of: systemctl start .mount, and systemctl stop .mount ... since systemd creates a cgroup for each slice which it mounts, and the bh leak get amplified by a dying memory cgroup that also never gets freed, and memory consumption is much more easily noticed. Signed-off-by: Alexey Makhalov Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/459B4724-842E-4B47-B2E7-D29805431E69@vmware.com Fixes: ce40733ce93d ("ext4: Check for return value from sb_set_blocksize") Fixes: ac27a0ec112a ("ext4: initial copy of files from ext3") Signed-off-by: "Theodore Ts'o" Cc: Andreas Dilger ------------------------------ The commit description above is 18 lines (exclusive of trailers and headers) versus 71 lines, and is much more to the point for someone who might be doing code archeology via "git log". When submitting this as a patch, you can either use a separate cover letter (git format-patch --cover-letter) or including the explanation after the --- in the diff, so that it disappears before the commit is added via "git am". But it's not that hard for me to rework a commit description, so I'll take care of it for this patch; no need to send a V3. Cheers, - Ted