Skip to content

Commit ece06d3

Browse files
authored
Add NeighborDiscovery caching checks (#1368)
1. Protect against unsolicited neighbor advertisements writing to the cache 2. Protect against MAC caching for spoofed packets We thank Causal Security (https://causalsecurity.com) for their help identifying this issue. We thank @htibosch for the extensive help developing source code changes for this fix
1 parent 201d3b6 commit ece06d3

19 files changed

Lines changed: 4028 additions & 532 deletions

File tree

‎.github/.cSpellWords.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ NCARR
810810
NCFGR
811811
NCONFIG
812812
NCPDT
813+
neighbours
813814
Netif
814815
Nett
815816
netto
@@ -1360,6 +1361,7 @@ THALT
13601361
THRES
13611362
tiarmclang
13621363
TIDM
1364+
TLLA
13631365
tmout
13641366
TMXBFR
13651367
totalappdescnbr

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
uses: FreeRTOS/CI-CD-Github-Actions/formatting@main
137137
with:
138138
path: ./
139-
exclude-dirs: source/portable/NetworkInterface/STM32
139+
exclude-dirs: source/portable/NetworkInterface/STM32, test/integration-test/ndp
140140

141141
doxygen:
142142
runs-on: ubuntu-latest

‎source/FreeRTOS_IP.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,17 +1823,18 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
18231823
#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 )
18241824
if( pxNDWaitingNetworkBuffer == NULL )
18251825
{
1826+
/* Nothing to copy out: the ND code reads the source address
1827+
* back out of the packet itself. */
18261828
pxNDWaitingNetworkBuffer = pxNetworkBuffer;
18271829
vIPTimerStartNDResolution( ipND_RESOLUTION_MAX_DELAY );
1828-
18291830
iptraceDELAYED_ND_REQUEST_STARTED();
18301831
}
18311832
else
18321833
#endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */
18331834
{
18341835
/* We are already waiting on one resolution. This frame will be dropped. */
18351836
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
1836-
1837+
FreeRTOS_debug_printf( ( "NDBuffer: = full/release\n" ) );
18371838
iptraceDELAYED_ND_BUFFER_FULL();
18381839
}
18391840

@@ -2131,7 +2132,8 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
21312132
{
21322133
#if ( ipconfigUSE_IPv6 != 0 )
21332134
case ipIPv6_FRAME_TYPE:
2134-
vNDRefreshCacheEntry( &( pxIPPacket->xEthernetHeader.xSourceAddress ), &( pxIPHeader_IPv6->xSourceAddress ), pxNetworkBuffer->pxEndPoint );
2135+
vNDRefreshCacheEntryAge( &( pxIPPacket->xEthernetHeader.xSourceAddress ),
2136+
&( pxIPHeader_IPv6->xSourceAddress ) );
21352137
break;
21362138
#endif /* ( ipconfigUSE_IPv6 != 0 ) */
21372139

@@ -2163,9 +2165,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
21632165
* went wrong because it will not be able to validate what it
21642166
* receives. */
21652167
#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )
2166-
{
21672168
eReturn = ProcessICMPPacket( pxNetworkBuffer );
2168-
}
21692169
#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */
21702170
break;
21712171
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

‎source/FreeRTOS_IP_Timers.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,10 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer )
694694
void vIPSetDHCP_RATimerEnableState( NetworkEndPoint_t * pxEndPoint,
695695
BaseType_t xEnableState )
696696
{
697-
FreeRTOS_printf( ( "vIPSetDHCP_RATimerEnableState: %s\n", ( xEnableState != 0 ) ? "On" : "Off" ) );
697+
if( ( pxEndPoint->xDHCP_RATimer.bActive != 0 ) != ( xEnableState != 0 ) )
698+
{
699+
FreeRTOS_printf( ( "vIPSetDHCP_RATimerEnableState: %s\n", ( xEnableState != 0 ) ? "On" : "Off" ) );
700+
}
698701

699702
/* 'xDHCP_RATimer' is shared between DHCP (IPv4) and RA/SLAAC (IPv6). */
700703
if( xEnableState != 0 )

0 commit comments

Comments
 (0)