aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins/randomize_layout_plugin.c
diff options
context:
space:
mode:
authorJoonwon Kang <kjw1627@gmail.com>2019-07-27 11:58:41 -0400
committerKees Cook <keescook@chromium.org>2019-07-31 16:13:22 -0400
commit60f2c82ed20bde57c362e66f796cf9e0e38a6dbb (patch)
tree41cd23407429499f0c3fab1ed59e0cc566254f1a /scripts/gcc-plugins/randomize_layout_plugin.c
parent609488bc979f99f805f34e9a32c1e3b71179d10b (diff)
randstruct: Check member structs in is_pure_ops_struct()
While no uses in the kernel triggered this case, it was possible to have a false negative where a struct contains other structs which contain only function pointers because of unreachable code in is_pure_ops_struct(). Signed-off-by: Joonwon Kang <kjw1627@gmail.com> Link: https://lore.kernel.org/r/20190727155841.GA13586@host Fixes: 313dd1b62921 ("gcc-plugins: Add the randstruct plugin") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'scripts/gcc-plugins/randomize_layout_plugin.c')
-rw-r--r--scripts/gcc-plugins/randomize_layout_plugin.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c
index 6d5bbd31db7f..bd29e4e7a524 100644
--- a/scripts/gcc-plugins/randomize_layout_plugin.c
+++ b/scripts/gcc-plugins/randomize_layout_plugin.c
@@ -443,13 +443,13 @@ static int is_pure_ops_struct(const_tree node)
443 if (node == fieldtype) 443 if (node == fieldtype)
444 continue; 444 continue;
445 445
446 if (!is_fptr(fieldtype)) 446 if (code == RECORD_TYPE || code == UNION_TYPE) {
447 return 0; 447 if (!is_pure_ops_struct(fieldtype))
448 448 return 0;
449 if (code != RECORD_TYPE && code != UNION_TYPE)
450 continue; 449 continue;
450 }
451 451
452 if (!is_pure_ops_struct(fieldtype)) 452 if (!is_fptr(fieldtype))
453 return 0; 453 return 0;
454 } 454 }
455 455