Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:43777 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754017AbcFEWDK (ORCPT ); Sun, 5 Jun 2016 18:03:10 -0400 Subject: Patch "btrfs: avoid overflowing f_bfree" has been added to the 4.5-stable tree To: luisbg@osg.samsung.com, dsterba@suse.com, gregkh@linuxfoundation.org Cc: , From: Date: Sun, 05 Jun 2016 14:48:03 -0700 Message-ID: <146516328325143@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled btrfs: avoid overflowing f_bfree to the 4.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-avoid-overflowing-f_bfree.patch and it can be found in the queue-4.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From 41b34accb265e3a20211a7a8ef3625678f1c6ec7 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 30 Mar 2016 23:18:14 +0100 Subject: btrfs: avoid overflowing f_bfree From: Luis de Bethencourt commit 41b34accb265e3a20211a7a8ef3625678f1c6ec7 upstream. Since mixed block groups accounting isn't byte-accurate and f_bree is an unsigned integer, it could overflow. Avoid this. Signed-off-by: Luis de Bethencourt Suggested-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2073,7 +2073,11 @@ static int btrfs_statfs(struct dentry *d /* Account global block reserve as used, it's in logical size already */ spin_lock(&block_rsv->lock); - buf->f_bfree -= block_rsv->size >> bits; + /* Mixed block groups accounting is not byte-accurate, avoid overflow */ + if (buf->f_bfree >= block_rsv->size >> bits) + buf->f_bfree -= block_rsv->size >> bits; + else + buf->f_bfree = 0; spin_unlock(&block_rsv->lock); buf->f_bavail = div_u64(total_free_data, factor); Patches currently in stable-queue which might be from luisbg@osg.samsung.com are queue-4.5/btrfs-fix-mixed-block-count-of-available-space.patch queue-4.5/btrfs-avoid-overflowing-f_bfree.patch