aboutsummaryrefslogtreecommitdiff
path: root/net/lapb/lapb_iface.c
diff options
context:
space:
mode:
authorMathias Krause <[email protected]>2015-11-06 16:30:38 -0800
committerLinus Torvalds <[email protected]>2015-11-06 17:50:42 -0800
commit3824657c522f19f85a76bd932821174a5557a382 (patch)
treefeaf1871e0c40c88e26c10cf1f17774a1da98b23 /net/lapb/lapb_iface.c
parentd7ec9a05d6defda8432da574a2a888eed6fc29f6 (diff)
printk: prevent userland from spoofing kernel messages
The following statement of ABI/testing/dev-kmsg is not quite right: It is not possible to inject messages from userspace with the facility number LOG_KERN (0), to make sure that the origin of the messages can always be reliably determined. Userland actually can inject messages with a facility of 0 by abusing the fact that the facility is stored in a u8 data type. By using a facility which is a multiple of 256 the assignment of msg->facility in log_store() implicitly truncates it to 0, i.e. LOG_KERN, allowing users of /dev/kmsg to spoof kernel messages as shown below: The following call... # printf '<%d>Kernel panic - not syncing: beer empty\n' 0 >/dev/kmsg ...leads to the following log entry (dmesg -x | tail -n 1): user :emerg : [ 66.137758] Kernel panic - not syncing: beer empty However, this call... # printf '<%d>Kernel panic - not syncing: beer empty\n' 0x800 >/dev/kmsg ...leads to the slightly different log entry (note the kernel facility): kern :emerg : [ 74.177343] Kernel panic - not syncing: beer empty Fix that by limiting the user provided facility to 8 bit right from the beginning and catch the truncation early. Fixes: 7ff9554bb578 ("printk: convert byte-buffer to variable-length...") Signed-off-by: Mathias Krause <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Alex Elder <[email protected]> Cc: Joe Perches <[email protected]> Cc: Kay Sievers <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'net/lapb/lapb_iface.c')
0 files changed, 0 insertions, 0 deletions