Page MenuHomeFreeBSD

Static analysis: Fix potential NULL dereference in ICMP6 code
ClosedPublic

Authored by jtl on May 26 2017, 4:54 PM.
Tags
None
Referenced Files
F153584531: D10941.id28872.diff
Wed, Apr 22, 3:12 AM
Unknown Object (File)
Tue, Apr 21, 4:31 PM
Unknown Object (File)
Sun, Apr 19, 5:56 PM
Unknown Object (File)
Sat, Apr 18, 1:59 PM
Unknown Object (File)
Wed, Apr 15, 11:39 AM
Unknown Object (File)
Wed, Apr 8, 3:51 AM
Unknown Object (File)
Tue, Apr 7, 9:23 PM
Unknown Object (File)
Sun, Apr 5, 9:19 PM
Subscribers

Details

Summary

I ran clang's static analyzer over the kernel sources. It identified (apparently, correctly) two places in the ICMP6 code where we could dereference a NULL pointer in the icmp6_input() function.

When processing an ICMP6_ECHO_REQUEST, if IP6_EXTHDR_GET fails, it will set nicmp6 and n to NULL. Therefore, we should condition our modification to nicmp6 on n being not NULL.

And, when processing an ICMP6_WRUREQUEST in the (mode != FQDN) case, if m_dup_pkthdr() fails, the code will set n to NULL. However, the very next line dereferences n. Therefore, when m_dup_pkthdr() fails, we should discontinue further processing and follow the same path as when m_gethdr() fails.

Sponsored by: Netflix
MFC after: 2 weeks

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable