From: <rongqing.li@windriver.com>
To: <netdev@vger.kernel.org>, <selinux@tycho.nsa.gov>
Subject: [PATCH 5/5] Export the tcp sock's security context to proc.
Date: Fri, 5 Aug 2011 16:58:06 +0800 [thread overview]
Message-ID: <1312534686-4099-6-git-send-email-rongqing.li@windriver.com> (raw)
In-Reply-To: <1312534686-4099-1-git-send-email-rongqing.li@windriver.com>
From: Roy.Li <rongqing.li@windriver.com>
Export the tcp sock's security context to proc, since it maybe
different from the sock's owner process security context.
Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
net/ipv4/tcp_ipv4.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 955b8e6..98a85d6 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2478,13 +2478,16 @@ static void get_timewait4_sock(struct inet_timewait_sock *tw,
static int tcp4_seq_show(struct seq_file *seq, void *v)
{
struct tcp_iter_state *st;
- int len;
+ int len, sclen;
+ struct sock *s = NULL;
if (v == SEQ_START_TOKEN) {
- seq_printf(seq, "%-*s\n", TMPSZ - 1,
+ seq_printf(seq,
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout "
- "inode");
+ "inode %n", &len);
+ seq_printf(seq, "%-*s\n", TMPSZ - len - 1,
+ (selinux_is_enabled() ? " scontext" : ""));
goto out;
}
st = seq->private;
@@ -2493,15 +2496,19 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
case TCP_SEQ_STATE_LISTENING:
case TCP_SEQ_STATE_ESTABLISHED:
get_tcp4_sock(v, seq, st->num, &len);
+ s = v;
break;
case TCP_SEQ_STATE_OPENREQ:
get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid, &len);
+ s = st->syn_wait_sk;
break;
case TCP_SEQ_STATE_TIME_WAIT:
get_timewait4_sock(v, seq, st->num, &len);
break;
}
- seq_printf(seq, "%*s\n", TMPSZ - 1 - len, "");
+
+ sock_write_secctx(s, seq, &sclen);
+ seq_printf(seq, "%*s\n", TMPSZ + sclen - 1 - len, "");
out:
return 0;
}
--
1.7.1
prev parent reply other threads:[~2011-08-05 8:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 8:58 [PATCH 0/5] Export the sock's security context to proc rongqing.li
2011-08-05 8:58 ` [PATCH 1/5] Define the function to write sock's security context to seq_file rongqing.li
[not found] ` <1312534686-4099-2-git-send-email-rongqing.li-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2011-08-05 13:32 ` Stephen Smalley
2011-08-05 13:56 ` Stephen Smalley
2011-08-08 9:32 ` Rongqing Li
2011-08-08 13:25 ` Stephen Smalley
2011-08-05 8:58 ` [PATCH 2/5] Export the raw sock's security context to proc rongqing.li
2011-08-05 13:51 ` Stephen Smalley
2011-08-05 8:58 ` [PATCH 3/5] Export the udp " rongqing.li
2011-08-05 8:58 ` [PATCH 4/5] Export the unix " rongqing.li
2011-08-05 8:58 ` rongqing.li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312534686-4099-6-git-send-email-rongqing.li@windriver.com \
--to=rongqing.li@windriver.com \
--cc=netdev@vger.kernel.org \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).