Commit 60f2c82e authored by Joonwon Kang's avatar Joonwon Kang Committed by Kees Cook

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: default avatarJoonwon Kang <kjw1627@gmail.com>
Link: https://lore.kernel.org/r/20190727155841.GA13586@host
Fixes: 313dd1b6 ("gcc-plugins: Add the randstruct plugin")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 609488bc
...@@ -443,13 +443,13 @@ static int is_pure_ops_struct(const_tree node) ...@@ -443,13 +443,13 @@ static int is_pure_ops_struct(const_tree node)
if (node == fieldtype) if (node == fieldtype)
continue; continue;
if (!is_fptr(fieldtype)) if (code == RECORD_TYPE || code == UNION_TYPE) {
return 0; if (!is_pure_ops_struct(fieldtype))
return 0;
if (code != RECORD_TYPE && code != UNION_TYPE)
continue; continue;
}
if (!is_pure_ops_struct(fieldtype)) if (!is_fptr(fieldtype))
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment