arm64: cpuinfo: Missing NULL terminator in compat_hwcap_str
authorJulien Grall <julien.grall@arm.com>
Tue, 10 May 2016 14:40:31 +0000 (15:40 +0100)
committerWill Deacon <will.deacon@arm.com>
Wed, 11 May 2016 09:26:30 +0000 (10:26 +0100)
commitf228b494e56d949be8d8ea09d4f973d1979201bf
tree64d1e0e7b1aeb7a5abac45739265733728a85561
parent99aa036241ed4a08a71b627bb903b5d7c75d78c1
arm64: cpuinfo: Missing NULL terminator in compat_hwcap_str

The loop that browses the array compat_hwcap_str will stop when a NULL
is encountered, however NULL is missing at the end of array. This will
lead to overrun until a NULL is found somewhere in the following memory.
In reality, this works out because the compat_hwcap2_str array tends to
follow immediately in memory, and that *is* terminated correctly.
Furthermore, the unsigned int compat_elf_hwcap is checked before
printing each capability, so we end up doing the right thing because
the size of the two arrays is less than 32. Still, this is an obvious
mistake and should be fixed.

Note for backporting: commit 12d11817eaafa414 ("arm64: Move
/proc/cpuinfo handling code") moved this code in v4.4. Prior to that
commit, the same change should be made in arch/arm64/kernel/setup.c.

Fixes: 44b82b7700d0 "arm64: Fix up /proc/cpuinfo"
Cc: <stable@vger.kernel.org> # v3.19+ (but see note above prior to v4.4)
Signed-off-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/cpuinfo.c