linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: qgroup: add BUILD_BUG to report pointer cast breakage
@ 2014-11-12 15:00 Daniel Dressler
  2014-11-12 15:02 ` Daniel Dressler
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Dressler @ 2014-11-12 15:00 UTC (permalink / raw)
  To: danieru.dressler
  Cc: Chris Mason, Josef Bacik, open list:BTRFS FILE SYSTEM, open list

Our ulist data structure stores at max 64bit
values. qgroup has used this structure to store
pointers. In the future when we upgrade to 128bit
this casting of pointers to uint64_t will break.

This patch adds a BUILD_BUG ensuring that this
code will not be left untouched in the upgrade.

It also marks this issue on the TODO list so it
may be addressed before such an upgrade.

Signed-off-by: Daniel Dressler <danieru.dressler@gmail.com>
---
 fs/btrfs/qgroup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 48b60db..87f7c98 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -44,6 +44,7 @@
  *  - caches fuer ulists
  *  - performance benchmarks
  *  - check all ioctl parameters
+ *  - do not cast uintptr_t to uint64_t in ulist usage
  */
 
 /*
@@ -101,6 +102,7 @@ struct btrfs_qgroup_list {
 
 #define ptr_to_u64(x) ((u64)(uintptr_t)x)
 #define u64_to_ptr(x) ((struct btrfs_qgroup *)(uintptr_t)x)
+BUILD_BUG_ON(UINTPTR_MAX > UINT64_MAX);
 
 static int
 qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: qgroup: add BUILD_BUG to report pointer cast breakage
  2014-11-12 15:00 [PATCH] Btrfs: qgroup: add BUILD_BUG to report pointer cast breakage Daniel Dressler
@ 2014-11-12 15:02 ` Daniel Dressler
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Dressler @ 2014-11-12 15:02 UTC (permalink / raw)
  To: danieru.dressler
  Cc: Chris Mason, Josef Bacik, open list:BTRFS FILE SYSTEM, open list

I am very very sorry, I forgot to even test building. Please pretend
this patch was never submitted.

Daniel

2014-11-13 0:00 GMT+09:00 Daniel Dressler <danieru.dressler@gmail.com>:
> Our ulist data structure stores at max 64bit
> values. qgroup has used this structure to store
> pointers. In the future when we upgrade to 128bit
> this casting of pointers to uint64_t will break.
>
> This patch adds a BUILD_BUG ensuring that this
> code will not be left untouched in the upgrade.
>
> It also marks this issue on the TODO list so it
> may be addressed before such an upgrade.
>
> Signed-off-by: Daniel Dressler <danieru.dressler@gmail.com>
> ---
>  fs/btrfs/qgroup.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 48b60db..87f7c98 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -44,6 +44,7 @@
>   *  - caches fuer ulists
>   *  - performance benchmarks
>   *  - check all ioctl parameters
> + *  - do not cast uintptr_t to uint64_t in ulist usage
>   */
>
>  /*
> @@ -101,6 +102,7 @@ struct btrfs_qgroup_list {
>
>  #define ptr_to_u64(x) ((u64)(uintptr_t)x)
>  #define u64_to_ptr(x) ((struct btrfs_qgroup *)(uintptr_t)x)
> +BUILD_BUG_ON(UINTPTR_MAX > UINT64_MAX);
>
>  static int
>  qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
> --
> 2.1.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-12 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-12 15:00 [PATCH] Btrfs: qgroup: add BUILD_BUG to report pointer cast breakage Daniel Dressler
2014-11-12 15:02 ` Daniel Dressler

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).