diff options
| author | Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> | 2026-01-24 09:50:50 +0000 |
|---|---|---|
| committer | Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> | 2026-01-24 09:50:50 +0000 |
| commit | 04f6b99947d2d2e0f6ec7703609c74083b5646e2 (patch) | |
| tree | 13c9c128de2d8014cb703520bc204b99ac3eceba | |
| parent | cd730bef74f9ecc2500fd5c01094dd5bfd34c246 (diff) | |
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
| -rw-r--r-- | sys/netlink/route/iface.c | 12 |
1 files 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 |
