randomize_layout: Fix potential auto-selection bug

- Fix auto-selection bug in is_pure_ops_struct (Joonwon Kang)
 -----BEGIN PGP SIGNATURE-----
 Comment: Kees Cook <kees@outflux.net>
 
 iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAl2AAbgWHGtlZXNjb29r
 QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJgb+D/0cIQPUhhkV3yhA869/7Fwe6vr9
 Z3PKL1aM4Z70phabvbAmwii1jD18NrncSaXKxcvmRVlt/LYUxLQhumJbs+G+/ADA
 fKmEZi6XA0Ej9k5T32ChW8d1O3FTzwuv1WEs4EpurWabk3rGY/lVA2c4tk/NTsrQ
 vOLmfxNtJC3CzRYLLCUae0Yi9rj8XBtIf+JnnJL3DDxTjMM0PNwZTafvtoUgrUn+
 Hzq4jYsYVGYvasRW2Y8TxwfWZ6FQiYHlf+V8ptRIMdfOCUU+W6/hSrBx6iYAYNF2
 ENiav5/UeSfD42qxxhLD29fOQyECDJHF9F3oEFTr/BcX6BOwqbwNkywdZrHTQATi
 4OFH/FmvcibmfkYelmBzbaUqU775gLpAA9ivE+q1HBY2BwWKFJBhj2dzxNe8pLgI
 YmmBf8ronIlxfg5OqR1aQWkHSGU25uG+UTNge8/vd9LXxiJf4uZzvoWXHmJj3rvD
 9JyEWao8McJZMP66yf1E5hfg2rjKRDQRrCTyVGWdbKgoTvncNAV7qVFp//3pe9GI
 AcSa4bqznjerIPQTCNH1HJsMMPDHNJYtAVTgB6DGc/xPIfc+IUngx1ihZoUFebcw
 n1YjLDvZxrEValH4wU5zS0C8sMWb9nwFJjfvA/H3j9OgUD9aBZM5S9xIn+T2lm9t
 37iC8TpgU5yiNzUMMA==
 =qhHB
 -----END PGP SIGNATURE-----

Merge tag 'gcc-plugins-v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull gcc-plugins fix from Kees Cook:
 "Fix a potential problem in randomize_layout structure auto-selection
  (that was not triggered by any existing kernel structures)"

* tag 'gcc-plugins-v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  randstruct: Check member structs in is_pure_ops_struct()
This commit is contained in:
Linus Torvalds 2019-09-21 09:36:28 -07:00
commit 56c631f5ae
1 changed files with 5 additions and 5 deletions

View File

@ -443,13 +443,13 @@ static int is_pure_ops_struct(const_tree node)
if (node == fieldtype)
continue;
if (!is_fptr(fieldtype))
return 0;
if (code != RECORD_TYPE && code != UNION_TYPE)
if (code == RECORD_TYPE || code == UNION_TYPE) {
if (!is_pure_ops_struct(fieldtype))
return 0;
continue;
}
if (!is_pure_ops_struct(fieldtype))
if (!is_fptr(fieldtype))
return 0;
}