Skip to content

Commit

Permalink
route-table: Fix another UBsan warning about pointer type.
Browse files Browse the repository at this point in the history
The 'parse()' callback has a function type with 'void *change'
argument.  In all other cases it is used this way, except for
the route_table_parse().  That generates UBsan error:

  lib/netlink-notifier.c:190:25: runtime error: call to function
     route_table_parse through pointer to incorrect function type
     'int (*)(struct ofpbuf *, void *)'
  lib/route-table.c:227: note: route_table_parse defined here
    0 0x24d0 in nln_run lib/netlink-notifier.c:190:25
    1 0x7b39 in route_table_run lib/route-table.c:137:9
    2 0x5565 in netdev_vport_run lib/netdev-vport.c:364:5
    3 0xe978 in netdev_run lib/netdev.c:192:13
    4 0x2f25 in main vswitchd/ovs-vswitchd.c:132:9
    5 0xa1c9 in __libc_start_call_main
    6 0xa28a in __libc_start_main
    7 0xf004 in _start (vswitchd/ovs-vswitchd+0x726004)

Instead of turning off function sanitizer, let's just define
this callback as all the other parsing callbacks and cast the
void pointer inside the implementation.

This fixes system tests on Ubuntu 24.04 with UBsan.

Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
igsilya committed Aug 14, 2024
1 parent 5fb3bbd commit dd91419
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/route-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static bool route_table_valid = false;

static void route_table_reset(void);
static void route_table_handle_msg(const struct route_table_msg *);
static int route_table_parse(struct ofpbuf *, struct route_table_msg *);
static int route_table_parse(struct ofpbuf *, void *change);
static void route_table_change(const struct route_table_msg *, void *);
static void route_map_clear(void);

Expand All @@ -109,8 +109,7 @@ route_table_init(void)
ovs_assert(!route6_notifier);

ovs_router_init();
nln = nln_create(NETLINK_ROUTE, (nln_parse_func *) route_table_parse,
&rtmsg);
nln = nln_create(NETLINK_ROUTE, route_table_parse, &rtmsg);

route_notifier =
nln_notifier_create(nln, RTNLGRP_IPV4_ROUTE,
Expand Down Expand Up @@ -222,8 +221,9 @@ route_table_reset(void)
/* Return RTNLGRP_IPV4_ROUTE or RTNLGRP_IPV6_ROUTE on success, 0 on parse
* error. */
static int
route_table_parse(struct ofpbuf *buf, struct route_table_msg *change)
route_table_parse(struct ofpbuf *buf, void *change_)
{
struct route_table_msg *change = change_;
bool parsed, ipv4 = false;

static const struct nl_policy policy[] = {
Expand Down

0 comments on commit dd91419

Please sign in to comment.