From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Stosse <florian.stosse@harvester.fr>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH libmnl 5/5] callback: avoid signed overflow on INT_MIN error code
Date: Fri, 13 Nov 2026 12:05:08 +0100 [thread overview]
Message-ID: <avbu5GRDDig6xAZj@chamomile> (raw)
In-Reply-To: <20261106191841.1645-6-florian.stosse@harvester.fr>
On Fri, Nov 06, 2026 at 08:18:40PM +0100, Florian Stosse wrote:
> mnl_cb_error() negates the error field of an NLMSG_ERROR message to get
> a positive errno. For INT_MIN the negation overflows, which is undefined
> behaviour. No errno has that value, so report the message as malformed
> with EBADMSG instead.
>
> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
> Signed-off-by: Florian Stosse <florian.stosse@harvester.fr>
> ---
> src/callback.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/callback.c b/src/callback.c
> index 703ae80..660c90a 100644
> --- a/src/callback.c
> +++ b/src/callback.c
> @@ -8,6 +8,7 @@
> */
>
> #include <errno.h>
> +#include <limits.h>
> #include <libmnl/libmnl.h>
> #include "internal.h"
>
> @@ -25,7 +26,9 @@ static int mnl_cb_error(const struct nlmsghdr *nlh, void *data)
> return MNL_CB_ERROR;
> }
> /* Netlink subsystems returns the errno value with different signess */
> - if (err->error < 0)
> + if (err->error == INT_MIN)
> + errno = EBADMSG;
This is most likely processing an errno from the kernel.
IIRC, this is for historical reasons, I remember there was a very old
bug in netlink.
Probably this branch can just go away?
> + else if (err->error < 0)
> errno = -err->error;
> else
> errno = err->error;
> --
> 2.56.0.windows.4
>
next prev parent reply other threads:[~2026-11-13 11:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 19:18 [PATCH libmnl 0/5] libmnl: fix memory safety issues found by static analysis Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 1/5] nlmsg: fix overlapping copy in mnl_nlmsg_batch_reset() Florian Stosse
2026-11-10 0:51 ` Pablo Neira Ayuso
2026-11-06 19:18 ` [PATCH libmnl 2/5] attr: account for alignment padding in the *_check() builders Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 3/5] attr: do not wrap mnl_attr_get_payload_len() for nla_len < 4 Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 4/5] nlmsg: do not read past nlmsg_len in mnl_nlmsg_fprintf() Florian Stosse
2026-11-13 10:46 ` Pablo Neira Ayuso
2026-11-06 19:18 ` [PATCH libmnl 5/5] callback: avoid signed overflow on INT_MIN error code Florian Stosse
2026-11-13 11:05 ` Pablo Neira Ayuso [this message]
2026-11-13 11:47 ` [PATCH libmnl 0/5] libmnl: fix memory safety issues found by static analysis Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avbu5GRDDig6xAZj@chamomile \
--to=pablo@netfilter.org \
--cc=florian.stosse@harvester.fr \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.