lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <9a4228356eaa5c8db653c43467526a0dbd00ce30.1579102319.git.gnault@redhat.com> Date: Wed, 15 Jan 2020 16:36:27 +0100 From: Guillaume Nault <gnault@...hat.com> To: David Miller <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org> Cc: netdev@...r.kernel.org, Nicolas Dichtel <nicolas.dichtel@...nd.com> Subject: [PATCH net-next v2 1/2] netns: Parse *_PID and *_FD netlink attributes as signed integers These attributes represent signed values (file descriptors and PIDs). Make that clear in nla_policy. Signed-off-by: Guillaume Nault <gnault@...hat.com> --- net/core/net_namespace.c | 12 ++++++------ net/core/rtnetlink.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 6412c1fbfcb5..85c565571c1c 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -706,8 +706,8 @@ static struct pernet_operations __net_initdata net_ns_ops = { static const struct nla_policy rtnl_net_policy[NETNSA_MAX + 1] = { [NETNSA_NONE] = { .type = NLA_UNSPEC }, [NETNSA_NSID] = { .type = NLA_S32 }, - [NETNSA_PID] = { .type = NLA_U32 }, - [NETNSA_FD] = { .type = NLA_U32 }, + [NETNSA_PID] = { .type = NLA_S32 }, + [NETNSA_FD] = { .type = NLA_S32 }, [NETNSA_TARGET_NSID] = { .type = NLA_S32 }, }; @@ -731,10 +731,10 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh, nsid = nla_get_s32(tb[NETNSA_NSID]); if (tb[NETNSA_PID]) { - peer = get_net_ns_by_pid(nla_get_u32(tb[NETNSA_PID])); + peer = get_net_ns_by_pid(nla_get_s32(tb[NETNSA_PID])); nla = tb[NETNSA_PID]; } else if (tb[NETNSA_FD]) { - peer = get_net_ns_by_fd(nla_get_u32(tb[NETNSA_FD])); + peer = get_net_ns_by_fd(nla_get_s32(tb[NETNSA_FD])); nla = tb[NETNSA_FD]; } else { NL_SET_ERR_MSG(extack, "Peer netns reference is missing"); @@ -874,10 +874,10 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh, if (err < 0) return err; if (tb[NETNSA_PID]) { - peer = get_net_ns_by_pid(nla_get_u32(tb[NETNSA_PID])); + peer = get_net_ns_by_pid(nla_get_s32(tb[NETNSA_PID])); nla = tb[NETNSA_PID]; } else if (tb[NETNSA_FD]) { - peer = get_net_ns_by_fd(nla_get_u32(tb[NETNSA_FD])); + peer = get_net_ns_by_fd(nla_get_s32(tb[NETNSA_FD])); nla = tb[NETNSA_FD]; } else if (tb[NETNSA_NSID]) { peer = get_net_ns_by_id(net, nla_get_s32(tb[NETNSA_NSID])); diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 20bc406f3871..9b5419a7bd74 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1794,8 +1794,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_OPERSTATE] = { .type = NLA_U8 }, [IFLA_LINKMODE] = { .type = NLA_U8 }, [IFLA_LINKINFO] = { .type = NLA_NESTED }, - [IFLA_NET_NS_PID] = { .type = NLA_U32 }, - [IFLA_NET_NS_FD] = { .type = NLA_U32 }, + [IFLA_NET_NS_PID] = { .type = NLA_S32 }, + [IFLA_NET_NS_FD] = { .type = NLA_S32 }, /* IFLA_IFALIAS is a string, but policy is set to NLA_BINARY to * allow 0-length string (needed to remove an alias). */ @@ -2118,9 +2118,9 @@ struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]) * network namespace we are talking about. */ if (tb[IFLA_NET_NS_PID]) - net = get_net_ns_by_pid(nla_get_u32(tb[IFLA_NET_NS_PID])); + net = get_net_ns_by_pid(nla_get_s32(tb[IFLA_NET_NS_PID])); else if (tb[IFLA_NET_NS_FD]) - net = get_net_ns_by_fd(nla_get_u32(tb[IFLA_NET_NS_FD])); + net = get_net_ns_by_fd(nla_get_s32(tb[IFLA_NET_NS_FD])); else net = get_net(src_net); return net; -- 2.21.1
Powered by blists - more mailing lists