Skip to content

Commit 1307457

Browse files
tony-josi-awskarkhazmarkrtuttle
authored
Fix CBMC proofs for IP (#725)
* Fixed CBMC proof for ProcessIPPacket * Use CBMC XML output to enable VSCode debugger (#673) 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]> * Fix CBMX proof for prvProcessEthernetPacket * adding more asserts * updating as per review comments --------- Co-authored-by: Kareem Khazem <[email protected]> Co-authored-by: Mark Tuttle <[email protected]>
1 parent 8f54d76 commit 1307457

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

test/cbmc/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ void harness()
6363

6464
__CPROVER_assume( pxNetworkBuffer != NULL );
6565

66-
/* Pointer to the start of the Ethernet frame. It should be able to access the whole Ethernet frame.*/
67-
pxNetworkBuffer->pucEthernetBuffer = malloc( ipTOTAL_ETHERNET_FRAME_SIZE );
66+
/* Points to ethernet buffer offset by ipIP_TYPE_OFFSET, this make sure the buffer allocation is similar
67+
to the pxGetNetworkBufferWithDescriptor */
68+
pxNetworkBuffer->pucEthernetBuffer = ( ( ( uint8_t * ) malloc( ipTOTAL_ETHERNET_FRAME_SIZE ) ) + ipIP_TYPE_OFFSET );
6869
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
6970

7071
/* Minimum length of the pxNetworkBuffer->xDataLength is at least the size of the IPPacket_t. */

test/cbmc/proofs/prvProcessEthernetPacket/prvProcessEthernetPacket_harness.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,33 @@ eFrameProcessingResult_t __CPROVER_file_local_FreeRTOS_IP_c_prvProcessIPPacket(
5656
return result;
5757
}
5858

59+
60+
BaseType_t NetworkInterfaceOutputFunction_Stub( struct xNetworkInterface * pxDescriptor,
61+
NetworkBufferDescriptor_t * const pxNetworkBuffer,
62+
BaseType_t xReleaseAfterSend )
63+
{
64+
BaseType_t xRet;
65+
__CPROVER_assert( pxDescriptor != NULL, "The network interface cannot be NULL." );
66+
__CPROVER_assert( pxNetworkBuffer != NULL, "The network buffer descriptor cannot be NULL." );
67+
__CPROVER_assert( pxNetworkBuffer->pucEthernetBuffer != NULL, "The Ethernet buffer cannot be NULL." );
68+
69+
return xRet;
70+
}
71+
5972
void harness()
6073
{
6174
NetworkBufferDescriptor_t * const pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, 0 );
62-
6375
/* The network buffer cannot be NULL for this function call. If it is, it will hit an assert in the function. */
6476
__CPROVER_assume( pxNetworkBuffer != NULL );
6577

78+
/* Add an endpoint */
79+
pxNetworkBuffer->pxEndPoint = ( NetworkEndPoint_t * ) malloc( sizeof( NetworkEndPoint_t ) );
80+
__CPROVER_assume( pxNetworkBuffer->pxEndPoint != NULL );
81+
82+
/* Interface init. */
83+
pxNetworkBuffer->pxEndPoint->pxNetworkInterface = ( NetworkInterface_t * ) malloc( sizeof( NetworkInterface_t ) );
84+
__CPROVER_assume( pxNetworkBuffer->pxEndPoint->pxNetworkInterface != NULL );
85+
pxNetworkBuffer->pxEndPoint->pxNetworkInterface->pfOutput = NetworkInterfaceOutputFunction_Stub;
86+
6687
__CPROVER_file_local_FreeRTOS_IP_c_prvProcessEthernetPacket( pxNetworkBuffer );
6788
}

0 commit comments

Comments
 (0)