Skip to content

Conversation

@tony-josi-aws
Copy link
Member

This PR fixes the build issues and proof failures for the ARP CBMC proofs post the IPv6 changes.

Description

Major changes:

  • As the support multiple endpoint was added in dev/IPv6_integration, this PR allocates endpoints to get rid of asserts and validate functions
  • Removed —nondet-static for ARPGetCacheEntryByMac proof: as proof fails if its there as the endpoint gets random value
  • Increased global object-bits to --object-bits 8 from 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

cd test/cbmc/proofs/
python run-cbmc-proofs.py

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.

karkhaz and others added 15 commits February 4, 2023 09:02
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 *)
@tony-josi-aws tony-josi-aws requested a review from a team as a code owner February 13, 2023 11:43
NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t xReleaseAfterSend )
{
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

__CPROVER_assume( pxNetworkEndPoints != NULL );
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
__CPROVER_assume( pxNetworkEndPoints->pxNext->pxNext == NULL );
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 that instead of __CPROVER_assume, we can just set this value to NULL.
as in pxNetworkEndPoints->pxNext->pxNext = NULL;

Copy link
Member Author

@tony-josi-aws tony-josi-aws Feb 15, 2023

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 );
Copy link
Member

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 );
Copy link
Member

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 );
Copy link
Member

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...

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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.

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

*/
xNetworkBuffer2.pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( xNetworkBuffer2.pxEndPoint != NULL );
__CPROVER_assume( xNetworkBuffer2.pxEndPoint->pxNext == NULL );
Copy link
Member

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.

Copy link
Member Author

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 );
Copy link
Member

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?

Copy link
Member Author

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 )
{

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

{
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
}
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Member

@AniruddhaKanhere AniruddhaKanhere left a 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;
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?

@tony-josi-aws tony-josi-aws merged commit a489ea5 into FreeRTOS:dev/IPv6_integration Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants