-
Notifications
You must be signed in to change notification settings - Fork 206
Fix build and proof failures for CBMC ARP proofs #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build and proof failures for CBMC ARP proofs #709
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 <[email protected]>
* 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.
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." );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| __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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that instead of __CPROVER_assume, we can just set this value to NULL.
as in pxNetworkEndPoints->pxNext->pxNext = NULL;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed all cases
| */ | ||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here as well.
| */ | ||
| uint8_t ucBUFFER_SIZE; | ||
|
|
||
| __CPROVER_assume( ucBUFFER_SIZE < CBMC_MAX_OBJECT_SIZE ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
| */ | ||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set this to NULL directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated all
|
|
||
| pxNetworkEndPoints = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) ); | ||
| __CPROVER_assume( pxNetworkEndPoints != NULL ); | ||
| __CPROVER_assume( pxNetworkEndPoints->pxNext == NULL ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not try this with more than one network endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| NetworkBufferDescriptor_t * const pxNetworkBuffer, | ||
| BaseType_t xReleaseAfterSend ) | ||
| { | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
| { | ||
| vReleaseNetworkBufferAndDescriptor( pxDescriptor ); | ||
| vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert on pointers being non-NULL here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
4574eae to
39d8c53
Compare
AniruddhaKanhere
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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?
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.