The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=04f6b99947d2d2e0f6ec7703609c74083b5646e2
commit 04f6b99947d2d2e0f6ec7703609c74083b5646e2 Author: Pouria Mousavizadeh Tehrani <[email protected]> AuthorDate: 2026-01-24 09:50:50 +0000 Commit: Pouria Mousavizadeh Tehrani <[email protected]> CommitDate: 2026-01-24 09:50:50 +0000 netlink: use caller's credentials in rtnl_handle_newlink Make sure rtnl_handle_newlink sets the caller's credential during calls to ifc_create_ifp_nl and ifc_modify_ifp_nl Reviewed by: glebius, melifaro Approved by: glebius (mentor) Differential Revision: https://reviews.freebsd.org/D54109 --- sys/netlink/route/iface.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c index e9c053015fad..2ae43e22f7ed 100644 --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -675,6 +675,8 @@ static int rtnl_handle_newlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *npt) { struct nlattr_bmask bm; + struct thread *td = curthread; + struct ucred *cred; int error; struct nl_parsed_link attrs = {}; @@ -683,10 +685,16 @@ rtnl_handle_newlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *n return (error); nl_get_attrs_bmask_nlmsg(hdr, &ifmsg_parser, &bm); + /* XXX: temporary patch until the D39180 review lands */ + cred = td->td_ucred; + td->td_ucred = nlp_get_cred(nlp); if (hdr->nlmsg_flags & NLM_F_CREATE) - return (create_link(hdr, &attrs, &bm, nlp, npt)); + error = create_link(hdr, &attrs, &bm, nlp, npt); else - return (modify_link(hdr, &attrs, &bm, nlp, npt)); + error = modify_link(hdr, &attrs, &bm, nlp, npt); + td->td_ucred = cred; + + return (error); } static void
