Fix build and proof failures for CBMC ARP proofs#709
Fix build and proof failures for CBMC ARP proofs#709tony-josi-aws merged 32 commits intoFreeRTOS:dev/IPv6_integrationfrom
Conversation
Prior to this commit, CBMC would emit logging information in plain text format, which does not contain information required for the CBMC VSCode debugger. This commit makes CBMC use XML instead of plain text. Co-authored-by: Mark Tuttle <tuttle@acm.org>
* Adds /source/FreeRTOS_Routing.c to ARPAgeCache proof build
* Assumes pxNetworkEndPoints and pxNetworkEndPoints->pxNetworkInterface are properly initialized before ARPAgeCache is used.
* Assumes one endpoint and interface are only present
Changes to CBMC flags/configs:
* Added:
* `--unwindset FreeRTOS_OutputARPRequest.0:3` and `--unwindset vARPAgeCache.1:3` as per number of endpoints
* Modified:
* `--object-bits 8` to address: too many addressed objects: maximum number of objects is set to 2^n=128 (with n=7);
…arARP:
* New flags:
* "--unwindset FreeRTOS_ClearARP.0:7" to support loop in cleararp function
* Added argument to FreeRTOS_ClearARP in harness to support new change in API
Changes ------- Removed --nondet-static: proof fails if that option is enabled as the endpoint gets random value even if there is NULL check before its usage
Changes: ------- ARPProcessPacket takes new arg (NetworkBufferDescriptor_t *)
| NetworkBufferDescriptor_t * const pxNetworkBuffer, | ||
| BaseType_t xReleaseAfterSend ) | ||
| { | ||
| return 0; |
There was a problem hiding this comment.
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." );
| __CPROVER_assume( pxNetworkEndPoints != NULL ); | ||
| pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( pxNetworkEndPoints->pxNext != NULL ); | ||
| __CPROVER_assume( pxNetworkEndPoints->pxNext->pxNext == NULL ); |
There was a problem hiding this comment.
I think that instead of __CPROVER_assume, we can just set this value to NULL.
as in pxNetworkEndPoints->pxNext->pxNext = NULL;
| */ | ||
| xNetworkBuffer2.pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( xNetworkBuffer2.pxEndPoint != NULL ); | ||
| __CPROVER_assume( xNetworkBuffer2.pxEndPoint->pxNext == NULL ); |
There was a problem hiding this comment.
Same here, we can get away with just setting it to NULL.
|
|
||
| pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( pxNetworkEndPoints != NULL ); | ||
| __CPROVER_assume( pxNetworkEndPoints->pxNext == NULL ); |
| */ | ||
| uint8_t ucBUFFER_SIZE; | ||
|
|
||
| __CPROVER_assume( ucBUFFER_SIZE < CBMC_MAX_OBJECT_SIZE ); |
There was a problem hiding this comment.
Isn't this true automatically? the ucBUFFER_SIZE is an unsigned 8-bit integer meaning that it will never go beyond 255. I assume that CBMC_MAX_OBJECT_SIZE will at least be 16-bit value...
| eARPProcessPacket( &xARPFrame ); | ||
| /* | ||
| * The assumption made here is that the buffer pointed by pucEthernetBuffer | ||
| * is at least allocated to sizeof(ARPPacket_t) size but eventually a even larger buffer. |
There was a problem hiding this comment.
| * is at least allocated to sizeof(ARPPacket_t) size but eventually a even larger buffer. | |
| * is at least allocated to sizeof(ARPPacket_t) size but eventually an even larger buffer. |
| */ | ||
| xNetworkBuffer2.pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( xNetworkBuffer2.pxEndPoint != NULL ); | ||
| __CPROVER_assume( xNetworkBuffer2.pxEndPoint->pxNext == NULL ); |
There was a problem hiding this comment.
Set this to NULL directly.
|
|
||
| pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( pxNetworkEndPoints != NULL ); | ||
| __CPROVER_assume( pxNetworkEndPoints->pxNext == NULL ); |
There was a problem hiding this comment.
Why not try this with more than one network endpoint?
| NetworkBufferDescriptor_t * const pxNetworkBuffer, | ||
| BaseType_t xReleaseAfterSend ) | ||
| { | ||
|
|
There was a problem hiding this comment.
We should add asserts on the pointers to make sure that they are not NULL when stub is called.
| { | ||
| vReleaseNetworkBufferAndDescriptor( pxDescriptor ); | ||
| vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); | ||
| } |
There was a problem hiding this comment.
Assert on pointers being non-NULL here.
4574eae to
39d8c53
Compare
AniruddhaKanhere
left a comment
There was a problem hiding this comment.
Approved with one minor comment.
| __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; |
There was a problem hiding this comment.
Why are we returning 0 and not nondet_uint32?
This PR fixes the build issues and proof failures for the ARP CBMC proofs post the IPv6 changes.
Description
Major changes:
—nondet-staticfor ARPGetCacheEntryByMac proof: as proof fails if its there as the endpoint gets random value--object-bits 8from 7: as some of the existing proofs were having issues with more number addressed objects:too many addressed objects: maximum number of objects is set to 2^n=128 (with n=7);Test Steps
Related Issue
Failing CBMC proofs
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.