From a30d903956d387b9c5e97f4b50d1166361fb33da Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Tue, 24 Oct 2017 10:24:57 +0200 Subject: [PATCH] silence l2fib_init() invalid read of size 2 found by address-sanitizer l2fib_make_key() casts and reads the input 6-Bytes mac_address as u64, therefore if the mac_address is declared with 6 Bytes only, address-sanitizer rightly triggers an invalid read on the last two Bytes. However, l2fib_make_key() does a 16 bits shift to discard those 2 values, therefore, this invalid read is of no consequence (and so can be silenced safely). Change-Id: I38646fe60073093d25cdf135185d4c96136d55d0 Signed-off-by: Gabriel Ganne --- src/vnet/l2/l2_fib.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vnet/l2/l2_fib.h b/src/vnet/l2/l2_fib.h index 6346826ee99..60c197f2a57 100644 --- a/src/vnet/l2/l2_fib.h +++ b/src/vnet/l2/l2_fib.h @@ -148,7 +148,12 @@ l2fib_compute_hash_bucket (l2fib_entry_key_t * key) return result % L2FIB_NUM_BUCKETS; } -always_inline u64 +/** + * make address sanitizer skip this: + * The 6-Bytes mac-address is cast into an 8-Bytes u64, with 2 additional Bytes. + * l2fib_make_key() does read those two Bytes but does not use them. + */ +always_inline u64 __attribute__ ((no_sanitize_address)) l2fib_make_key (u8 * mac_address, u16 bd_index) { u64 temp; -- 2.16.6