diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-06 21:10:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-06 21:10:04 -0500 |
commit | 1d87b0d388c65feb890f1e0aa832338a33d0760f (patch) | |
tree | ca1980ce84f2fb1bc7952738e32f9657dc4d0154 /fs/binfmt_elf.c | |
parent | d4cf109f05ff04c6f5065c3e14165ef01a57dd53 (diff) | |
parent | 92dc07b1f988e8c237a38e23be660b9b8533e6fd (diff) |
Merge branch 'to-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland
* 'to-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland:
elf core dump: fix get_user use
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index e3ff2b9e602f..33b7235f853b 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1208,9 +1208,11 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma, | |||
1208 | * check for an ELF header. If we find one, dump the first page to | 1208 | * check for an ELF header. If we find one, dump the first page to |
1209 | * aid in determining what was mapped here. | 1209 | * aid in determining what was mapped here. |
1210 | */ | 1210 | */ |
1211 | if (FILTER(ELF_HEADERS) && vma->vm_file != NULL && vma->vm_pgoff == 0) { | 1211 | if (FILTER(ELF_HEADERS) && |
1212 | vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) { | ||
1212 | u32 __user *header = (u32 __user *) vma->vm_start; | 1213 | u32 __user *header = (u32 __user *) vma->vm_start; |
1213 | u32 word; | 1214 | u32 word; |
1215 | mm_segment_t fs = get_fs(); | ||
1214 | /* | 1216 | /* |
1215 | * Doing it this way gets the constant folded by GCC. | 1217 | * Doing it this way gets the constant folded by GCC. |
1216 | */ | 1218 | */ |
@@ -1223,7 +1225,15 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma, | |||
1223 | magic.elfmag[EI_MAG1] = ELFMAG1; | 1225 | magic.elfmag[EI_MAG1] = ELFMAG1; |
1224 | magic.elfmag[EI_MAG2] = ELFMAG2; | 1226 | magic.elfmag[EI_MAG2] = ELFMAG2; |
1225 | magic.elfmag[EI_MAG3] = ELFMAG3; | 1227 | magic.elfmag[EI_MAG3] = ELFMAG3; |
1226 | if (get_user(word, header) == 0 && word == magic.cmp) | 1228 | /* |
1229 | * Switch to the user "segment" for get_user(), | ||
1230 | * then put back what elf_core_dump() had in place. | ||
1231 | */ | ||
1232 | set_fs(USER_DS); | ||
1233 | if (unlikely(get_user(word, header))) | ||
1234 | word = 0; | ||
1235 | set_fs(fs); | ||
1236 | if (word == magic.cmp) | ||
1227 | return PAGE_SIZE; | 1237 | return PAGE_SIZE; |
1228 | } | 1238 | } |
1229 | 1239 | ||