summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2011-11-11 11:35:58 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-11-12 11:33:14 +0000
commita34dbfb03f472ad3e063d3b1d1e88f7ef8f88bf1 (patch)
treec3e5418493546663bf0b9ba00810621b9ec7b0d9 /arch
parent798681bf2127e60f16e9decc5e3a0b901f3ff3fe (diff)
downloadlinux-stable-a34dbfb03f472ad3e063d3b1d1e88f7ef8f88bf1.tar.gz
linux-stable-a34dbfb03f472ad3e063d3b1d1e88f7ef8f88bf1.tar.bz2
linux-stable-a34dbfb03f472ad3e063d3b1d1e88f7ef8f88bf1.zip
ARM: 7160/1: setup: avoid overflowing {elf,arch}_name from proc_info_list
setup_processor copies the arch_name and elf_name fields out of the selected proc_info_list into two fixed size buffers. Since the proc_info_list structure is defined in a proc_*.S assembly file, this can lead to subtle errors if the strings defined there are too long (for example, corrupting the machine ID). This patch uses snprintf instead of sprintf to ensure that these buffers are not overrun. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/setup.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 7e7977ab994f..3448a3f9cc8c 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -461,8 +461,10 @@ static void __init setup_processor(void)
cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
proc_arch[cpu_architecture()], cr_alignment);
- sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS);
- sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
+ snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c",
+ list->arch_name, ENDIANNESS);
+ snprintf(elf_platform, ELF_PLATFORM_SIZE, "%s%c",
+ list->elf_name, ENDIANNESS);
elf_hwcap = list->elf_hwcap;
#ifndef CONFIG_ARM_THUMB
elf_hwcap &= ~HWCAP_THUMB;