Skip to contentSkip to conversation

btrfs-progs: subvol sync: fix memory corruption, undersized array

PATCH New David Sterba 4 participants 5 messages Mar 17, 2016 – Mar 19, 2016 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs-progs: subvol sync: fix memory corruption, undersized array

The subvol sync command crashed randomly at the end with

*** glibc detected *** btrfs: double free or corruption (out): 0x00000000006ab040 ***

This is caused by running out of the ids array in case there are more than 128 subvolumes. The array is increased in steps but does not account the size of the item, so there was room for 1024 / 8 = 128 subvolume ids.

Fixes c9f885ec8963 ("btrfs-progs: subvol: let sync check only current deletions")
---
 cmds-subvolume.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cmds-subvolume.c +2 -1
index 02e1dec18ed2..32caaa5db9ec 100644
@@ -1204,7 +1204,8 @@ static int enumerate_dead_subvols(int fd, u64 **ids)
 					u64 *newids;
 
 					count += SUBVOL_ID_BATCH;
-					newids = (u64*)realloc(*ids, count);
+					newids = (u64*)realloc(*ids,
+							count * sizeof(u64));
 					if (!newids)
 						return -ENOMEM;
 					*ids = newids;
Signature · 1 line
2.7.1
#1 lore raw

Blocks changed since previous snapshot of subvolume

Hi,

I Would like to know between 2 snapshots of a subvolume, can we identify what all blocks modified particular to that subvolume ?

there can be many subvolume and snapshots present on the btrfs but i want only blocks modified since first snapshot for the specific subvolume.

blocks should include metadata and data blocks.

#2 lore raw

Re: Blocks changed since previous snapshot of subvolume

Quoted 10 lines · sri <toyours_sridhar <at> yahoo.co.in> writes:

Hi,

I Would like to know between 2 snapshots of a subvolume, can we identify what all blocks modified particular to that subvolume ?

there can be many subvolume and snapshots present on the btrfs but i want only blocks modified since first snapshot for the specific subvolume.

blocks should include metadata and data blocks.

Not directly diff blocks, rather files, you could do something like this:

btrfs subvolume find-new <newer_snapshot> btrfs subvolume show <older_snapshot> | grep Generation | awk '{print $2}' | awk '{ print $17 }' | sort | uniq

#3 lore raw

Re: Blocks changed since previous snapshot of subvolume

Quoted 7 lines · Henk Slager <eye1tm <at> gmail.com> writes:
Quoted 4 lines · sri <toyours_sridhar <at> yahoo.co.in> writes:

Hi,

I Would like to know between 2 snapshots of a subvolume, can we

identify

Quoted 3 lines
Quoted 3 lines

what all blocks modified particular to that subvolume ?

there can be many subvolume and snapshots present on the btrfs but i

want

Quoted 1 line
Quoted 1 line

only blocks modified since first snapshot for the specific

subvolume.

Quoted 4 lines
Quoted 2 lines

blocks should include metadata and data blocks.

Not directly diff blocks, rather files, you could do something like

this:

Quoted 3 lines

btrfs subvolume find-new <newer_snapshot> btrfs subvolume show <older_snapshot> | grep Generation | awk '{print $2}' | awk '{ print

$17 }'

Quoted 4 lines

| sort | uniq

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"

in

Quoted 4 lines

the body of a message to majordomo <at> vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Thank you. As I checked only blocks related to file are shown.

sample output:

btrfs subvolume find-new snap2 15
inode 264 file offset 0 len 8192 disk start 351559680 offset 0 gen 16 flags NONE mman.h
inode 265 file offset 0 len 8192 disk start 351567872 offset 0 gen 16 flags NONE mount.h
inode 266 file offset 0 len 2374 disk start 0 offset 0 gen 16 flags INLINE msg.h
inode 267 file offset 0 len 12288 disk start 351576064 offset 0 gen 16 flags NONE mtio.h
transid marker was 16

I think it showed blocks changed w.r.t file data block.

is there a way to get other blocks modified such as meta data such as inodes blocks modified and corresponding directory inode blocks along with files?

Above fs is created on 2 disks /dev/sdd and /dev/sdd of 3 gb. No raid configured. I think it is just strped with 6gb size around.

How should I interpret:
inode 266 file offset 0 len 2374 disk start 0 offset 0 gen 16 flags INLINE msg.h

??

disk start is 0 here. Is this w.r.t what?

and offset 0 is offset inside block represented by disk start ?

thank you.

#4 lore raw

Re: Blocks changed since previous snapshot of subvolume

sri posted on Fri, 18 Mar 2016 13:36:50 +0000 as excerpted:

Quoted 14 lines
Quoted 12 lines · Henk Slager <eye1tm <at> gmail.com> writes:
Quoted 7 lines · sri <toyours_sridhar <at> yahoo.co.in> writes:

I Would like to know between 2 snapshots of a subvolume, can we identify what all blocks modified particular to that subvolume ?

there can be many subvolume and snapshots present on the btrfs but i want only blocks modified since first snapshot for the specific subvolume. blocks should include metadata and data blocks.

Not directly diff blocks, rather files, you could do something like this:

Quoted 8 lines
Quoted 3 lines

btrfs subvolume find-new [...]

Thank you. As I checked only blocks related to file are shown.

is there a way to get other blocks modified such as meta data such as inodes blocks modified and corresponding directory inode blocks along with files?

This would include the change data itself as well, and I'm not sure if the format once the actual binary level changes themselves are removed is practically consumable by humans or not, but it occurs to me that this is precisely the information that btrfs send -p provides. If you can strip the changes themselves out and what's left is either human readable or can be processed to human readable, then it should be exactly what you're after, the changed blocks, for data and metadata both.

Signature · 3 lines
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman