Bug 290050 - netlink: snl_init_writer() does not report the error flag appropriately
Summary: netlink: snl_init_writer() does not report the error flag appropriately
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.3-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-06 16:43 UTC by Bruno Silvestre
Modified: 2025-11-21 16:53 UTC (History)
1 user (show)

See Also:
glebius: mfc-stable15+
glebius: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Silvestre 2025-10-06 16:43:32 UTC
snl_init_writer() always set the error flag as 'false'.

Here is a fix suggestion:

--- netlink_snl_old.h    2025-10-02 14:17:36.369302000 -0300
+++ netlink_snl.h    2025-10-02 14:17:56.411429000 -0300
@@ -1021,20 +1021,20 @@
 };

 static inline void
 snl_init_writer(struct snl_state *ss, struct snl_writer *nw)
 {
+    nw->error = false;
     nw->size = SNL_WRITER_BUFFER_SIZE;
     nw->base = (char *)snl_allocz(ss, nw->size);
     if (nw->base == NULL) {
         nw->error = true;
         nw->size = 0;
     }

     nw->offset = 0;
     nw->hdr = NULL;
-    nw->error = false;
     nw->ss = ss;
 }

 static inline bool
 snl_realloc_msg_buffer(struct snl_writer *nw, size_t sz)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2025-10-06 19:46:01 UTC
^Triage: note inline patch, applying to sys/netlink/netlink_snl.h .
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-10-07 05:49:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=488718ff42346888243496c00cbeb42ba004171e

commit 488718ff42346888243496c00cbeb42ba004171e
Author:     Bruno Silvestre <bruno.silvestre@gmail.com>
AuthorDate: 2025-10-07 05:48:28 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-10-07 05:48:28 +0000

    netlink: in snl_init_writer() don't overwrite error in case of failure

    PR:     290050

 sys/netlink/netlink_snl.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-10-15 19:00:11 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=794299ac6876ecdf62e503d3fb05bd388f5c8be7

commit 794299ac6876ecdf62e503d3fb05bd388f5c8be7
Author:     Bruno Silvestre <bruno.silvestre@gmail.com>
AuthorDate: 2025-10-07 05:48:28 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-10-15 18:57:46 +0000

    netlink: in snl_init_writer() don't overwrite error in case of failure

    PR:     290050
    (cherry picked from commit 488718ff42346888243496c00cbeb42ba004171e)

 sys/netlink/netlink_snl.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2025-11-21 16:17:19 UTC
This commit needs to be MFCed to stable/14 as well.  Gleb, will you handle it?
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-11-21 16:52:57 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf95eabb5572368c80d72c151ebebca8cf6b2dbc

commit cf95eabb5572368c80d72c151ebebca8cf6b2dbc
Author:     Bruno Silvestre <bruno.silvestre@gmail.com>
AuthorDate: 2025-10-07 05:48:28 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-11-21 16:52:01 +0000

    netlink: in snl_init_writer() don't overwrite error in case of failure

    PR:     290050
    (cherry picked from commit 488718ff42346888243496c00cbeb42ba004171e)

 sys/netlink/netlink_snl.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)