Skip to content
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

[CBMC] Add assert with readability check #214

Merged
merged 38 commits into from
Mar 22, 2021
Merged
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be9fe45
Fix compiler warnings when the TCP Window is not used (#124)
AniruddhaKanhere Dec 18, 2020
f39f440
Move local variables to inner loop in prvNetworkInterfaceInput() (#144)
htibosch Jan 5, 2021
e696768
Update litani submodule (#147)
markrtuttle Jan 7, 2021
307bacb
Fix doxygen check (#149)
AniruddhaKanhere Jan 11, 2021
b80e096
TCP_WIN: fix compile warning on x86_64 (#148)
twpedersen Jan 14, 2021
4a05a0a
fix deprecated volatile compound assignment (#152)
hs2gh Jan 14, 2021
f3650e4
FreeRTOS_ARP.c : store local addresses only (#120)
htibosch Jan 15, 2021
2ecc851
Remove unnecessary #ifndef (#186)
AniruddhaKanhere Jan 28, 2021
82fa238
Don't Fragment Flags patch. (#179)
evpopov Feb 3, 2021
9e364b9
fix IP buffer padding check on 64bit (#146)
twpedersen Feb 8, 2021
20cbc94
Update readme.md (#189)
shrewmouse1 Feb 8, 2021
7a56144
Update files referencing aws_application_version.h to use iot_applica…
paulbartell Feb 8, 2021
a4d261c
Remove function defs from header files (#190)
AniruddhaKanhere Feb 9, 2021
ffc9612
Do not release a network buffer if it equals to NULL (#191)
htibosch Feb 12, 2021
245d1c5
Circumvent Qemu MPS2 networking bug (#142)
alfred2g Feb 16, 2021
38c4054
Add a project for static analysis (#195)
AniruddhaKanhere Feb 19, 2021
809b438
Merge pull request #9 from FreeRTOS/main
AniruddhaKanhere Feb 24, 2021
c35ee3e
Create uncrustify.yml
AniruddhaKanhere Feb 28, 2021
894fe96
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
be69988
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
2ba96b2
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
bfe8232
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
9152cde
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
40410e1
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
d7e314c
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
0a27eb9
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
48beb6b
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
faed2e1
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
6b98a33
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
d621465
Update uncrustify.yml
AniruddhaKanhere Feb 28, 2021
65e4f32
Update proof to use assert with readability check
AniruddhaKanhere Mar 19, 2021
1629b53
Revert ci.yml changes
AniruddhaKanhere Mar 19, 2021
bcb52e3
Merge branch 'main' into CBMCAddAssert
AniruddhaKanhere Mar 19, 2021
0f90a55
Remove unwanted changes
AniruddhaKanhere Mar 19, 2021
7d12d86
Merge branch 'CBMCAddAssert' of https://github.com/aniruddhakanhere/f…
AniruddhaKanhere Mar 19, 2021
b541382
Null check
AniruddhaKanhere Mar 19, 2021
96df001
Fix adding NULL checks
AniruddhaKanhere Mar 22, 2021
1a7ad02
Uncrustify
AniruddhaKanhere Mar 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

#include "../../utility/memory_assignments.c"

/* This proof assumes that pxDuplicateNetworkBufferWithDescriptor is implemented correctly. */
#include "cbmc.h"

/* This proof assumes that pxDuplicateNetworkBufferWithDescriptor is implemented correctly. */
void publicTCPReturnPacket( FreeRTOS_Socket_t * pxSocket,
NetworkBufferDescriptor_t * pxNetworkBuffer,
uint32_t ulLen,
Expand All @@ -59,12 +60,23 @@ NetworkBufferDescriptor_t * pxDuplicateNetworkBufferWithDescriptor( const Networ
return pxNetworkBuffer;
}

BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * pxDescriptor,
BaseType_t xReleaseAfterSend )
{
AniruddhaKanhere marked this conversation as resolved.
Show resolved Hide resolved
BaseType_t xReturn;

__CPROVER_assert( pxDescriptor != NULL , "The descriptor cannot be NULL" );
__CPROVER_assert( pxDescriptor->pucEthernetBuffer != NULL, "The ethernet buffer cannot be NULL" );

return xReturn;
}

uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer,
size_t uxBufferLength,
BaseType_t xOutgoingPacket )
{
__CPROVER_assert( pucEthernetBuffer != NULL, "The ethernet buffer cannot be NULL" );
__CPROVER_r_ok( pucEthernetBuffer, uxBufferLength );
__CPROVER_assert( __CPROVER_r_ok( pucEthernetBuffer, uxBufferLength ), "pucEthernetBuffer should be readable." );

uint16_t usReturn;
return usReturn;
Expand All @@ -75,7 +87,7 @@ uint16_t usGenerateChecksum( uint16_t usSum,
size_t uxByteCount )
{
__CPROVER_assert( pucNextData != NULL, "The next data pointer cannot be NULL" );
__CPROVER_r_ok( pucNextData, uxByteCount );
__CPROVER_assert( __CPROVER_r_ok( pucNextData, uxByteCount ), "The pucNextData should be readable." );

uint16_t usReturn;
return usReturn;
Expand All @@ -86,16 +98,30 @@ void harness()
FreeRTOS_Socket_t * pxSocket = ensure_FreeRTOS_Socket_t_is_allocated();
NetworkBufferDescriptor_t * pxNetworkBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();

/* The code does not expect both of these to be equal to NULL at the same time. */
__CPROVER_assume( pxSocket != NULL || pxNetworkBuffer != NULL );

uint32_t ulLen;

/* If network buffer is properly created. */
if( ensure_memory_is_valid( pxNetworkBuffer, sizeof( *pxNetworkBuffer ) ) )
{
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( sizeof( TCPPacket_t ) );
/* Assume that the length is proper. */
__CPROVER_assume( ( ulLen >= sizeof( TCPPacket_t ) ) && ( ulLen < ipconfigNETWORK_MTU ) );
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( ulLen + ipSIZE_OF_ETH_HEADER );
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer );
}
/* If not. */
else
{
/* Assume that the length is proper. The length should be between this range. It
* is made so by the functions up the call tree. Essentially, this is equal to a
* TCP packet header with and without TCP options. */
__CPROVER_assume( ( ulLen >= ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this will need rework for IPv6 support.

( ulLen <= ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + 40 /* Maximum option bytes. */ ) );
}

uint32_t ulLen;
BaseType_t xReleaseAfterSend;

/* The code does not expect both of these to be equal to NULL at the same time. */
__CPROVER_assume( pxSocket != NULL || pxNetworkBuffer != NULL );
publicTCPReturnPacket( pxSocket, pxNetworkBuffer, ulLen, xReleaseAfterSend );
}