diff mbox series

[ovs-dev,v3,02/14] dpif-netdev: Fix misaligned access.

Message ID 20220124141737.11777.23391.stgit@dceara.remote.csb
State Accepted
Commit 5a9bb85caf9aafe9a0be32671e0bc6909baefc32
Headers show
Series Fix UndefinedBehaviorSanitizer reported issues and enable it in CI. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Dumitru Ceara Jan. 24, 2022, 2:17 p.m. UTC
Remove the forced cache-line size alignment markers from
struct dp_netdev_pmd_thread and struct dp_netdev as discussed
at [0].  They don't seem to add any benefit and cause 64 byte
alignment requirements.

UB Sanitizer report:
  lib/dpif-netdev.c:6758:13: runtime error: member access within misaligned address 0x7f7f24d25010 for type 'struct dp_netdev_pmd_thread', which requires 64 byte alignment
  0x7f7f24d25010: note: pointer points here
   00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                ^
     #0 0x5fbfde in dp_netdev_configure_pmd lib/dpif-netdev.c:6758
     #1 0x5fbde9 in dp_netdev_set_nonpmd lib/dpif-netdev.c:6715
     #2 0x5d6fdd in create_dp_netdev lib/dpif-netdev.c:1769
     #3 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
     #4 0x61c83f in do_open lib/dpif.c:347
     [...]
  lib/dpif-netdev.c:1724:6: runtime error: member access within misaligned address 0x000002005eb0 for type 'struct dp_netdev', which requires 64 byte alignment
  0x000002005eb0: note: pointer points here
   00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                ^
      #0 0x5d6660 in create_dp_netdev lib/dpif-netdev.c:1724
      #1 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
      #2 0x61c846 in do_open lib/dpif.c:347
      #3 0x61ca9c in dpif_create lib/dpif.c:402
      #4 0x61cac9 in dpif_create_and_open lib/dpif.c:415
      #5 0x48f235 in open_dpif_backer ofproto/ofproto-dpif.c:776
      [...]

[0] https://mail.openvswitch.org/pipermail/ovs-dev/2021-December/390256.html

Suggested-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
 lib/dpif-netdev-private-thread.h |    2 +-
 lib/dpif-netdev.c                |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Valerio Feb. 3, 2022, 5:13 p.m. UTC | #1
Dumitru Ceara <dceara@redhat.com> writes:

> Remove the forced cache-line size alignment markers from
> struct dp_netdev_pmd_thread and struct dp_netdev as discussed
> at [0].  They don't seem to add any benefit and cause 64 byte
> alignment requirements.
>
> UB Sanitizer report:
>   lib/dpif-netdev.c:6758:13: runtime error: member access within misaligned address 0x7f7f24d25010 for type 'struct dp_netdev_pmd_thread', which requires 64 byte alignment
>   0x7f7f24d25010: note: pointer points here
>    00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
>                 ^
>      #0 0x5fbfde in dp_netdev_configure_pmd lib/dpif-netdev.c:6758
>      #1 0x5fbde9 in dp_netdev_set_nonpmd lib/dpif-netdev.c:6715
>      #2 0x5d6fdd in create_dp_netdev lib/dpif-netdev.c:1769
>      #3 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
>      #4 0x61c83f in do_open lib/dpif.c:347
>      [...]
>   lib/dpif-netdev.c:1724:6: runtime error: member access within misaligned address 0x000002005eb0 for type 'struct dp_netdev', which requires 64 byte alignment
>   0x000002005eb0: note: pointer points here
>    00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
>                 ^
>       #0 0x5d6660 in create_dp_netdev lib/dpif-netdev.c:1724
>       #1 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
>       #2 0x61c846 in do_open lib/dpif.c:347
>       #3 0x61ca9c in dpif_create lib/dpif.c:402
>       #4 0x61cac9 in dpif_create_and_open lib/dpif.c:415
>       #5 0x48f235 in open_dpif_backer ofproto/ofproto-dpif.c:776
>       [...]
>
> [0] https://mail.openvswitch.org/pipermail/ovs-dev/2021-December/390256.html
>
> Suggested-by: Ilya Maximets <i.maximets@ovn.org>
> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
> ---

Acked-by: Paolo Valerio <pvalerio@redhat.com>
Ilya Maximets Feb. 15, 2022, 1:13 p.m. UTC | #2
On 2/3/22 18:13, Paolo Valerio wrote:
> Dumitru Ceara <dceara@redhat.com> writes:
> 
>> Remove the forced cache-line size alignment markers from
>> struct dp_netdev_pmd_thread and struct dp_netdev as discussed
>> at [0].  They don't seem to add any benefit and cause 64 byte
>> alignment requirements.
>>
>> UB Sanitizer report:
>>   lib/dpif-netdev.c:6758:13: runtime error: member access within misaligned address 0x7f7f24d25010 for type 'struct dp_netdev_pmd_thread', which requires 64 byte alignment
>>   0x7f7f24d25010: note: pointer points here
>>    00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
>>                 ^
>>      #0 0x5fbfde in dp_netdev_configure_pmd lib/dpif-netdev.c:6758
>>      #1 0x5fbde9 in dp_netdev_set_nonpmd lib/dpif-netdev.c:6715
>>      #2 0x5d6fdd in create_dp_netdev lib/dpif-netdev.c:1769
>>      #3 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
>>      #4 0x61c83f in do_open lib/dpif.c:347
>>      [...]
>>   lib/dpif-netdev.c:1724:6: runtime error: member access within misaligned address 0x000002005eb0 for type 'struct dp_netdev', which requires 64 byte alignment
>>   0x000002005eb0: note: pointer points here
>>    00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
>>                 ^
>>       #0 0x5d6660 in create_dp_netdev lib/dpif-netdev.c:1724
>>       #1 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
>>       #2 0x61c846 in do_open lib/dpif.c:347
>>       #3 0x61ca9c in dpif_create lib/dpif.c:402
>>       #4 0x61cac9 in dpif_create_and_open lib/dpif.c:415
>>       #5 0x48f235 in open_dpif_backer ofproto/ofproto-dpif.c:776
>>       [...]
>>
>> [0] https://mail.openvswitch.org/pipermail/ovs-dev/2021-December/390256.html
>>
>> Suggested-by: Ilya Maximets <i.maximets@ovn.org>
>> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
>> ---
> 
> Acked-by: Paolo Valerio <pvalerio@redhat.com>
> 

Thanks!  Applied to master and 2.17.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h
index 020047ea68d4..4472b199d5c8 100644
--- a/lib/dpif-netdev-private-thread.h
+++ b/lib/dpif-netdev-private-thread.h
@@ -83,7 +83,7 @@  struct dp_netdev_pmd_thread {
      * instance for cpu core NON_PMD_CORE_ID can be accessed by multiple
      * threads, and thusly need to be protected by 'non_pmd_mutex'.  Every
      * other instance will only be accessed by its own pmd thread. */
-    OVS_ALIGNED_VAR(CACHE_LINE_SIZE) struct dfc_cache flow_cache;
+    struct dfc_cache flow_cache;
 
     /* Flow-Table and classifiers
      *
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 45435fdec9e5..0e8e8d28d478 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -273,7 +273,7 @@  struct dp_netdev {
     struct cmap meters OVS_GUARDED;
 
     /* Probability of EMC insertions is a factor of 'emc_insert_min'.*/
-    OVS_ALIGNED_VAR(CACHE_LINE_SIZE) atomic_uint32_t emc_insert_min;
+    atomic_uint32_t emc_insert_min;
     /* Enable collection of PMD performance metrics. */
     atomic_bool pmd_perf_metrics;
     /* Enable the SMC cache from ovsdb config */