Skip to contentSkip to conversation

Patch "btrfs: avoid overflowing f_bfree" has been added to the 4.5-stable tree

PATCH [email protected] 1 participant 1 message Jun 5, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

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 <[email protected]> know about it.

Quoted 1 line

From 41b34accb265e3a20211a7a8ef3625678f1c6ec7 Mon Sep 17 00:00:00 2001

From: Luis de Bethencourt <[email protected]>
Date: Wed, 30 Mar 2016 23:18:14 +0100
Subject: btrfs: avoid overflowing f_bfree

From: Luis de Bethencourt <[email protected]>

commit 41b34accb265e3a20211a7a8ef3625678f1c6ec7 upstream.

Since mixed block groups accounting isn't byte-accurate and f_bree is an unsigned integer, it could overflow. Avoid this.

---
 fs/btrfs/super.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/btrfs/super.c +5 -1
@@ -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 [email protected] are

queue-4.5/btrfs-fix-mixed-block-count-of-available-space.patch queue-4.5/btrfs-avoid-overflowing-f_bfree.patch