fix CVE-2022-48757.
Congyu Liu (1): net: fix information leakage in /proc/net/ptype
Dong Chenchen (1): net: fix kabi breakage in struct packet_type
include/linux/netdevice.h | 4 ++++ net/core/net-procfs.c | 3 ++- net/packet/af_packet.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
From: Congyu Liu liu3101@purdue.edu
stable inclusion from stable-v4.19.228 commit b67ad6170c0ea87391bb253f35d1f78857736e54 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IA72F3 CVE: CVE-2022-48757
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=...
--------------------------------
commit 47934e06b65637c88a762d9c98329ae6e3238888 upstream.
In one net namespace, after creating a packet socket without binding it to a device, users in other net namespaces can observe the new `packet_type` added by this packet socket by reading `/proc/net/ptype` file. This is minor information leakage as packet socket is namespace aware.
Add a net pointer in `packet_type` to keep the net namespace of of corresponding packet socket. In `ptype_seq_show`, this net pointer must be checked when it is not NULL.
Fixes: 2feb27dbe00c ("[NETNS]: Minor information leak via /proc/net/ptype file.") Signed-off-by: Congyu Liu liu3101@purdue.edu Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org Signed-off-by: Sasha Levin sashal@kernel.org Conflicts: include/linux/netdevice.h [kabi macro lead to conflicts] Signed-off-by: Dong Chenchen dongchenchen2@huawei.com --- include/linux/netdevice.h | 1 + net/core/net-procfs.c | 3 ++- net/packet/af_packet.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index dc8ca7c36adf..eedf0db8e048 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2503,6 +2503,7 @@ struct packet_type { struct net_device *); bool (*id_match)(struct packet_type *ptype, struct sock *sk); + struct net *af_packet_net; void *af_packet_priv; struct list_head list;
diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c index 63881f72ef71..6d4343e0092f 100644 --- a/net/core/net-procfs.c +++ b/net/core/net-procfs.c @@ -252,7 +252,8 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
if (v == SEQ_START_TOKEN) seq_puts(seq, "Type Device Function\n"); - else if (pt->dev == NULL || dev_net(pt->dev) == seq_file_net(seq)) { + else if ((!pt->af_packet_net || net_eq(pt->af_packet_net, seq_file_net(seq))) && + (!pt->dev || net_eq(dev_net(pt->dev), seq_file_net(seq)))) { if (pt->type == htons(ETH_P_ALL)) seq_puts(seq, "ALL "); else diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index a9f92dc90192..c64bcba21e47 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1720,6 +1720,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) match->prot_hook.dev = po->prot_hook.dev; match->prot_hook.func = packet_rcv_fanout; match->prot_hook.af_packet_priv = match; + match->prot_hook.af_packet_net = read_pnet(&match->net); match->prot_hook.id_match = match_fanout_group; list_add(&match->list, &fanout_list); } @@ -3306,6 +3307,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol, po->prot_hook.func = packet_rcv_spkt;
po->prot_hook.af_packet_priv = sk; + po->prot_hook.af_packet_net = sock_net(sk);
if (proto) { po->prot_hook.type = proto;
hulk inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IA72F3 CVE: CVE-2022-48757
--------------------------------
Fix kabi breakage in struct packet_type
Fixes: b67ad6170c0e("net: fix information leakage in /proc/net/ptype") Signed-off-by: Dong Chenchen dongchenchen2@huawei.com --- include/linux/netdevice.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index eedf0db8e048..be765a9915f3 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2503,11 +2503,14 @@ struct packet_type { struct net_device *); bool (*id_match)(struct packet_type *ptype, struct sock *sk); - struct net *af_packet_net; void *af_packet_priv; struct list_head list;
+#ifndef __GENKSYMS__ + struct net *af_packet_net; +#else KABI_RESERVE(1) +#endif KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4)
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/9723 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/N...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/9723 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/N...