]> git.karo-electronics.de Git - karo-tx-linux.git/commit
proc: fix ->f_pos overflows in first_tid()
authorOleg Nesterov <oleg@redhat.com>
Fri, 3 Jan 2014 03:10:29 +0000 (14:10 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 3 Jan 2014 03:10:29 +0000 (14:10 +1100)
commit3edb772cc2ffef63904c162a1317f87b39a3b63d
treee05291d003a22cb34124bbd05a4df1d0ffed2c38
parent985082bf4c98d8311bccf3ffe0770298acbce4ac
proc: fix ->f_pos overflows in first_tid()

1. proc_task_readdir()->first_tid() path truncates f_pos to int, this
   is wrong even on 64bit.

   We could check that f_pos < PID_MAX or even INT_MAX in
   proc_task_readdir(), but this patch simply checks the potential
   overflow in first_tid(), this check is nop on 64bit.  We do not care if
   it was negative and the new unsigned value is huge, all we need to
   ensure is that we never wrongly return !NULL.

2. Remove the 2nd "nr != 0" check before get_nr_threads(),
   nr_threads == 0 is not distinguishable from !pid_task() above.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Sameer Nanda <snanda@chromium.org>
Cc: Sergey Dyasly <dserrg@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/base.c