Skip to content

Commit

Permalink
netdev-dummy: Allocate dummy_packet_stream on cacheline boundary.
Browse files Browse the repository at this point in the history
UB Sanitizer report:

lib/netdev-dummy.c:197:15: runtime error: member access within
misaligned address 0x00000217a7f0 for type 'struct
dummy_packet_stream', which requires 64 byte alignment
              ^
    #0 dummy_packet_stream_init lib/netdev-dummy.c:197
    openvswitch#1 dummy_packet_stream_create lib/netdev-dummy.c:208
    openvswitch#2 dummy_packet_conn_set_config lib/netdev-dummy.c:436
    [...]

Signed-off-by: Mike Pattrick <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
mkp-rh authored and roseoriorden committed Jul 1, 2024
1 parent 0973b0f commit 39e34fb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ dummy_packet_stream_create(struct stream *stream)
{
struct dummy_packet_stream *s;

s = xzalloc(sizeof *s);
s = xzalloc_cacheline(sizeof *s);
dummy_packet_stream_init(s, stream);

return s;
Expand Down Expand Up @@ -350,7 +350,7 @@ dummy_packet_conn_close(struct dummy_packet_conn *conn)
pstream_close(pconn->pstream);
for (i = 0; i < pconn->n_streams; i++) {
dummy_packet_stream_close(pconn->streams[i]);
free(pconn->streams[i]);
free_cacheline(pconn->streams[i]);
}
free(pconn->streams);
pconn->pstream = NULL;
Expand All @@ -359,7 +359,7 @@ dummy_packet_conn_close(struct dummy_packet_conn *conn)

case ACTIVE:
dummy_packet_stream_close(rconn->rstream);
free(rconn->rstream);
free_cacheline(rconn->rstream);
rconn->rstream = NULL;
reconnect_destroy(rconn->reconnect);
rconn->reconnect = NULL;
Expand Down Expand Up @@ -469,7 +469,7 @@ dummy_pconn_run(struct netdev_dummy *dev)
pconn->streams = xrealloc(pconn->streams,
((pconn->n_streams + 1)
* sizeof s));
s = xmalloc(sizeof *s);
s = xmalloc_cacheline(sizeof *s);
pconn->streams[pconn->n_streams++] = s;
dummy_packet_stream_init(s, new_stream);
} else if (error != EAGAIN) {
Expand All @@ -489,7 +489,7 @@ dummy_pconn_run(struct netdev_dummy *dev)
stream_get_name(s->stream),
ovs_retval_to_string(error));
dummy_packet_stream_close(s);
free(s);
free_cacheline(s);
pconn->streams[i] = pconn->streams[--pconn->n_streams];
} else {
i++;
Expand Down

0 comments on commit 39e34fb

Please sign in to comment.