[BUG] CBMC: operator precedence turns the pxUDPPayloadBuffer_to_NetworkBuffer harness assumption into assume(false)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 95/100
Direzione di ricerca
Apri test/cbmc/proofs/IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer/pxUDPPayloadBuffer_to_NetworkBuffer_harness.c alla riga 88 e controlla la precedenza degli operatori nell’assunzione sul tipo IP. Aggiungi parentesi affinché la maschera venga valutata prima di ogni confronto di uguaglianza. Poi esegui i comandi di riproduzione nell’issue e conferma che CBMC segnali SUCCESS, 94 properties e coverage after the assumption come SATISFIED.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
In the CBMC proof IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer, the IP-type assumption on harness line 88 is always false, because == binds tighter than &. CBMC therefore never reaches the call to pxUDPPayloadBuffer_to_NetworkBuffer() on line 90, so none of the proof's 94 properties is checked on an actual execution of the function, yet make cbmc reports SUCCESS. Only the proof is affected, and it still passes after the fix below.
pxUDPPayloadBuffer_to_NetworkBuffer_harness.c, line 88:
__CPROVER_assume( ( ( *pucIPType ) & 0xf0 == ipTYPE_IPv4 ) || ( ( *pucIPType ) & 0xf0 == ipTYPE_IPv6 ) );
This is ( *pucIPType & ( 0xf0 == 0x40 ) ) || ( *pucIPType & ( 0xf0 == 0x60 ) ), that is *pucIPType & 0 || *pucIPType & 0, which is always 0. gcc -Wparentheses warns about both & operands on this line. The library code masks first (FreeRTOS_IP_Utils.c, line 748).
Target
Not target-specific: CBMC proof only.
Host
Ubuntu 22.04 (x86-64), CBMC 6.3.1 (the version pinned in .github/workflows/ci.yml), 32-bit glibc headers from libc6-dev-i386. main at b86ad086e9870099bb0ac18a75dcb7f6dd508cc7 (V4.4.2).
To Reproduce
The cbmc line uses the proof's own CBMCFLAGS.
git clone https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git
cd FreeRTOS-Plus-TCP
git checkout b86ad086e9870099bb0ac18a75dcb7f6dd508cc7
git submodule update --init --checkout test/FreeRTOS-Kernel
cd test/cbmc/proofs
python3 prepare.py
cd IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer
make goto
make -s cbmc; grep '<cprover-status>' cbmc.xml; grep -c '<result ' cbmc.xml
cbmc --32 --object-bits 8 --unwind 1 --nondet-static --cover assume pxUDPPayloadBuffer_to_NetworkBuffer.goto | grep 'line 88'
Last lines of the output:
<cprover-status>SUCCESS</cprover-status>
94
[harness.coverage.11] file pxUDPPayloadBuffer_to_NetworkBuffer_harness.c line 88 function harness assert(false) before assume(((signed int)*pucIPType & (signed int)((unsigned int)0xF0 == 0x40u)) != 0 || ((signed int)*pucIPType & (signed int)((unsigned int)0xF0 == 0x60u)) != 0): SATISFIED
[harness.coverage.12] file pxUDPPayloadBuffer_to_NetworkBuffer_harness.c line 88 function harness assert(false) after assume(((signed int)*pucIPType & (signed int)((unsigned int)0xF0 == 0x40u)) != 0 || ((signed int)*pucIPType & (signed int)((unsigned int)0xF0 == 0x60u)) != 0): FAILED
before ...: SATISFIED together with after ...: FAILED means that CBMC reaches the assumption but the assumption never holds.
Expected behavior
The point after the assumption is reachable (after ...: SATISFIED), so pxUDPPayloadBuffer_to_NetworkBuffer() is actually checked. With the patch below, the same commands print SUCCESS, 94 and after ...: SATISFIED.
Additional context
Suggested fix (apply with git apply from the repository root):
diff --git a/test/cbmc/proofs/IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer/pxUDPPayloadBuffer_to_NetworkBuffer_harness.c b/test/cbmc/proofs/IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer/pxUDPPayloadBuffer_to_NetworkBuffer_harness.c
index 6d53978b..df6c879a 100644
--- a/test/cbmc/proofs/IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer/pxUDPPayloadBuffer_to_NetworkBuffer_harness.c
+++ b/test/cbmc/proofs/IPUtils/pxUDPPayloadBuffer_to_NetworkBuffer/pxUDPPayloadBuffer_to_NetworkBuffer_harness.c
@@ -85,7 +85,7 @@ void harness()
pvBuffer = &pxNetworkBuffer->pucEthernetBuffer[ ipconfigBUFFER_PADDING + sizeof( UDPPacket_t ) ];
}
- __CPROVER_assume( ( ( *pucIPType ) & 0xf0 == ipTYPE_IPv4 ) || ( ( *pucIPType ) & 0xf0 == ipTYPE_IPv6 ) );
+ __CPROVER_assume( ( ( ( *pucIPType ) & 0xf0 ) == ipTYPE_IPv4 ) || ( ( ( *pucIPType ) & 0xf0 ) == ipTYPE_IPv6 ) );
( void ) pxUDPPayloadBuffer_to_NetworkBuffer( pvBuffer );
}
- Lingua principale
- C
- Stelle
- 215
- Fork
- 222
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di FreeRTOS/FreeRTOS-Plus-TCP
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 63/100
FreeRTOS/FreeRTOS-Plus-TCP#1395 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
FreeRTOS/FreeRTOS-Plus-TCP#1388 ·
-
[BUG] PhyHandling incorrectly lists LAN8742A as having 19 PHYCRForse già presa @StitchLilo626 l’ha presa 41 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
FreeRTOS/FreeRTOS-Plus-TCP#1361 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
FreeRTOS/FreeRTOS-Plus-TCP#1392 · 1 commento ·
-
[BUG] DHCPv6 socket-allocation failure crashes with assertions disabled; CBMC stubs hide the pathApertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
FreeRTOS/FreeRTOS-Plus-TCP#1391 ·
Tutte le issue di FreeRTOS/FreeRTOS-Plus-TCP
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
qoretechnologies/qore#8222 ·
I maintainer di solito rispondono entro 1 giorno
-
c easy first-contributor first-contributors good first issue help wanted up-for-grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 96/100
fork-commit-merge/fork-commit-merge#8696 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
libsdl-org/SDL#16873 ·
I maintainer di solito rispondono entro 1 giorno