From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-901460-1516769782-2-7838764273189712051 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.25, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='com', MailFrom='org', XOriginatingCountry='US' X-Spam-charsets: plain='iso-8859-1' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1516769781; b=imxnZx05WhXhAKd5H0cFjW+ACQIu5Nr+ocS6EX/FNOMLC9O V5jFeEAlECPFtlnr5WZP6TJSO7/9lzhsn84IW906in26FwUNw3tqx63Ti3izlxBJ 7AYii/pHtxevjsVL9qD5j0g11+Fgv0e/yksA1McZ0qqQ0enZA7h/JewwBUPtYccy d6tuuG34b/UsFiH0fsV2VsNSYzme9Yxk69v2bsFcm7RyNJncBUcu4Oxp1XN4TJaF WSzm2Cre1AL6Kr/og2mhH0vfJzuq/5VwQ9FVcQiezpigCWrmXuL1uoPNhvYidmIf 4vizNzBj23zTMezCXcD9wgl0kjEyN/E2Wd+eC7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:date:message-id :references:in-reply-to:content-type:content-transfer-encoding :mime-version:sender:list-id; s=arctest; t=1516769781; bh=Exo8oG xRx2gSWQog+GlGm73rfG+PApBakT3kQjx/rqs=; b=FVUZBzlVO+G3D0P9enL0AI FANMO9FjatZAuwmb0tGgsDDLhQqTv10VwhRYfk2mmE1zLspIGRHBS+FoFexW8QlN mSsFRwss4HdxUjIbxhi0nqzwSoKI4DsYX5yUW2+V319/Mq4IvY6Aezv+ZJT24zvT nDLALCSpwVQL4nRbBhKVOKAHY2XyXGQUSyJQhtKfvaIOfEEKKYPd3JMgpTc2/QfQ sFdUB7/mCzkhQWRck0c2O7VEIj6ZpyneOIdx1diqVWUUwj8KyeqcRizijt/N9+WE qgKv2V6rGHsgoJG0sCcNvfsBZPmykXRwbR6t5hd3b6FSf11kcDP8d44mQPs2P4AA == ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=ZkQu+Lzh x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=ZkQu+Lzh x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932272AbeAXEzw (ORCPT ); Tue, 23 Jan 2018 23:55:52 -0500 Received: from mail-sn1nam01on0109.outbound.protection.outlook.com ([104.47.32.109]:45568 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932180AbeAXEPW (ORCPT ); Tue, 23 Jan 2018 23:15:22 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Darrick J. Wong" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 051/100] xfs: always free inline data before resetting inode fork during ifree Thread-Topic: [PATCH AUTOSEL for 4.14 051/100] xfs: always free inline data before resetting inode fork during ifree Thread-Index: AQHTlMngMTeTWVabNUibjwgAZbGOPA== Date: Wed, 24 Jan 2018 04:14:50 +0000 Message-ID: <20180124041414.32065-51-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1015;7:qxvvuPKCWvblPuOTRXFRoe6JfHYrdGJR7sOsFmMl/NbhdDsIboWkceshI+KoHMlYs15cOvtQND5Cq8U6vfjg7EyQx7xJhoOGF/jnxT1WH7Yp14QwVN2eUw8BUiLP0eDlWYQlZ7f259KiWRw3V91K+RjOHApEc8SmNvcV0p9un4vL8+GNUd8XCUWwLTZVt8jjVO9SCQgYnX1ca50aqpXgYcSXMlEWgPmMbjNL2WW5mQ9Yy5MUQ4HR9MU8oLhWSG6g x-ms-office365-filtering-correlation-id: ae61aa46-0146-4700-61e8-08d562e113c5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(146099531331640)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(376002)(366004)(39860400002)(346002)(199004)(189003)(478600001)(6666003)(106356001)(6512007)(53936002)(2900100001)(36756003)(102836004)(2950100002)(2501003)(10290500003)(97736004)(14454004)(81166006)(72206003)(8936002)(6486002)(1076002)(10090500001)(6346003)(26005)(54906003)(4326008)(76176011)(99286004)(86362001)(3660700001)(105586002)(6116002)(8676002)(68736007)(22452003)(66066001)(25786009)(6506007)(5660300001)(305945005)(7736002)(3280700002)(5250100002)(2906002)(107886003)(86612001)(6436002)(316002)(81156014)(3846002)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: KiPC6T4Myov5VhY2CAh8AMMRilDSbUkS63H2VpLNnN6kIeubSJzepPbxuIM5ZENdETtQ0nq7GQYH24ZLzI3Wjg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae61aa46-0146-4700-61e8-08d562e113c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:50.1821 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: From: "Darrick J. Wong" [ Upstream commit 98c4f78dcdd8cec112d1cbc5e9a792ee6e5ab7a6 ] In xfs_ifree, we reset the data/attr forks to extents format without bothering to free any inline data buffer that might still be around after all the blocks have been truncated off the file. Prior to commit 43518812d2 ("xfs: remove support for inlining data/extents into the inode fork") nobody noticed because the leftover inline data after truncation was small enough to fit inside the inline buffer inside the fork itself. However, now that we've removed the inline buffer, we /always/ have to free the inline data buffer or else we leak them like crazy. This test was found by turning on kmemleak for generic/001 or generic/388. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/xfs/xfs_inode.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 63350906961a..cb4833d06467 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2422,6 +2422,24 @@ retry: } =20 /* + * Free any local-format buffers sitting around before we reset to + * extents format. + */ +static inline void +xfs_ifree_local_data( + struct xfs_inode *ip, + int whichfork) +{ + struct xfs_ifork *ifp; + + if (XFS_IFORK_FORMAT(ip, whichfork) !=3D XFS_DINODE_FMT_LOCAL) + return; + + ifp =3D XFS_IFORK_PTR(ip, whichfork); + xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); +} + +/* * This is called to return an inode to the inode free list. * The inode should already be truncated to 0 length and have * no pages associated with it. This routine also assumes that @@ -2458,6 +2476,9 @@ xfs_ifree( if (error) return error; =20 + xfs_ifree_local_data(ip, XFS_DATA_FORK); + xfs_ifree_local_data(ip, XFS_ATTR_FORK); + VFS_I(ip)->i_mode =3D 0; /* mark incore inode as free */ ip->i_d.di_flags =3D 0; ip->i_d.di_dmevmask =3D 0; --=20 2.11.0