summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorCongyu Liu <liu3101@purdue.edu>2022-01-18 14:20:13 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-01 17:24:37 +0100
commite372ecd455b6ebc7720f52bf4b5f5d44d02f2092 (patch)
treea83f0ce8c1adf0a8635bfd6deded58485bb6e82b /net/core
parent20b7af413153f61c92c48938173ba587be4f6524 (diff)
net: fix information leakage in /proc/net/ptype
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-procfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
index 36347933ec3a..f1e005c8a54f 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