Bug 108531

Summary: btrfs crashes (with grsec)/has size overflow in extend_map (reading from written/moved files)
Product: File System Reporter: alex (devkral)
Component: btrfsAssignee: Josef Bacik (josef)
Status: RESOLVED CODE_FIX    
Severity: high CC: dsterba, kernel_bugs, pageexec, szg00000
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 4.2.6 Subsystem:
Regression: No Bisected commit-id:
Attachments: output kernel

Description alex 2015-11-27 13:58:12 UTC
Created attachment 195591 [details]
output kernel

Trigger:
I ran my backup script accidentally over a directory where a program of mine heavily wrote in files,moved them.
This seems to have triggered a size overflow in btrfs/extend_map.c (line 238) which was reported and blocked by pax.
It seems that reading from written or moved files can trigger this bug.

I don't know exactly if it is a btrfs upstream bug or a grsec bug.
My linux distro is Archlinux, with the exact kernel version: linux-grsec 4.2.6.201511232037-1.
Comment 1 Martin 2015-12-03 20:54:17 UTC
I had same bug. I reported it there
https://bugs.gentoo.org/show_bug.cgi?id=567046
After I applied this patch https://projects.archlinux.org/svntogit/community.git/tree/trunk/btrfs-overflow.patch?h=packages/linux-grsec btrfs didn't crash anymore. But as you can see in my bug report on gentoo em->block_len and merge->block_len has many times value ffffffffffffffff
Comment 2 David Sterba 2015-12-04 15:06:45 UTC
I can reproduce it locally, still investigating.
Comment 3 Martin 2016-01-10 19:13:03 UTC
Patch is included in new Gentoo packages. Did you know if values 0xffffffffffffffff on em->block_len and merge->block_len are correct? Or this patch is only workaround to handle overflow in filesystem without crash?