linux/fs/proc
Dave Young 0b50a2d86d proc-vmcore: wrong data type casting fix
On i686 PAE enabled machine the contiguous physical area could be large
and it can cause trimming down variables in below calculation in
read_vmcore() and mmap_vmcore():

	tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);

That is, the types being used is like below on i686:
m->offset: unsigned long long int
m->size:   unsigned long long int
*fpos:     loff_t (long long int)
buflen:    size_t (unsigned int)

So casting (m->offset + m->size - *fpos) by size_t means truncating a
given value by 4GB.

Suppose (m->offset + m->size - *fpos) being truncated to 0, buflen >0
then we will get tsz = 0.  It is of course not an expected result.
Similarly we could also get other truncated values less than buflen.
Then the real size passed down is not correct any more.

If (m->offset + m->size - *fpos) is above 4GB, read_vmcore or
mmap_vmcore use the min_t result with truncated values being compared to
buflen.  Then, fpos proceeds with the wrong value so that we reach below
bugs:

1) read_vmcore will refuse to continue so makedumpfile fails.
2) mmap_vmcore will trigger BUG_ON() in remap_pfn_range().

Use unsigned long long in min_t instead so that the variables in are not
truncated.

Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Dave Young <dyoung@redhat.com>
Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jianyu Zhan <nasa4836@gmail.com>
Cc: Minfei Huang <mhuang@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-17 15:09:34 -07:00
..
Kconfig fs, proc: add help for CONFIG_PROC_CHILDREN 2015-07-17 16:39:52 -07:00
Makefile
array.c ptrace: use fsuid, fsgid, effective creds for fs access checks 2016-01-20 17:09:18 -08:00
base.c proc/base: make prompt shell start from new line after executing "cat /proc/$pid/wchan" 2016-03-17 15:09:34 -07:00
cmdline.c
consoles.c
cpuinfo.c
devices.c
fd.c proc: add a reschedule point in proc_readfd_common() 2016-01-09 02:56:10 -05:00
fd.h
generic.c proc: change proc_subdir_lock to a rwlock 2015-09-10 13:29:01 -07:00
inode.c kmemcg: account certain kmem allocations to memcg 2016-01-14 16:00:49 -08:00
internal.h proc: Allow creating permanently empty directories that serve as mount points 2015-07-01 10:36:41 -05:00
interrupts.c
kcore.c wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
kmsg.c
loadavg.c
meminfo.c mm/page_alloc.c: calculate 'available' memory in a separate function 2016-03-17 15:09:34 -07:00
namespaces.c ptrace: use fsuid, fsgid, effective creds for fs access checks 2016-01-20 17:09:18 -08:00
nommu.c vfs: add seq_file_path() helper 2015-06-23 18:01:07 -04:00
page.c /proc/kpageflags: return KPF_SLAB for slab tail pages 2016-03-17 15:09:34 -07:00
proc_net.c
proc_sysctl.c fs: Drop unlikely before IS_ERR(_OR_NULL) 2015-09-29 15:13:58 +02:00
proc_tty.c
root.c vfs: Commit to never having exectuables on proc and sysfs. 2015-07-10 10:39:25 -05:00
self.c wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
softirqs.c
stat.c
task_mmu.c proc: revert /proc/<pid>/maps [stack:TID] annotation 2016-02-03 08:28:43 -08:00
task_nommu.c proc: revert /proc/<pid>/maps [stack:TID] annotation 2016-02-03 08:28:43 -08:00
thread_self.c wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
uptime.c
version.c
vmcore.c proc-vmcore: wrong data type casting fix 2016-03-17 15:09:34 -07:00