aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorDan Rosenberg <drosenberg@vsecurity.com>2011-05-23 08:17:35 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-24 01:13:12 -0400
commit71338aa7d050c86d8765cd36e46be514fb0ebbce (patch)
tree96bacb805b939c490145b31b4e2fb9e5cea79c5d /net/sctp
parent229de618ba6ff36e382b908b7637fe56c25ae9f1 (diff)
net: convert %p usage to %pK
The %pK format specifier is designed to hide exposed kernel pointers, specifically via /proc interfaces. Exposing these pointers provides an easy target for kernel write vulnerabilities, since they reveal the locations of writable structures containing easily triggerable function pointers. The behavior of %pK depends on the kptr_restrict sysctl. If kptr_restrict is set to 0, no deviation from the standard %p behavior occurs. If kptr_restrict is set to 1, the default, if the current user (intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG (currently in the LSM tree), kernel pointers using %pK are printed as 0's. If kptr_restrict is set to 2, kernel pointers using %pK are printed as 0's regardless of privileges. Replacing with 0's was chosen over the default "(null)", which cannot be parsed by userland %p, which expects "(nil)". The supporting code for kptr_restrict and %pK are currently in the -mm tree. This patch converts users of %p in net/ to %pK. Cases of printing pointers to the syslog are not covered, since this would eliminate useful information for postmortem debugging and the reading of the syslog is already optionally protected by the dmesg_restrict sysctl. Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com> Cc: James Morris <jmorris@namei.org> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Thomas Graf <tgraf@infradead.org> Cc: Eugene Teo <eugeneteo@kernel.org> Cc: Kees Cook <kees.cook@canonical.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: David S. Miller <davem@davemloft.net> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Eric Paris <eparis@parisplace.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/proc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 61aacfbbaa92..05a6ce214714 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -212,7 +212,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
212 sctp_for_each_hentry(epb, node, &head->chain) { 212 sctp_for_each_hentry(epb, node, &head->chain) {
213 ep = sctp_ep(epb); 213 ep = sctp_ep(epb);
214 sk = epb->sk; 214 sk = epb->sk;
215 seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, 215 seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
216 sctp_sk(sk)->type, sk->sk_state, hash, 216 sctp_sk(sk)->type, sk->sk_state, hash,
217 epb->bind_addr.port, 217 epb->bind_addr.port,
218 sock_i_uid(sk), sock_i_ino(sk)); 218 sock_i_uid(sk), sock_i_ino(sk));
@@ -316,7 +316,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
316 assoc = sctp_assoc(epb); 316 assoc = sctp_assoc(epb);
317 sk = epb->sk; 317 sk = epb->sk;
318 seq_printf(seq, 318 seq_printf(seq,
319 "%8p %8p %-3d %-3d %-2d %-4d " 319 "%8pK %8pK %-3d %-3d %-2d %-4d "
320 "%4d %8d %8d %7d %5lu %-5d %5d ", 320 "%4d %8d %8d %7d %5lu %-5d %5d ",
321 assoc, sk, sctp_sk(sk)->type, sk->sk_state, 321 assoc, sk, sctp_sk(sk)->type, sk->sk_state,
322 assoc->state, hash, 322 assoc->state, hash,