]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gas/ChangeLog
bpf: gas: avoid UB in pointer subtraction
authorJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 19 Feb 2024 19:39:48 +0000 (20:39 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 19 Feb 2024 19:48:17 +0000 (20:48 +0100)
commitb86b514aace19799ea141514e16296fb63a089b3
treed191bbb58f8dc18907d5014d7cd3689f68321672
parentb47cef7ca8a2fa55acdab367c87c1ea076aec4b2
bpf: gas: avoid UB in pointer subtraction

The PARSE_ERROR macro in md_assemble performs pointer subtraction.  If
parse_expression returns NULL then the later will be part of the
subtraction and therefore UB will be incurred.

This patch changes md_assemble to:
1. Accommodate all invocations to parse_expression to the fact it will
   return NULL when a parse error occurs.
2. Avoid UB in PARSE_ERROR.

Tested in bpf-unknown-none target / x86_64-linux-gnu host.

gas/ChangeLog:

* config/tc-bpf.c (md_assemble): Fix to take into account that
parse_expression can return NULL.
(PARSE_ERROR): Avoid passing invalid length to parse_error.
gas/ChangeLog
gas/config/tc-bpf.c