Skip to content

Commit

Permalink
Fix CBMC proof for xCheckRequiresARPResolution
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws committed Nov 8, 2024
1 parent 6ae79f1 commit 5341b9b
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,12 @@ void harness()
NetworkBufferDescriptor_t * pxNetworkBuffer;
IPPacket_t * pxIPPacket;

/* IPv4/IPv6 header size are different. To make sure buffer size is enough,
* determine the test case is for IPv4 or IPv6 at the beginning. */
xIsIPv6 = nondet_bool();
const IPPacket_t * pxIPPacket;
const IPHeader_t * pxIPHeader;

if( xIsIPv6 )
{
__CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_IPv6_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) );
}
else
{
__CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) );
}
/* Make sure buffer size is enough, xCheckRequiresARPResolution is only called for
IPv4 packets hence the minimum size should be sizeof( IPPacket_t ) */
__CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) );

pxNetworkBuffer = ( NetworkBufferDescriptor_t * ) safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
__CPROVER_assume( pxNetworkBuffer != NULL );
Expand All @@ -111,6 +105,13 @@ void harness()
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( xBufferLength );
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );

/* Its asserted in the code that xCheckRequiresARPResolution is only called on IPv4 frame types */
/* See assertion: configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) );
in xCheckRequiresARPResolution() */
pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
pxIPHeader = &( pxIPPacket->xIPHeader );
__CPROVER_assume(pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE);

pxNetworkBuffer->pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
__CPROVER_assume( pxNetworkBuffer->pxEndPoint != NULL );

Expand Down

0 comments on commit 5341b9b

Please sign in to comment.