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
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100301045206.GB496@home.unix.ba>
Date:	Mon, 1 Mar 2010 05:52:07 +0100
From:	Kenan Kalajdzic <kenan@...x.ba>
To:	netdev@...r.kernel.org
Subject: [RFC][PATCH] af_unix: Add peer inode to /proc/net/unix

Recently, I had a problem identifying local X-clients on a desktop system from 
within a userspace application.  So, I thought it may be a good idea to add the 
peer inode field to /proc/net/unix.

Instead of adding a new column to /proc/net/unix (which breaks important 
userspace programs, including 'netstat' and 'lsof'), we can make use of the 
fact that most client sockets (including these of X-clients) and anonymous 
sockets have an empty path field in /proc/net/unix, which can be used for 
specifying the peer inode.  In order to differentiate between a regular path 
and an entry which contains the inode number of the peer socket, I chose to 
simply add the 'peer=' prefix to the peer inode number.

Signed-off-by: Kenan Kalajdzic <kenan@...x.ba>
---
 net/unix/af_unix.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index f255119..e778428 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2157,7 +2157,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 		seq_puts(seq, "Num       RefCount Protocol Flags    Type St "
 			 "Inode Path\n");
 	else {
-		struct sock *s = v;
+		struct sock *s = v, *peer;
 		struct unix_sock *u = unix_sk(s);
 		unix_state_lock(s);
 
@@ -2186,6 +2186,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 			}
 			for ( ; i < len; i++)
 				seq_putc(seq, u->addr->name->sun_path[i]);
+		} else {
+			peer = unix_peer(s);
+			if (peer) {
+				unix_state_lock(peer);
+				seq_printf(seq, " peer=%lu", sock_i_ino(peer));
+				unix_state_unlock(peer);
+			}
 		}
 		unix_state_unlock(s);
 		seq_putc(seq, '\n');
-- 
1.6.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ