* [PATCH] btrfs: check file extent backref offset underflow
@ 2011-08-29 1:25 Yan, Zheng
2011-08-29 1:59 ` Li Zefan
0 siblings, 1 reply; 2+ messages in thread
From: Yan, Zheng @ 2011-08-29 1:25 UTC (permalink / raw)
Cc: linux-btrfs
Offset field in data extent backref can underflow if clone range ioctl
is used. We can reliably detect the underflow because max file size is
limited to 2^63 and max data extent size is limited by block group size.
Signed-off-by: Zheng Yan <zheng.z.yan@intel.com>
---
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 59bb176..107c9cf 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3323,8 +3323,11 @@ static int find_data_references(struct reloc_control *rc,
}
key.objectid = ref_objectid;
- key.offset = ref_offset;
key.type = BTRFS_EXTENT_DATA_KEY;
+ if (ref_offset > ((u64)-1 << 32))
+ key.offset = 0;
+ else
+ key.offset = ref_offset;
path->search_commit_root = 1;
path->skip_locking = 1;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: check file extent backref offset underflow
2011-08-29 1:25 [PATCH] btrfs: check file extent backref offset underflow Yan, Zheng
@ 2011-08-29 1:59 ` Li Zefan
0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2011-08-29 1:59 UTC (permalink / raw)
To: Yan, Zheng; +Cc: linux-btrfs
Yan, Zheng wrote:
> Offset field in data extent backref can underflow if clone range ioctl
> is used. We can reliably detect the underflow because max file size is
> limited to 2^63 and max data extent size is limited by block group size.
>
> Signed-off-by: Zheng Yan <zheng.z.yan@intel.com>
Tested-by: Li Zefan <lizf@cn.fujitsu.com>
...
> @@ -3323,8 +3323,11 @@ static int find_data_references(struct reloc_control *rc,
> }
>
> key.objectid = ref_objectid;
> - key.offset = ref_offset;
> key.type = BTRFS_EXTENT_DATA_KEY;
> + if (ref_offset > ((u64)-1 << 32))
> + key.offset = 0;
> + else
> + key.offset = ref_offset;
This needs comment, as we're working around a corner case and a magic number is
used.
>
> path->search_commit_root = 1;
> path->skip_locking = 1;
> --
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-29 1:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-29 1:25 [PATCH] btrfs: check file extent backref offset underflow Yan, Zheng
2011-08-29 1:59 ` Li Zefan
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).