From patchwork Fri Mar 1 23:29:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10836251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC0F21575 for ; Fri, 1 Mar 2019 23:29:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3CFB2E04E for ; Fri, 1 Mar 2019 23:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 967262E053; Fri, 1 Mar 2019 23:29:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 470B42E04E for ; Fri, 1 Mar 2019 23:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726041AbfCAX3I (ORCPT ); Fri, 1 Mar 2019 18:29:08 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47660 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725982AbfCAX3I (ORCPT ); Fri, 1 Mar 2019 18:29:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x21NT4VI126636 for ; Fri, 1 Mar 2019 23:29:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=3B22+0RwEYaFaD2qG6W4rUJeB+kLfcUEbibewFX/WK0=; b=JMFaF54dYqswnju+alIj84FCwqxJMf0uq8U/spqlV/Ruu9Q+IhlLVT9CcvZvFzwtmj7k /8Qf0lmfiZAM0cFqaP9d4IFRE1IC0Kcio8ivKBcQiIz/WensVXXvhR8onPgfV0xQl2LH A7Dk2SXtsEZURbsJIzoxdHkslnUCFsJhc6TW4rxmDsucCG7is+UNujuOy4JV6tFkQNp3 0xnDPyF7uZKccD89IWHWTMXQRVm7EJZ9OI8odgpT3ktiGUbG9KEvpez5ro0Mbv6igzk/ 1htEIDxa2Q776f9/ThqcCuPclKUhhB5087xdxrdt56C+I4VSZvCN1rVNz+XdJ8y617gR jQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qtwkut93w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 01 Mar 2019 23:29:07 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x21NT51h009684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 1 Mar 2019 23:29:06 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x21NT5DE008183 for ; Fri, 1 Mar 2019 23:29:05 GMT Received: from localhost (/10.159.229.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Mar 2019 15:29:05 -0800 Subject: [PATCH 21/23] libxfs: free buffer log item in libxfs_trans_brelse From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 01 Mar 2019 15:29:04 -0800 Message-ID: <155148294438.16677.1930910751833400782.stgit@magnolia> In-Reply-To: <155148280859.16677.6057998944865066232.stgit@magnolia> References: <155148280859.16677.6057998944865066232.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9182 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=972 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903010162 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong If we're going to putbuf a buffer at the bottom of libxfs_trans_brelse, that means that the buffer is clean and not held, and therefore we need to detach the buffer from the transaction prior to releasing the buffer. For whatever reason, we forget to free the buffer's b_log_item (though we set b_transp to NULL), which means that if the buffer is immediately freed or picked back up to write an inode core (which changes b_log_item), we'll leak the buf item. Therefore, free the buffer log item like the kernel does, which stops the leak. Signed-off-by: Darrick J. Wong --- libxfs/trans.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libxfs/trans.c b/libxfs/trans.c index 46ff8b4a..b0a04ecd 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -570,6 +570,8 @@ libxfs_trans_brelse( xfs_trans_del_item(&bip->bli_item); if (bip->bli_flags & XFS_BLI_HOLD) bip->bli_flags &= ~XFS_BLI_HOLD; + kmem_zone_free(xfs_buf_item_zone, bip); + bp->b_log_item = NULL; bp->b_transp = NULL; libxfs_putbuf(bp); } @@ -856,6 +858,7 @@ inode_item_done( return; } + ASSERT(bp->b_log_item == NULL); bp->b_log_item = iip; error = libxfs_iflush_int(ip, bp); if (error) {