RFR: 8247732: validate user-input intrinsic_ids in ControlIntrinsic [v7]

Xin Liu xliu at openjdk.java.net
Thu Dec 3 00:26:16 UTC 2020


On Tue, 1 Dec 2020 21:32:04 GMT, Nils Eliasson <neliasso at openjdk.org> wrote:

>> Xin Liu has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>> 
>>  - 8247732: validate user-input intrinsic_ids in ControlIntrinsic
>>    
>>    fix typos in JDK-8256508
>>  - 8247732: validate user-input intrinsic_ids in ControlIntrinsic
>>    
>>    avoid a warning of stringop-overflow
>>  - 8247732: validate user-input intrinsic_ids in ControlIntrinsic
>>    
>>    rebase chagnes to tip. make use of JDK-8256508
>
> src/hotspot/share/compiler/compilerDirectives.hpp line 197:
> 
>> 195:     for (ControlIntrinsicIter iter(option, disabled_all); *iter != NULL && _valid; ++iter) {
>> 196:       if (vmIntrinsics::_none == vmIntrinsics::find_id(*iter)) {
>> 197:         _bad = NEW_C_HEAP_ARRAY(char, strlen(*iter) + 1, mtCompiler);
> 
> Hi, 
> 
> I wanted something like this:
> 
>         size_t len = MIN(strlen(*iter), 64);        // cap len to a value we know is enough for all intrinsic names
>         _bad = NEW_C_HEAP_ARRAY(char, len + 1, mtCompiler);
>         strncpy(_bad, *iter, len + 1);              // use strncpy to cap copy length

okay. I see.  I make change to ensure the _bad is a bound string. here is a test. the _bad is limited to 64  even user-input is overflown. 
java -XX:+UnlockDiagnosticVMOptions -XX:ControlIntrinsic=+_dtan,+_0123456789012345678901234567890123456789012345678901234567890123456789 -version
Unrecognized intrinsic detected in ControlIntrinsic: _012345678901234567890123456789012345678901234567890123456789012

-------------

PR: https://git.openjdk.java.net/jdk/pull/1179


More information about the hotspot-compiler-dev mailing list