stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH 4.9 38/86] xfs: always free inline data before resetting inode fork during ifree
Date: Fri,  2 Feb 2018 17:57:58 +0100	[thread overview]
Message-ID: <20180202140825.972875915@linuxfoundation.org> (raw)
In-Reply-To: <20180202140822.679101338@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Darrick J. Wong" <darrick.wong@oracle.com>


[ 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 <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_inode.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2430,6 +2430,24 @@ retry:
 }
 
 /*
+ * 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) != XFS_DINODE_FMT_LOCAL)
+		return;
+
+	ifp = 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
@@ -2466,6 +2484,9 @@ xfs_ifree(
 	if (error)
 		return error;
 
+	xfs_ifree_local_data(ip, XFS_DATA_FORK);
+	xfs_ifree_local_data(ip, XFS_ATTR_FORK);
+
 	VFS_I(ip)->i_mode = 0;		/* mark incore inode as free */
 	ip->i_d.di_flags = 0;
 	ip->i_d.di_dmevmask = 0;

  parent reply	other threads:[~2018-02-02 17:04 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 16:57 [PATCH 4.9 00/86] 4.9.80-stable review Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 02/86] net/mlx5: Define interface bits for fencing UMR wqe Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 03/86] RDMA/mlx5: set UMR wqe fence according to HCA cap Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 05/86] gpio: stmpe: i2c transfer are forbiden in atomic context Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 06/86] gpio: Fix kernel stack leak to userspace Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 07/86] crypto: ecdh - fix typo in KPP dependency of CRYPTO_ECDH Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 08/86] crypto: aesni - handle zero length dst buffer Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 09/86] crypto: sha3-generic - fixes for alignment and big endian operation Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 10/86] crypto: af_alg - whitelist mask and type Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 11/86] HID: wacom: EKR: ensure devres groups at higher indexes are released Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 12/86] power: reset: zx-reboot: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 13/86] gpio: iop: " Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 14/86] gpio: ath79: add missing MODULE_DESCRIPTION/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 15/86] mtd: nand: denali_pci: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 16/86] igb: Free IRQs when device is hotplugged Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 17/86] drm/vc4: Account for interrupts in flight Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 18/86] cpupowerutils: bench - Fix cpu online check Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 19/86] cpupower : Fix cpupower working when cpu0 is offline Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 25/86] ACPI / bus: Leave modalias empty for devices which are not present Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 27/86] cpufreq: Add Loongson machine dependencies Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 28/86] bcache: check return value of register_shrinker Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 29/86] drm/amdgpu: Fix SDMA load/unload sequence on HWS disabled mode Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 30/86] drm/amdkfd: Fix SDMA ring buffer size calculation Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 31/86] drm/amdkfd: Fix SDMA oversubsription handling Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 32/86] openvswitch: fix the incorrect flow action alloc size Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 33/86] mac80211: fix the update of path metric for RANN frame Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 34/86] btrfs: fix deadlock when writing out space cache Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.9 35/86] reiserfs: remove unneeded i_version bump Greg Kroah-Hartman
2018-02-02 16:57 ` Greg Kroah-Hartman [this message]
2018-02-02 16:57 ` [PATCH 4.9 39/86] xen-netfront: remove warning when unloading module Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 40/86] auxdisplay: img-ascii-lcd: Only build on archs that have IOMEM Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 41/86] nfsd: CLOSE SHOULD return the invalid special stateid for NFSv4.x (x>0) Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 42/86] nfsd: Ensure we check stateid validity in the seqid operation checks Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 43/86] grace: replace BUG_ON by WARN_ONCE in exit_net hook Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 44/86] nfsd: check for use of the closed special stateid Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 45/86] lockd: fix "list_add double add" caused by legacy signal interface Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 46/86] hwmon: (pmbus) Use 64bit math for DIRECT format values Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 47/86] bnxt_en: Fix an error handling path in bnxt_get_module_eeprom() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 48/86] xfs: fortify xfs_alloc_buftarg error handling Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 50/86] net: ethernet: xilinx: Mark XILINX_LL_TEMAC broken on 64-bit Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 51/86] quota: Check for register_shrinker() failure Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 52/86] SUNRPC: Allow connect to return EHOSTUNREACH Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 53/86] kmemleak: add scheduling point to kmemleak_scan() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 54/86] drm/bridge: tc358767: do no fail on hi-res displays Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 55/86] drm/bridge: tc358767: filter out too high modes Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 56/86] drm/bridge: tc358767: fix DP0_MISC register set Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 57/86] drm/bridge: tc358767: fix timing calculations Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 58/86] drm/bridge: tc358767: fix AUXDATAn registers access Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 59/86] drm/bridge: tc358767: fix 1-lane behavior Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 60/86] drm/omap: Fix error handling path in omap_dmm_probe() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 61/86] xfs: ubsan fixes Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 62/86] xfs: Properly retry failed dquot items in case of error during buffer writeback Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 63/86] scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 64/86] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 65/86] iwlwifi: mvm: fix the TX queue hang timeout for MONITOR vif type Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 66/86] ARM: dts: NSP: Fix PPI interrupt types Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 67/86] media: usbtv: add a new usbid Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 68/86] usb: gadget: dont dereference g until after it has been null checked Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 69/86] staging: rtl8188eu: Fix incorrect response to SIOCGIWESSID Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 70/86] drm/vc4: Move IRQ enable to PM path Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 71/86] staging: lustre: separate a connection destroy from free struct kib_conn Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 72/86] tty: fix data race between tty_init_dev and flush of buf Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 73/86] usb: option: Add support for FS040U modem Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 75/86] USB: cdc-acm: Do not log urb submission errors on disconnect Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 76/86] CDC-ACM: apply quirk for card reader Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 77/86] USB: serial: io_edgeport: fix possible sleep-in-atomic Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 78/86] usbip: prevent bind loops on devices attached to vhci_hcd Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 79/86] usbip: list: dont list " Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 80/86] USB: serial: simple: add Motorola Tetra driver Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 81/86] usb: f_fs: Prevent gadget unbind if it is already unbound Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 82/86] usb: uas: unconditionally bring back host after reset Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 83/86] usb/gadget: Fix "high bandwidth" check in usb_gadget_ep_match_desc() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 84/86] usbip: vhci_hcd: clear just the USB_PORT_STAT_POWER bit Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 85/86] serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.9 86/86] spi: imx: do not access registers while clocks disabled Greg Kroah-Hartman
2018-02-02 22:19 ` [PATCH 4.9 00/86] 4.9.80-stable review Shuah Khan
2018-02-02 22:45 ` Dan Rue
2018-02-03 15:29 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180202140825.972875915@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@microsoft.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).