An error occurred while fetching folder content.
sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output
Joe Perches authored
commit 2efc459d

 upstream.

Output defects can exist in sysfs content using sprintf and snprintf.

sprintf does not know the PAGE_SIZE maximum of the temporary buffer
used for outputting sysfs content and it's possible to overrun the
PAGE_SIZE buffer length.

Add a generic sysfs_emit function that knows that the size of the
temporary buffer and ensures that no overrun is done.

Add a generic sysfs_emit_at function that can be used in multiple
call situations that also ensures that no overrun is done.

Validate the output buffer argument to be page aligned.
Validate the offset len argument to be within the PAGE_SIZE buf.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Link: https://lore.kernel.org/r/884235202216d464d61ee975f7465332c86f76b2.1600285923.git.joe@perches.com

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
3d8e2128
Name Last commit Last update
..
ABI iio: improve IIO_CONCENTRATION channel type description
DocBook ata: make qc_prep return ata_completion_errors
EDID drm: Add 800x600 (SVGA) screen resolution to the built-in EDIDs
PCI Merge tag 'docs-for-linus' of git://git.lwn.net/linux-2.6
RCU Merge branches 'doc.2015.10.06a', 'percpu-rwsem.2015.10.06a' and 'torture.2015.10.06a' into HEAD
accounting tools/accounting/getdelays.c: fix netlink attribute length
acpi i2c: add ACPI support for I2C mux ports
aoe aoe: remove do-nothing NAME="%k" term from example udev rules
arm ARM: 8833/1: Ensure that NEON code always compiles with Clang
arm64 arm64: documentation: document tagged pointer stack constraints
auxdisplay Documentation: use subdir-y to avoid unnecessary built-in.o files
backlight backlight: lp855x_bl: support new LP8555 device
blackfin Docs: blackfin: Use new switch macro SAMPLE_IRQ_TIMER instead of IRQ_TIMER5
block null_blk: register as a LightNVM device
blockdev zram: update documentation
bus-devices ARM: OMAP2+: gpmc: generic timing calculation
cdrom doc: fix broken references
cgroups Merge tag 'docs-for-linus' of git://git.lwn.net/linux
cma cma: debug: document new debugfs interface
connector w1: optional bundling of netlink kernel replies
console TTY:console: update document console.txt
cpu-freq cpufreq: remove redundant CPUFREQ_INCOMPATIBLE notifier event
cpuidle cpuidle: remove cpuidle_unregister_governor()
cris CRIS: Update documentation
crypto KEYS: Merge the type-specific data with the payload data
development-process
device-mapper
devicetree
dmaengine
driver-model
dvb
early-userspace
extcon
fault-injection
fb
features
filesystems
firmware_class
fmc
fpga
frv
gpio
hid
hw-vuln
hwmon
i2c
ia64
ide
infiniband
input
ioctl
isdn
ja_JP
kbuild
kdump
ko_KR
laptops
leds
locking
m68k
memory-devices
metag
mic
mips
misc-devices
mmc
mn10300
mtd
namespaces
netlabel
networking
nfc
nios2
nvdimm
nvmem
parisc
pcmcia
phy
platform
power
powerpc
pps
prctl
pti
ptp
rapidio
s390
scheduler
scsi
security
serial
sh
sound
spi
sysctl
target
thermal
timers
tpm
trace