Sanitize two error conditions in netlink code
Phil Sutter
reviewercover Sanitize two error conditions in netlink code
While reviewing netlink deserialization code I noticed these two potential issues. Submitting them separately from other work as they are clear fixes (IMO).
Phil Sutter (2):
netlink: Avoid potential NULL-ptr deref parsing set elem expressions
netlink: Catch unknown types when deserializing objects
src/netlink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.49.0
Phil Sutter
reviewerPATCH 1/2 netlink: Avoid potential NULL-ptr deref parsing set elem expressions
Since netlink_parse_set_expr() may return NULL, the following deref must be guarded.
--- src/netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/netlink.c +2 -1
@@ -969,7 +969,8 @@ static int set_elem_parse_expressions(struct nftnl_expr *e, void *data)struct stmt *stmt; stmt =netlink_parse_set_expr (set, cache, e); -list_add_tail (&stmt->list, &setelem_parse_ctx->stmt_list); +if (stmt) +list_add_tail (&stmt->list, &setelem_parse_ctx->stmt_list);return 0 ; }
Signature · 1 line
2.49.0
Phil Sutter
reviewerPATCH 2/2 netlink: Catch unknown types when deserializing objects
In reply to Phil SutterPrint an error message and discard the object instead of returning it to the caller. At least when trying to print it, we would hit an assert() in obj_type_name() anyway.
--- src/netlink.c | 4 ++++ 1 file changed, 4 insertions(+)
src/netlink.c +4 -0
@@ -1802,6 +1802,10 @@ struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx, obj->synproxy.flags =nftnl_obj_get_u32 (nlo,NFTNL_OBJ_SYNPROXY_FLAGS );break ; +default : +netlink_io_error (ctx,NULL ,"Unknown object type %u" , type); +obj_free (obj); +return NULL ; } obj->type = type;
Signature · 1 line
2.49.0
Florian Westphal
maintainerQuoted 3 lines · Phil Sutter
While reviewing netlink deserialization code I noticed these two potential issues. Submitting them separately from other work as they are clear fixes (IMO).
Thanks Phil, please push them out.
Phil Sutter
reviewerQuoted 6 lines · Florian Westphal
Quoted 3 lines · Phil Sutter
While reviewing netlink deserialization code I noticed these two potential issues. Submitting them separately from other work as they are clear fixes (IMO).
Thanks Phil, please push them out.
Series applied, thanks!