-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug
Description
Describe the bug
UB sanitizers finds misaligned reads/writes of struct in_addr when running in native_sim.
To Reproduce
- Build for native_sim with UB-sanitizer enabled
- Run the sim
- Network Ping
- ->UB sanitizer finds
misaligned accesses
Expected behavior
UB sanitizer should not find misaligned access under those circumstances.
Impact
- Either those are a real problem
- Or they are false positives, and the UB sanitizer can not be used to test an application in above circumstances to find actual problems
Logs and console output
Snippes tripping UBsan:
/**
* @brief Check if the IPv4 address is a loopback address (127.0.0.0/8).
*
* @param addr IPv4 address
*
* @return True if address is a loopback address, False otherwise.
*/
static inline bool net_ipv4_is_addr_loopback(struct in_addr *addr)
{
return addr->s4_addr[0] == 127U;
}/**
* @brief Compare two IPv4 addresses
*
* @param addr1 Pointer to IPv4 address.
* @param addr2 Pointer to IPv4 address.
*
* @return True if the addresses are the same, false otherwise.
*/
static inline bool net_ipv4_addr_cmp(const struct in_addr *addr1,
const struct in_addr *addr2)
{
return UNALIGNED_GET(&addr1->s_addr) == UNALIGNED_GET(&addr2->s_addr);
}/**
* @brief Check if the IPv4 address is a multicast address.
*
* @param addr IPv4 address
*
* @return True if address is multicast address, False otherwise.
*/
static inline bool net_ipv4_is_addr_mcast(const struct in_addr *addr)
{
return (ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xF0000000) == 0xE0000000;
}Environment (please complete the following information):
TBD
Additional context
TBD
Metadata
Metadata
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug