android_kernel_samsung_a7y1.../drivers/misc
Daniel Axtens afea76c321 altera-stapl: altera_get_note: prevent write beyond end of 'key'
[ Upstream commit 3745488e9d599916a0b40d45d3f30e3d4720288e ]

altera_get_note is called from altera_init, where key is kzalloc(33).

When the allocation functions are annotated to allow the compiler to see
the sizes of objects, and with FORTIFY_SOURCE, we see:

In file included from drivers/misc/altera-stapl/altera.c:14:0:
In function ‘strlcpy’,
    inlined from ‘altera_init’ at drivers/misc/altera-stapl/altera.c:2189:5:
include/linux/string.h:378:4: error: call to ‘__write_overflow’ declared with attribute error: detected write beyond size of object passed as 1st parameter
    __write_overflow();
    ^~~~~~~~~~~~~~~~~~

That refers to this code in altera_get_note:

    if (key != NULL)
            strlcpy(key, &p[note_strings +
                            get_unaligned_be32(
                            &p[note_table + (8 * i)])],
                    length);

The error triggers because the length of 'key' is 33, but the copy
uses length supplied as the 'length' parameter, which is always
256. Split the size parameter into key_len and val_len, and use the
appropriate length depending on what is being copied.

Detected by compiler error, only compile-tested.

Cc: "Igor M. Liplianin" <liplianin@netup.ru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Link: https://lore.kernel.org/r/20200120074344.504-2-dja@axtens.net
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/202002251042.D898E67AC@keescook
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-07 14:14:00 +02:00
..
altera-stapl altera-stapl: altera_get_note: prevent write beyond end of 'key' 2020-04-07 14:14:00 +02:00
c2port A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cb710 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cxl A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
echo A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
eeprom A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
genwqe misc: genwqe: should return proper error value. 2020-04-07 12:29:28 +02:00
gnss_if A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ibmasm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lis3lv02d A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mcu_ipc A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mei mei: bus: prefix device names on bus with the bus name 2020-04-07 12:43:20 +02:00
mic mic: avoid statically declaring a 'struct device'. 2020-04-07 13:42:37 +02:00
modem_if A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
modem_v1 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
samsung A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-gru A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-xp misc: sgi-xp: Properly initialize buf in xpc_get_rsvd_page_pa 2020-04-07 13:42:03 +02:00
ti-st A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tui A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tzdev A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
usim_det A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vmw_vmci VMCI: Release resource if the work is already queued 2020-04-06 21:33:52 +02:00
ad525x_dpot-i2c.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot-spi.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ad525x_dpot.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
apds990x.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
apds9802als.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
arm-charlcd.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
atmel_tclib.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
atmel-ssc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bh1770glc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bh1780gli.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085-i2c.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085-spi.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bmp085.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cs5535-mfgpt.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dmverity_query.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ds1682.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dummy-irq.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
enclosure.c scsi: enclosure: Fix stale device oops with hot replug 2020-04-07 13:36:54 +02:00
exynos_ima.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fsa9480.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hmc6352.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hpilo.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hpilo.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ics932s401.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ioc4.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
isl29003.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
isl29020.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kgdbts.c misc: kgdbts: Fix restrict error 2020-04-07 12:29:25 +02:00
lattice-ecp3-config.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lkdtm.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
memory_state_time.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pch_phub.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
phantom.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pti.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
qcom-coincell.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
spear13xx_pcie_gadget.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sram.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ti_dac7512.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tifm_7xx1.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tifm_core.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tima_debug_log.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tima_debug_test.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tsl2550.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tzic64.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
uid_cputime.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
uid_sys_stats.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vexpress-syscfg.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vmw_balloon.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30