Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2feb27db authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller
Browse files

[NETNS]: Minor information leak via /proc/net/ptype file.



This file displays the registered packet types, but some of them
(packet sockets creates such) can be bound to a net device and showing
them in a wrong namespace is not correct.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84c375af
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -2615,7 +2615,7 @@ static int ptype_seq_show(struct seq_file *seq, void *v)


	if (v == SEQ_START_TOKEN)
	if (v == SEQ_START_TOKEN)
		seq_puts(seq, "Type Device      Function\n");
		seq_puts(seq, "Type Device      Function\n");
	else {
	else if (pt->dev == NULL || pt->dev->nd_net == seq_file_net(seq)) {
		if (pt->type == htons(ETH_P_ALL))
		if (pt->type == htons(ETH_P_ALL))
			seq_puts(seq, "ALL ");
			seq_puts(seq, "ALL ");
		else
		else
@@ -2639,7 +2639,8 @@ static const struct seq_operations ptype_seq_ops = {


static int ptype_seq_open(struct inode *inode, struct file *file)
static int ptype_seq_open(struct inode *inode, struct file *file)
{
{
	return seq_open(file, &ptype_seq_ops);
	return seq_open_net(inode, file, &ptype_seq_ops,
			sizeof(struct seq_net_private));
}
}


static const struct file_operations ptype_seq_fops = {
static const struct file_operations ptype_seq_fops = {
@@ -2647,7 +2648,7 @@ static const struct file_operations ptype_seq_fops = {
	.open    = ptype_seq_open,
	.open    = ptype_seq_open,
	.read    = seq_read,
	.read    = seq_read,
	.llseek  = seq_lseek,
	.llseek  = seq_lseek,
	.release = seq_release,
	.release = seq_release_net,
};
};