]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
lib/strscpy: Shut up KASAN false-positives in strscpy()
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Thu, 1 Feb 2018 18:00:50 +0000 (21:00 +0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit0f880138d6fee07546d2db2c477afb0813eec990
treec10c6b760546ae4563d8bc0e66acb3e225bc421f
parent25ea5fd2ee9defdd3964a172ea25164ca4056955
lib/strscpy: Shut up KASAN false-positives in strscpy()

BugLink: https://bugs.launchpad.net/bugs/1839036
[ Upstream commit 1a3241ff10d038ecd096d03380327f2a0b5840a6 ]

strscpy() performs the word-at-a-time optimistic reads.  So it may may
access the memory past the end of the object, which is perfectly fine
since strscpy() doesn't use that (past-the-end) data and makes sure the
optimistic read won't cross a page boundary.

Use new read_word_at_a_time() to shut up the KASAN.

Note that this potentially could hide some bugs.  In example bellow,
stscpy() will copy more than we should (1-3 extra uninitialized bytes):

        char dst[8];
        char *src;

        src = kmalloc(5, GFP_KERNEL);
        memset(src, 0xff, 5);
        strscpy(dst, src, 8);

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
lib/string.c