]> git.ipfire.org Git - thirdparty/linux.git/commit
iio: consumers: ensure read buffers for labels and ext_info are page aligned
authorMatteo Martelli <matteomartelli3@gmail.com>
Mon, 2 Dec 2024 15:11:07 +0000 (16:11 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 11 Dec 2024 19:20:49 +0000 (19:20 +0000)
commit22ccb0a1c57c436de899ccd3170d6d2ce7238836
tree8fd87290d2ec5b82c9866d69147aa6519589195a
parentca56951352ca26a15e9a62a7e682e56f1c01bf53
iio: consumers: ensure read buffers for labels and ext_info are page aligned

Attributes of iio providers are exposed via sysfs. Typically, providers
pass attribute values to the iio core, which handles formatting and
printing to sysfs. However, some attributes, such as labels or extended
info, are directly formatted and printed to sysfs by provider drivers
using sysfs_emit() and sysfs_emit_at(). These helpers assume the read
buffer, allocated by sysfs fop, is page-aligned. When these attributes
are accessed by consumer drivers, the read buffer is allocated by the
consumer and may not be page-aligned, leading to failures in the
provider's callback that utilizes sysfs_emit*.

Add a check to ensure that read buffers for labels and external info
attributes are page-aligned. Update the prototype documentation as well.

Signed-off-by: Matteo Martelli <matteomartelli3@gmail.com>
Link: https://patch.msgid.link/20241202-iio-kmalloc-align-v1-1-aa9568c03937@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/inkern.c
include/linux/iio/consumer.h