Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
75e6fde
Use CBMC XML output to enable VSCode debugger (#673)
karkhaz Jan 13, 2023
5a0bac2
Fixes CBMC proof for the ARPAgeCache function:
tony-josi-aws Feb 6, 2023
a1371d9
Fixes CBMC proof build failure and proof failure for ARP_FreeRTOS_Cle…
tony-josi-aws Feb 6, 2023
8068a1d
Merge branch 'dev/IPv6_integration' into fix_cbmc_proof_arp
tony-josi-aws Feb 7, 2023
ff05ea3
Fixed ARPGenerateRequestPacket CBMC proof
tony-josi-aws Feb 7, 2023
be35723
Fixed ARPGetCacheEntryByMac proof:
tony-josi-aws Feb 7, 2023
441e266
Fix ARPProcessPacket CBMC proof:
tony-josi-aws Feb 7, 2023
1999639
Fixed CBMC proof for ARP_OutputARPRequest_buffer_alloc1 diff configs
tony-josi-aws Feb 7, 2023
e0f3d75
Fixed CBMC proof for ARP_OutputARPRequest_buffer_alloc2 diff configs
tony-josi-aws Feb 7, 2023
c17d11d
Fix CBMC proof for ARPGetCacheEntry
tony-josi-aws Feb 7, 2023
759182e
Fixed proofs for ARPRefreshCacheEntry
tony-josi-aws Feb 8, 2023
2895b31
Fixed CBMC proof for ARP_FreeRTOS_OutputARPRequest
tony-josi-aws Feb 8, 2023
e3313df
Merge branch 'dev/IPv6_integration' into fix_cbmc_proof_arp
tony-josi-aws Feb 11, 2023
a5d9b57
Fix cbmc proof for ARPProcessPacket
tony-josi-aws Feb 11, 2023
a48c5ef
fixed cbmc target func not called issue in ARP_FreeRTOS_PrintARPCache
tony-josi-aws Feb 13, 2023
62f0638
adding changes as per review comments
tony-josi-aws Feb 14, 2023
563b329
add multiple endpoints
tony-josi-aws Feb 14, 2023
7b22b34
config fix for multiple end point
tony-josi-aws Feb 14, 2023
f575184
wip
tony-josi-aws Feb 14, 2023
b6b388d
assigning null instead of assuming
tony-josi-aws Feb 15, 2023
e6e3b81
fixe minor isssue
tony-josi-aws Feb 15, 2023
b1f9e46
update asume to assignment
tony-josi-aws Feb 16, 2023
f516277
more comments
tony-josi-aws Feb 17, 2023
39d8c53
Merge branch 'dev/IPv6_integration' into fix_cbmc_proof_arp
tony-josi-aws Feb 17, 2023
a338c5c
Revert "update asume to assignment"
tony-josi-aws Feb 17, 2023
49cbd55
reverting kernel submodule change
tony-josi-aws Feb 17, 2023
55a3ed9
addding non deterministic number of endpoints
tony-josi-aws Feb 17, 2023
7e0a5b6
addding non deterministic number of endpoints
tony-josi-aws Feb 17, 2023
195e024
addding non deterministic number of endpoints
tony-josi-aws Feb 17, 2023
e9c8861
addding non deterministic number of endpoints
tony-josi-aws Feb 17, 2023
4954db6
addding non deterministic number of endpoints
tony-josi-aws Feb 17, 2023
2322350
Merge branch 'dev/IPv6_integration' into fix_cbmc_proof_arp
tony-josi-aws Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test/cbmc/proofs/ARP/ARPAgeCache/ARPAgeCache_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,45 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS
return pxNetworkBuffer;
}

BaseType_t NetworkInterfaceOutputFunction_Stub( struct xNetworkInterface * pxDescriptor,
NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t xReleaseAfterSend )
{
__CPROVER_assert( pxDescriptor != NULL, "The network interface cannot be NULL." );
__CPROVER_assert( pxNetworkBuffer != NULL, "The network buffer descriptor cannot be NULL." );
__CPROVER_assert( pxNetworkBuffer->pucEthernetBuffer != NULL, "The Ethernet buffer cannot be NULL." );
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we check the validity of the pointers in the stub by adding something like this:

__CPROVER_assert( pxDescriptor != NULL, "The network interface cannot be NULL." );
__CPROVER_assert( pxNetworkBuffer != NULL, "The network buffer descriptor cannot be NULL." );

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we returning 0 and not nondet_uint32?

}

void harness()
{
/*
For this proof, its assumed that the endpoints and interfaces are correctly
initialised and the pointers are set correctly.
Assumes two endpoints and interface is present.
*/

pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints != NULL );

/* Interface init. */
pxNetworkEndPoints->pxNetworkInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNetworkInterface != NULL );

if( nondet_bool() )
{
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
pxNetworkEndPoints->pxNext->pxNext = NULL;
pxNetworkEndPoints->pxNext->pxNetworkInterface = pxNetworkEndPoints->pxNetworkInterface;
}
else
{
pxNetworkEndPoints->pxNext = NULL;
}

pxNetworkEndPoints->pxNetworkInterface->pfOutput = NetworkInterfaceOutputFunction_Stub;
/* No assumption is added for pfOutput as its pointed to a static object/memory location. */

vARPAgeCache();
}
3 changes: 3 additions & 0 deletions test/cbmc/proofs/ARP/ARPAgeCache/Makefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
[
"--unwind 1",
"--unwindset vARPAgeCache.0:7",
"--unwindset FreeRTOS_OutputARPRequest.0:3",
"--unwindset vARPAgeCache.1:3",
"--nondet-static"
],
"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Routing.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto",
"$(FREERTOS_PLUS_TCP)/test/FreeRTOS-Kernel/tasks.goto"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ void harness()
xNetworkBuffer2.pucEthernetBuffer = xBuffer;
xNetworkBuffer2.xDataLength = ucBUFFER_SIZE;

/*
This proof assumes one end point is present.
*/
xNetworkBuffer2.pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( xNetworkBuffer2.pxEndPoint != NULL );
xNetworkBuffer2.pxEndPoint->pxNext = NULL;

/* vARPGenerateRequestPacket asserts buffer has room for a packet */
__CPROVER_assume( xNetworkBuffer2.xDataLength >= sizeof( ARPPacket_t ) );
vARPGenerateRequestPacket( &xNetworkBuffer2 );
Expand Down
35 changes: 34 additions & 1 deletion test/cbmc/proofs/ARP/ARPGetCacheEntry/ARPGetCacheEntry_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,38 @@ void harness()
uint32_t ulIPAddress;
MACAddress_t xMACAddress;

eARPGetCacheEntry( &ulIPAddress, &xMACAddress );
/*
For this proof, its assumed that the endpoints and interfaces are correctly
initialised and the pointers are set correctly.
Assumes one endpoint and interface is present.
*/

pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints != NULL );

/* Interface init. */
pxNetworkEndPoints->pxNetworkInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNetworkInterface != NULL );

if( nondet_bool() )
{
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
pxNetworkEndPoints->pxNext->pxNext = NULL;
pxNetworkEndPoints->pxNext->pxNetworkInterface = pxNetworkEndPoints->pxNetworkInterface;
}
else
{
pxNetworkEndPoints->pxNext = NULL;
}

NetworkInterface_t **ppxInterface = ( NetworkInterface_t ** ) malloc( sizeof( NetworkInterface_t * ) );

if ( ppxInterface )
{
*ppxInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( *ppxInterface != NULL );
}

eARPGetCacheEntry( &ulIPAddress, &xMACAddress, ppxInterface );
}
5 changes: 5 additions & 0 deletions test/cbmc/proofs/ARP/ARPGetCacheEntry/Configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
[
"--unwind 1",
"--unwindset prvCacheLookup.0:7",
"--unwindset FreeRTOS_FindEndPointOnIP_IPv4.0:3",
"--unwindset FreeRTOS_InterfaceEndPointOnNetMask.0:3",
"--unwindset eARPGetCacheEntry.0:3",
"--unwindset FreeRTOS_FindGateWay.0:3",
"--nondet-static"
],
"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Routing.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto"
],
"DEF":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_ARP.h"

extern ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ];

static NetworkEndPoint_t xEndPoint_Temp;

void harness()
{
MACAddress_t xMACAddress;
uint32_t ulIPAddress;

eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress );
NetworkInterface_t **ppxInterface = ( NetworkInterface_t ** ) malloc( sizeof( NetworkInterface_t * ) );

if ( ppxInterface )
{
*ppxInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( *ppxInterface != NULL );
}

eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, ppxInterface );
}
3 changes: 1 addition & 2 deletions test/cbmc/proofs/ARP/ARPGetCacheEntryByMac/Makefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"ENTRY": "ARPGetCacheEntryByMac",
"CBMCFLAGS":
[
"--unwind 7",
"--nondet-static"
"--unwind 7"
],
"OBJS":
[
Expand Down
30 changes: 28 additions & 2 deletions test/cbmc/proofs/ARP/ARPProcessPacket/ARPProcessPacket_harness.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "cbmc.h"

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "queue.h"
Expand All @@ -17,7 +19,6 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress )

void harness()
{
ARPPacket_t xARPFrame;
NetworkBufferDescriptor_t xLocalBuffer;
uint16_t usEthernetBufferSize;

Expand Down Expand Up @@ -47,5 +48,30 @@ void harness()
pxARPWaitingNetworkBuffer = NULL;
}

eARPProcessPacket( &xARPFrame );
/*
* The assumption made here is that the buffer pointed by pucEthernetBuffer
* is at least allocated to sizeof(ARPPacket_t) size but eventually an even larger buffer.
* This is not checked inside eARPProcessPacket.
*/
uint8_t ucBUFFER_SIZE;

void * xBuffer = malloc( ucBUFFER_SIZE + sizeof( ARPPacket_t ) );

__CPROVER_assume( xBuffer != NULL );

NetworkBufferDescriptor_t xNetworkBuffer2;

xNetworkBuffer2.pucEthernetBuffer = xBuffer;
xNetworkBuffer2.xDataLength = ucBUFFER_SIZE + sizeof(ARPPacket_t);

/*
This proof assumes one end point is present.
*/
xNetworkBuffer2.pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( xNetworkBuffer2.pxEndPoint != NULL );
xNetworkBuffer2.pxEndPoint->pxNext = NULL;

/* eARPProcessPacket will be called in the source code only after checking if
xNetworkBuffer2.pucEthernetBuffer is not NULL, hence, __CPROVER_assume( xBuffer != NULL ); */
eARPProcessPacket( &xNetworkBuffer2 );
}
1 change: 1 addition & 0 deletions test/cbmc/proofs/ARP/ARPProcessPacket/Makefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[
"--unwind 1",
"--unwindset vARPRefreshCacheEntry.0:7,memcmp.0:17,xIsIPInARPCache.0:7",
"--unwindset prvFindCacheEntry.0:7",
"--nondet-static"
],
"OBJS":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ void harness()
MACAddress_t xMACAddress;
uint32_t ulIPAddress;

vARPRefreshCacheEntry( &xMACAddress, ulIPAddress );
vARPRefreshCacheEntry( NULL, ulIPAddress );
/*
For this proof, its assumed that the endpoints and interfaces are correctly
initialised and the pointers are set correctly.
Assumes one endpoints and interface is present.
*/

pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints != NULL );

/* Interface init. */
pxNetworkEndPoints->pxNetworkInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNetworkInterface != NULL );

if( nondet_bool() )
{
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
pxNetworkEndPoints->pxNext->pxNext = NULL;
pxNetworkEndPoints->pxNext->pxNetworkInterface = pxNetworkEndPoints->pxNetworkInterface;
}
else
{
pxNetworkEndPoints->pxNext = NULL;
}


NetworkEndPoint_t * pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxEndPoint != NULL );

vARPRefreshCacheEntry( &xMACAddress, ulIPAddress, pxEndPoint );
vARPRefreshCacheEntry( NULL, ulIPAddress, pxEndPoint );
}
7 changes: 4 additions & 3 deletions test/cbmc/proofs/ARP/ARPRefreshCacheEntry/Configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"CBMCFLAGS":
[
"--unwind 1",
"--unwindset vARPRefreshCacheEntry.0:7,memcmp.0:17",
"--nondet-static"
"--unwindset FreeRTOS_InterfaceEndPointOnNetMask.0:3",
"--unwindset prvFindCacheEntry.0:7,memcmp.0:17"
],
"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto"
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Routing.goto"
],
"DEF":
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@

void harness()
{
FreeRTOS_ClearARP();

NetworkEndPoint_t *pxEndPoint_Test = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
/*
Here the assumption that pxEndPoint_Test != NULL [__CPROVER_assume( pxEndPoint_Test != NULL );]
is not made as pxEndPoint_Test == NULL is a valid use case.
*/

FreeRTOS_ClearARP(pxEndPoint_Test);
}
3 changes: 2 additions & 1 deletion test/cbmc/proofs/ARP/ARP_FreeRTOS_ClearARP/Makefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"ENTRY": "ClearARP",
"CBMCFLAGS":
[
"--unwind 1"
"--unwind 1",
"--unwindset FreeRTOS_ClearARP.0:7"
],
"OBJS":
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Routing.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto"
],
#That is the minimal required size for an ARPPacket_t plus offset in the buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,49 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS
return &xNetworkBuffer;
}

BaseType_t NetworkInterfaceOutputFunction_Stub( struct xNetworkInterface * pxDescriptor,
NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t xReleaseAfterSend )
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add asserts on the pointers to make sure that they are not NULL when stub is called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

__CPROVER_assert( pxDescriptor != NULL, "The network interface cannot be NULL." );
__CPROVER_assert( pxNetworkBuffer != NULL, "The network buffer descriptor cannot be NULL." );
__CPROVER_assert( pxNetworkBuffer->pucEthernetBuffer != NULL, "The ethernet buffer cannot be NULL." );

}


void harness()
{
uint32_t ulIPAddress;

/*
For this proof, its assumed that the endpoints and interfaces are correctly
initialised and the pointers are set correctly.
Assumes one endpoint and interface is present.
*/

pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints != NULL );

/* Interface init. */
pxNetworkEndPoints->pxNetworkInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNetworkInterface != NULL );

if( nondet_bool() )
{
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
pxNetworkEndPoints->pxNext->pxNext = NULL;
pxNetworkEndPoints->pxNext->pxNetworkInterface = pxNetworkEndPoints->pxNetworkInterface;
}
else
{
pxNetworkEndPoints->pxNext = NULL;
}

pxNetworkEndPoints->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub;
/* No assumption is added for pfOutput as its pointed to a static object/memory location. */

FreeRTOS_OutputARPRequest( ulIPAddress );
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "FreeRTOSIPConfig.h"
#include "FreeRTOS_ARP.h"

void FreeRTOS_PrintARPCache( void );

void harness()
{
FreeRTOS_PrintARPCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
],
"DEF":
[
"ipconfigARP_CACHE_ENTRIES=6"
"ipconfigARP_CACHE_ENTRIES=6",
"ipconfigHAS_PRINTF=1"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_ARP.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Routing.goto",
"$(FREERTOS_PLUS_TCP)/source/portable/BufferManagement/BufferAllocation_1.goto",
"$(FREERTOS_PLUS_TCP)/test/FreeRTOS-Kernel/list.goto",
"$(FREERTOS_PLUS_TCP)/test/FreeRTOS-Kernel/queue.goto"
Expand Down
Loading