UBUNTU: SAUCE: (drop after 2.6.38) Convert net %p usage %pK
authorDan Rosenberg <drosenberg@vsecurity.com>
Thu, 23 Dec 2010 03:22:27 +0000 (22:22 -0500)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 28 Mar 2011 13:53:41 +0000 (06:53 -0700)
commit2ef24164964b38445781b0ff28c501aa7a225dec
treec8687cd0cd44293830bb2e548053be7b7c5fbcff
parent7ffd5b41b2feb3166b4c53a01a40c0288fa59554
UBUNTU: SAUCE: (drop after 2.6.38) Convert net %p usage %pK

This should be in the 2.6.39 kernel from the -mm tree

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>
Signed-off-by: Kees Cook <kees.cook@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
14 files changed:
net/atm/proc.c
net/can/bcm.c
net/ipv4/raw.c
net/ipv4/tcp_ipv4.c
net/ipv4/udp.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/key/af_key.c
net/netlink/af_netlink.c
net/packet/af_packet.c
net/phonet/socket.c
net/sctp/proc.c
net/unix/af_unix.c