Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1543890 > unrolled thread

[PATCH] rbtree: use designated initializers

Started byKees Cook <keescook@chromium.org>
First post2016-12-17 02:10 +0100
Last post2016-12-17 15:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] rbtree: use designated initializers Kees Cook <keescook@chromium.org> - 2016-12-17 02:10 +0100
    Re: [PATCH] rbtree: use designated initializers Peter Zijlstra <peterz@infradead.org> - 2016-12-17 15:00 +0100

#1543890 — [PATCH] rbtree: use designated initializers

FromKees Cook <keescook@chromium.org>
Date2016-12-17 02:10 +0100
Subject[PATCH] rbtree: use designated initializers
Message-ID<sPbFE-2GI-63@gated-at.bofh.it>
Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/linux/rbtree_augmented.h | 4 +++-
 lib/rbtree.c                     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index d076183e49be..9702b6e183bc 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new)	\
 	old->rbaugmented = rbcompute(old);				\
 }									\
 rbstatic const struct rb_augment_callbacks rbname = {			\
-	rbname ## _propagate, rbname ## _copy, rbname ## _rotate	\
+	.propagate = rbname ## _propagate,				\
+	.copy = rbname ## _copy,					\
+	.rotate = rbname ## _rotate					\
 };
 
 
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 1f8b112a7c35..4ba2828a67c0 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -427,7 +427,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
 
 static const struct rb_augment_callbacks dummy_callbacks = {
-	dummy_propagate, dummy_copy, dummy_rotate
+	.propagate = dummy_propagate,
+	.copy = dummy_copy,
+	.rotate = dummy_rotate
 };
 
 void rb_insert_color(struct rb_node *node, struct rb_root *root)
-- 
2.7.4


-- 
Kees Cook
Nexus Security

[toc] | [next] | [standalone]


#1543971

FromPeter Zijlstra <peterz@infradead.org>
Date2016-12-17 15:00 +0100
Message-ID<sPnGO-1Ui-3@gated-at.bofh.it>
In reply to#1543890
On Fri, Dec 16, 2016 at 05:02:53PM -0800, Kees Cook wrote:
> Prepare to mark sensitive kernel structures for randomization by making
> sure they're using designated initializers. These were identified during
> allyesconfig builds of x86, arm, and arm64, with most initializer fixes
> extracted from grsecurity.

Works for me.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

One note on these structures, the intent is that GCC value propagation
completely does away with everything and results in inlining the actual
functions. Older versions of GCC had a wee bit of trouble with this, but
recent versions do just that, not a single actual structure should end
up being emitted in the object code.

> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  include/linux/rbtree_augmented.h | 4 +++-
>  lib/rbtree.c                     | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
> index d076183e49be..9702b6e183bc 100644
> --- a/include/linux/rbtree_augmented.h
> +++ b/include/linux/rbtree_augmented.h
> @@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new)	\
>  	old->rbaugmented = rbcompute(old);				\
>  }									\
>  rbstatic const struct rb_augment_callbacks rbname = {			\
> -	rbname ## _propagate, rbname ## _copy, rbname ## _rotate	\
> +	.propagate = rbname ## _propagate,				\
> +	.copy = rbname ## _copy,					\
> +	.rotate = rbname ## _rotate					\
>  };
>  
>  
> diff --git a/lib/rbtree.c b/lib/rbtree.c
> index 1f8b112a7c35..4ba2828a67c0 100644
> --- a/lib/rbtree.c
> +++ b/lib/rbtree.c
> @@ -427,7 +427,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
>  static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
>  
>  static const struct rb_augment_callbacks dummy_callbacks = {
> -	dummy_propagate, dummy_copy, dummy_rotate
> +	.propagate = dummy_propagate,
> +	.copy = dummy_copy,
> +	.rotate = dummy_rotate
>  };
>  
>  void rb_insert_color(struct rb_node *node, struct rb_root *root)
> -- 
> 2.7.4
> 
> 
> -- 
> Kees Cook
> Nexus Security

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web