On Tue, Mar 21, 2017 at 12:05 AM, Brad Spengler <spen...@grsecurity.net> wrote: > Hi, > > As requested in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80094 > i'm attaching a patch for the issue described. > > Specifically: > when the plugin_name_args_tab hash table has its 11th entry inserted, it > trigers a hash table resize. This resize performs the hash_f against > each slot's value. Though the code was looking for matches in the hash > table via simple strings, the value of each slot was a pointer to a > plugin_name_args struct. The resize would thus effectively treat the > plugin_name_args struct as a string, producing incorrect hashes that result > in subsequent lookups for previously inserted items generally failing. > > To solve this, we use the correct hash function that operates on the > base_name field of the plugin_name_args struct and to minimize the changes > required, act in a similar way to tlink.c and other files by using the > _with_hash variants of lookup and removal functions, which allow us to > search based on just the names provided (which will match with the hash > formed from the base_name field). > > The patch is untested, but can be tested via the reproducer provided > at the link above. I have verified that it passes check_GNU_style.sh. > > All versions of GCC that support plugins (4.5+) are affected by this bug, > and users of grsecurity (who enable all the GCC plugins we provide) can > potentially hit this bug today (we have over 11 plugins, though some require > specific steps to enable) and definitely will hit it in the near future > as we add more GCC plugins. Since the bug results in a compile failure with > a deceptive error message (about arguments being out of order which aren't > in fact out of order), it's important to backport this to all affected > versions. > > Let me know if you have any questions or need anything else.
I've picked it up for my current test run on trunk and will commit it. It's a minor enough change to not need a copyright assignment but if you're going to do further contributions getting one is appreciated. Thanks, Richard. > Very Respectfully, > -Brad