The USB code and some other places raise false positives when a NULL
pointer is passed to an inlined function along with a separate length
and the compiler can't determine that the separate length of 0
prevents the use of the NULL pointer.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 48644 Build 45530: arc lint + arc unit
Event Timeline
Comment Actions
What are the functions? Generally, passing a null pointer to a standard string function invokes UB regardless of the passed size, and some compilers do make optimizations based on this assumption.
Comment Actions
I built with gcc12 in Cirrus-CI and get a few Wnonnull warnings. D39947 is a fix for one of them, PR271227 is a bug report for one of them, and the last one is:
In file included from /tmp/cirrus-ci-build/sys/sys/bus.h:169, from /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:37: In function 'ccp_do_xts', inlined from 'ccp_do_blkcipher' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1614:11, inlined from 'ccp_authenc' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1707:11: /tmp/cirrus-ci-build/sys/sys/systm.h:266:33: warning: argument 2 null where non-null expected [-Wnonnull] 266 | #define memcpy(to, from, len) __builtin_memcpy((to), (from), (len)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1433:25: note: in expansion of macro 'memcpy' 1433 | memcpy(&qp->completions_ring[qp->cq_tail], cctx, | ^~~~~~ /tmp/cirrus-ci-build/sys/sys/systm.h:266:33: note: in a call to built-in function '__builtin_memcpy' 266 | #define memcpy(to, from, len) __builtin_memcpy((to), (from), (len)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1433:25: note: in expansion of macro 'memcpy' 1433 | memcpy(&qp->completions_ring[qp->cq_tail], cctx, | ^~~~~~ In function 'ccp_do_blkcipher', inlined from 'ccp_authenc' at /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1707:11: /tmp/cirrus-ci-build/sys/sys/systm.h:266:33: warning: argument 2 null where non-null expected [-Wnonnull] 266 | #define memcpy(to, from, len) __builtin_memcpy((to), (from), (len)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1631:25: note: in expansion of macro 'memcpy' 1631 | memcpy(&qp->completions_ring[qp->cq_tail], cctx, | ^~~~~~ /tmp/cirrus-ci-build/sys/sys/systm.h:266:33: note: in a call to built-in function '__builtin_memcpy' 266 | #define memcpy(to, from, len) __builtin_memcpy((to), (from), (len)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/cirrus-ci-build/sys/crypto/ccp/ccp_hardware.c:1631:25: note: in expansion of macro 'memcpy' 1631 | memcpy(&qp->completions_ring[qp->cq_tail], cctx, | ^~~~~~