aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* fs: ext4: disable support for fallocate FALLOC_FL_PUNCH_HOLENick Desaulniers2016-11-071-0/+7
| | | | | | | Bug: 28760453 Change-Id: I019c2de559db9e4b95860ab852211b456d78c4ca Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> (cherry picked from commit eb0c8de6ef9ec336f88ee49c4c37226f03089e9c)
* ALSA: compress: fix an integer overflow checkDan Carpenter2016-11-071-1/+1
| | | | | | | | | | | | | | I previously added an integer overflow check here but looking at it now, it's still buggy. The bug happens in snd_compr_allocate_buffer(). We multiply ".fragments" and ".fragment_size" and that doesn't overflow but then we save it in an unsigned int so it truncates the high bits away and we allocate a smaller than expected size. Fixes: b35cc8225845 ('ALSA: compress_core: integer overflow in snd_compr_allocate_buffer()') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* Fix: Elevation of privilege vulnerability in kernel file systemMarcos Marado2016-11-073-2/+12
| | | | | | | | | | | | | | | An elevation of privilege vulnerability in the kernel file system could enable a local malicious application to execute arbitrary code within the context of the kernel. This issue is rated as High because it first requires compromising a privileged process. CVE References Severity CVE-2016-3802 A-28271368 High Issue: CYNGNOS-3281 Change-Id: I313dd754911251e7f01a0eb3710ee2565dcc4d1f (cherry picked from commit b24194f3ccdccd7c9efeb2a2c040e5f7e6fc4ba4)
* UPSTREAM: proc: actually make proc_fd_permission() thread-friendlyOleg Nesterov2016-11-071-3/+11
| | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 54708d2858e79a2bdda10bf8a20c80eb96c20613) The commit 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly") fixed the access to /proc/self/fd from sub-threads, but introduced another problem: a sub-thread can't access /proc/<tid>/fd/ or /proc/thread-self/fd if generic_permission() fails. Change proc_fd_permission() to check same_thread_group(pid_task(), current). Fixes: 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly") Reported-by: "Jin, Yihua" <yihua.jin@intel.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 26016905 Change-Id: I1894c78d0b13f0bde8cde84bd142ba67590dc0f1
* UPSTREAM: proc: make proc_fd_permission() thread-friendlyOleg Nesterov2016-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry pick from commit 96d0df79f2644fc823f26c06491e182d87a90c2a) proc_fd_permission() says "process can still access /proc/self/fd after it has executed a setuid()", but the "task_pid() = proc_pid() check only helps if the task is group leader, /proc/self points to /proc/<leader-pid>. Change this check to use task_tgid() so that the whole thread group can access its /proc/self/fd or /proc/<tid-of-sub-thread>/fd. Notes: - CLONE_THREAD does not require CLONE_FILES so task->files can differ, but I don't think this can lead to any security problem. And this matches same_thread_group() in __ptrace_may_access(). - /proc/self should probably point to /proc/<thread-tid>, but it is too late to change the rules. Perhaps it makes sense to add /proc/thread though. Test-case: void *tfunc(void *arg) { assert(opendir("/proc/self/fd")); return NULL; } int main(void) { pthread_t t; pthread_create(&t, NULL, tfunc, NULL); pthread_join(t, NULL); return 0; } fails if, say, this executable is not readable and suid_dumpable = 0. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 26016905 Change-Id: Ifdd6403a8fccd073122e89d3547c13ccc08f0dce
* defconfig: enable rgb cal nodeMoyster2016-11-071-0/+1
|
* Fix compilingfire8552016-11-071-1/+1
|
* mt6735: Add an RGB configuration sys attr driver for videox/corr10Diogo Ferreira2016-11-074-4/+111
| | | | | | | | | | | Adds the RGB configuration node which leverages the gamma subsystem to perform color correction. The new node takes rgb triplets that range from 0-2000 each, computes the gamma registers and dispatches them to the gamma correction subsystem. Change-Id: Iac9d3cbd4f423ccfffb8d665c29cfd251767a398
* arm64: kernel: perf: add cpu hotplug notifierLorenzo Pieralisi2016-11-072-1/+136
| | | | | | | | | | | | | | | When a CPU is taken offline, its PMU registers content is lost and needs to be reset on power up, since for most of the PMU registers content is UNKNOWN upon CPU reset. This patch implements a cpu hotplug notifier and hooks the reset call in the respective notifier callback function. Cc: Will Deacon <will.deacon at arm.com> Cc: Mark Rutland <mark.rutland at arm.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi at arm.com> Change-Id: I779158c4edb4e88f15d9bfebf6cf8af208a64259 Ticket: PORRIDGE-450
* Fix "arbitrary write-zero in mtkfb_ioctl() of Mediatek driver" issueyang-cy.chen2016-11-072-97/+2
| | | | | | | | | | | | | | | | Problem: lack of boundary check of user input parameter to cause arbitrary write-zero. Solution: remove unused code from driver Bug num:28175025,28175027 Signed-off-by: yang-cy.chen <yang-cy.chen@mediatek.com> (cherry picked from commit c811910368f393068b343ebdcb6d515dc33cd710) Change-Id: Ie59f5dd742b6b2295f63f76583a5cac2bdcf5d53 Ticket: PORRIDGE-398
* Fix "stack overflow in Mediatek Thermal driver" issueyang-cy.chen2016-11-071-0/+3
| | | | | | | | | | | | | | Problem: lack of boundary check of user input parameter before copy_from_user. Solution: Add boundary protection to prevent buffer overflow Bug num:28332766 Change-Id: I8536ae241070e59fbb15449bd3bca00d895e0b3f Signed-off-by: yang-cy.chen <yang-cy.chen@mediatek.com> Ticket: PORRIDGE-398
* Fix "Security Vulnerability - arbitrary address write ddp_drv.c" issueyang-cy.chen2016-11-074-52/+0
| | | | | | | | | | | | | | | | Problem: user input parameter without validation Solution: Remove legacy code to prevent buffer overflow Bug num:28402341 Signed-off-by: yang-cy.chen <yang-cy.chen@mediatek.com> (cherry picked from commit 76884c3948a5896c7d724a6852e9f8d1403fa9d0) Change-Id: I77467ae0c0652c7f44238b0320a1a6fef71c0d97 Ticket: PORRIDGE-398
* Fix "Security Vulnerability - kernel info leak ddp_drv.c" issueyang-cy.chen2016-11-071-1/+0
| | | | | | | | | | | | | | | | Problem: user input parameter without validation Solution: Remove legacy code to prevent buffer overflow Bug num:28402240 Signed-off-by: yang-cy.chen <yang-cy.chen@mediatek.com> (cherry picked from commit a8a18e931e3772d1bef10ec0b4611aa25831f0c0) Change-Id: I046968817190fc054225fb8c73f87574ec8db511 Ticket: PORRIDGE-398
* power: wakeup: partially revert some wakelock togglescm2016-11-071-5/+0
| | | | | This reverts msm_hsic_ws, since it's not used on MediaTek platform Makes no issue in having this here.. But let's keep this clean...
* turn off a bit of debugMoyster2016-11-071-8/+4
|
* disable KSM as the benefit in ram vs perf/battery might not be satisfyingMoyster2016-11-071-2/+2
|
* defconfig: enable config_jump_labelMoyster2016-11-071-1/+1
|
* defconfigMoyster2016-11-071-5/+2
|
* fs: push sync_filesystem() down to the file system's remount_fs()Theodore Ts'o2016-11-0743-2/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the no-op "mount -o mount /dev/xxx" operation when the file system is already mounted read-write causes an implied, unconditional syncfs(). This seems pretty stupid, and it's certainly documented or guaraunteed to do this, nor is it particularly useful, except in the case where the file system was mounted rw and is getting remounted read-only. However, it's possible that there might be some file systems that are actually depending on this behavior. In most file systems, it's probably fine to only call sync_filesystem() when transitioning from read-write to read-only, and there are some file systems where this is not needed at all (for example, for a pseudo-filesystem or something like romfs). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig <hch@infradead.org> Cc: Artem Bityutskiy <dedekind1@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Evgeniy Dushistov <dushistov@mail.ru> Cc: Jan Kara <jack@suse.cz> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Anders Larsen <al@alarsen.net> Cc: Phillip Lougher <phillip@squashfs.org.uk> Cc: Kees Cook <keescook@chromium.org> Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Cc: Petr Vandrovec <petr@vandrovec.name> Cc: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: codalist@coda.cs.cmu.edu Cc: linux-ext4@vger.kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net Cc: fuse-devel@lists.sourceforge.net Cc: cluster-devel@redhat.com Cc: linux-mtd@lists.infradead.org Cc: jfs-discussion@lists.sourceforge.net Cc: linux-nfs@vger.kernel.org Cc: linux-nilfs@vger.kernel.org Cc: linux-ntfs-dev@lists.sourceforge.net Cc: ocfs2-devel@oss.oracle.com Cc: reiserfs-devel@vger.kernel.org
* BACKPORT: arm64: cpu hotplug: ensure we mask out CPU_TASKS_FROZEN in notifiersWill Deacon2016-11-072-2/+2
| | | | | | | | | | | | | | | | | (cherry picked from commit e56d82a116176f7af9d642b560abbbd3a2b68013) We have a couple of CPU hotplug notifiers for resetting the CPU debug state to a sane value when a CPU comes online. This patch ensures that we mask out CPU_TASKS_FROZEN so that we don't miss any online events occuring due to suspend/resume. Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Pavel Labath <labath@google.com> Bug: 27189927 Change-Id: I72549149b9bf1f0d05cb17a1db98f9a342c580c0
* update MM defconfigMoyster2016-11-071-2/+2
|
* android: fiq_debugger: fix cut-off help messageColin Cross2016-11-071-1/+2
| | | | | | | | | fiq_debugger_printf has a 256 byte limit, which was causing the help lines for "kmsg" and "version" to be dropped. Split the long string into two calls. Change-Id: I55f9f030247cc16d13ae6236736311a5ef0c7aa0 Signed-off-by: Colin Cross <ccross@android.com>
* hand-pick: mediatek:remove unnecessary sido call flowMoyster2016-11-071-12/+0
| | | | | | | | | | | | | Problem: unnecessary sido call flow cause watchdog timeout Solution: remove unnecessary part that cause the issue Bug num:20566147 Change-Id: Iee332f38d339808f7245b4b0271b0f353f4081c4 Signed-off-by: yang-cy.chen <yang-cy.chen@mediatek.com>
* arm: crypto: Add optimized SHA-256/224Sami Tolvanen2016-11-077-1/+3979
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add Andy Polyakov's optimized assembly and NEON implementations for SHA-256/224. The sha256-armv4.pl script for generating the assembly code is from OpenSSL commit 51f8d095562f36cdaa6893597b5c609e943b0565. Compared to sha256-generic these implementations have the following tcrypt speed improvements on Motorola Nexus 6 (Snapdragon 805): bs b/u sha256-neon sha256-asm 16 16 x1.32 x1.19 64 16 x1.27 x1.15 64 64 x1.36 x1.20 256 16 x1.22 x1.11 256 64 x1.36 x1.19 256 256 x1.59 x1.23 1024 16 x1.21 x1.10 1024 256 x1.65 x1.23 1024 1024 x1.76 x1.25 2048 16 x1.21 x1.10 2048 256 x1.66 x1.23 2048 1024 x1.78 x1.25 2048 2048 x1.79 x1.25 4096 16 x1.20 x1.09 4096 256 x1.66 x1.23 4096 1024 x1.79 x1.26 4096 4096 x1.82 x1.26 8192 16 x1.20 x1.09 8192 256 x1.67 x1.23 8192 1024 x1.80 x1.26 8192 4096 x1.85 x1.28 8192 8192 x1.85 x1.27 Where bs refers to block size and b/u to bytes per update. Change-Id: I83938010007660f7f3f77f2946c8d22557e3a327 Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
* fix /proc/cpuinfoIliyan Malchev2016-10-031-1/+1
| | | | | | | | | | Use for_each_possible_cpu() instead of for_each_online_cpu() when enumerating the cores in /proc/cpuinfo. b/18108865 cpu info count is wrong Change-Id: Id1c81cb00b03b0f8d6a417037a4fd43359650c6a Signed-off-by: Iliyan Malchev <malchev@google.com>
* for w/e reasons, CONFIG_MAGIC_SYSRQ was defined, CVE-2015-6646Moyster2016-10-031-1/+1
|
* Use deadline as default iosched againMoyster2016-09-291-6/+6
|
* regen defconfigMoyster2016-09-281-0/+1
|
* net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfromAl Viro2016-09-281-0/+4
| | | | | | | | Bug: 28759139 Change-Id: I561a14b514d714838ef539a94275b117d7f475f4 Cc: stable@vger.kernel.org # v3.19 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
* Don't show empty tag stats for unprivileged uidsMohamad Ayyash2016-09-281-1/+1
| | | | | | | BUG: 27577101 BUG: 27532522 Change-Id: I890831a72e5ad4485fdf30e51a146712b18052ed Signed-off-by: Mohamad Ayyash <mkayyash@google.com
* power: wakeup: add wakelock togglesengstk2016-09-281-0/+29
| | | | Signed-off-by: engstk <eng.stk@sapo.pt>
* ARM: add documentation for finding start of physical memoryRussell King2016-09-281-1/+18
| | | | | | | | | | Occasionally, there's a question about the method we use to find the start of physical memory. Add some documentation so we don't have to keep repeating outselves on the mailing list. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Chet Kener <Cl3Kener@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* ARM: 8294/1: ATAG_DTB_COMPAT: remove the DT workspace's hardcoded 64KB sizeNicolas Pitre2016-09-281-9/+30
| | | | | | | | | | | | | | | | | | | | | | | There is currently a hardcoded limit of 64KB for the DTB to live in and be extended with ATAG info. Some DTBs have outgrown that limit: $ du -b arch/arm/boot/dts/omap3-n900.dtb 70212 arch/arm/boot/dts/omap3-n900.dtb Furthermore, the actual size passed to atags_to_fdt() included the stack size which is obviously wrong. The initial DTB size is known, so use it to size the allocated workspace with a 50% growth assumption and relocate the temporary stack above that. This is also clamped to 32KB min / 1MB max for robustness against bad DTB data. Reported-by: Pali Rohár <pali.rohar@gmail.com> Tested-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Chet Kener <Cl3Kener@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* ARM: compressed/head.S: remove s3c24xx special caseHeiko Stuebner2016-09-281-5/+0
| | | | | | | | | | | addruart from the generic debug macro is doing exactly the same using the common lowlevel uart definition, so there is no cause for this special casing for s3c24xx. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Chet Kener <Cl3Kener@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == u…Thomas Gleixner2016-09-281-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | …addr2 in futex_requeue(..., requeue_pi=1) If uaddr == uaddr2, then we have broken the rule of only requeueing from a non-pi futex to a pi futex with this call. If we attempt this, then dangling pointers may be left for rt_waiter resulting in an exploitable condition. This change brings futex_requeue() in line with futex_wait_requeue_pi() which performs the same check as per commit 6f7b0a2a5c0f ("futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi()") [ tglx: Compare the resulting keys as well, as uaddrs might be different depending on the mapping ] Fixes CVE-2014-3153. Change-Id: I3d40911aca262eaefc3852327fa12bec416cd27d Reported-by: Pinkie Pie Signed-off-by: Will Drewry <wad@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Darren Hart <dvhart@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* netfilter: IDLETIMER: fix invalid deference of timerJP Abgrall2016-09-281-1/+1
| | | | | | | | | "timer" was checked for null, but used later without being re-checked. Change-Id: Ib4d08cd49860c9f157d1cac556705ba85cd44f4e Reported-by: dan.carpenter@oracle.com Signed-off-by: JP Abgrall <jpa@google.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* mm, vmalloc: remove useless variable in vmap_blockJoonsoo Kim2016-09-281-2/+0
| | | | | | | | | | | | | | vbq in vmap_block isn't used. So remove it. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com> Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* mm, vmalloc: use well-defined find_last_bit() funcJoonsoo Kim2016-09-281-9/+6
| | | | | | | | | | | | | | | | | Our intention in here is to find last_bit within the region to flush. There is well-defined function, find_last_bit() for this purpose and its performance may be slightly better than current implementation. So change it. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com> Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com> Signed-off-by: engstk <eng.stk@sapo.pt>
* sched: remove migration notification from RT classSteve Muckle2016-09-281-19/+1
| | | | | | | | | | | | | | | | | | | | | Commit 88a7e37d265 (sched: provide per cpu-cgroup option to notify on migrations) added a notifier call when a task is moved to a different CPU. Unfortunately the two call sites in the RT sched class where this occurs happens with a runqueue lock held. This can result in a deadlock if the notifier call attempts to do something like wake up a task. Fortunately the benefit of 88a7e37d265 comes mainly from notifying on migration of non-RT tasks, so we can simply ignore the movements of RT tasks. CRs-Fixed: 491370 Change-Id: I8849d826bf1eeaf85a6f6ad872acb475247c5926 Signed-off-by: Steve Muckle <smuckle@codeaurora.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Conflicts: kernel/sched/rt.c
* sched: provide per cpu-cgroup option to notify on migrationsSteve Muckle2016-09-281-1/+19
| | | | | | | | | | | | | | | | | | | | | | | On systems where CPUs may run asynchronously, task migrations between CPUs running at grossly different speeds can cause problems. This change provides a mechanism to notify a subsystem in the kernel if a task in a particular cgroup migrates to a different CPU. Other subsystems (such as cpufreq) may then register for this notifier to take appropriate action when such a task is migrated. The cgroup attribute to set for this behavior is "notify_on_migrate" . Change-Id: Ie1868249e53ef901b89c837fdc33b0ad0c0a4590 Signed-off-by: Steve Muckle <smuckle@codeaurora.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Conflicts: kernel/sched/core.c kernel/sched/rt.c
* crypto: arm/aes update NEON AES module to latest OpenSSL versionArd Biesheuvel2016-09-282-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | [ Upstream commit 001eabfd54c0cbf9d7d16264ddc8cc0bee67e3ed ] This updates the bit sliced AES module to the latest version in the upstream OpenSSL repository (e620e5ae37bc). This is needed to fix a bug in the XTS decryption path, where data chunked in a certain way could trigger the ciphertext stealing code, which is not supposed to be active in the kernel build (The kernel implementation of XTS only supports round multiples of the AES block size of 16 bytes, whereas the conformant OpenSSL implementation of XTS supports inputs of arbitrary size by applying ciphertext stealing). This is fixed in the upstream version by adding the missing #ifndef XTS_CHAIN_TWEAK around the offending instructions. The upstream code also contains the change applied by Russell to build the code unconditionally, i.e., even if __LINUX_ARM_ARCH__ < 7, but implemented slightly differently. Cc: stable@vger.kernel.org Fixes: e4e7f10bfc40 ("ARM: add support for bit sliced AES using NEON instructions") Reported-by: Adrian Kotelba <adrian.kotelba@gmail.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* proc: introduce proc_mem_open()Oleg Nesterov2016-09-282-15/+23
| | | | | | | | | | | | | | | | Extract the mm_access() code from __mem_open() into the new helper, proc_mem_open(), the next patch will add another caller. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Conflicts: fs/proc/base.c
* mempolicy: fix show_numa_map() vs exec() + do_set_mempolicy() raceOleg Nesterov2016-09-281-24/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9e7814404b77 "hold task->mempolicy while numa_maps scans." fixed the race with the exiting task but this is not enough. The current code assumes that get_vma_policy(task) should either see task->mempolicy == NULL or it should be equal to ->task_mempolicy saved by hold_task_mempolicy(), so we can never race with __mpol_put(). But this can only work if we can't race with do_set_mempolicy(), and thus we can't race with another do_set_mempolicy() or do_exit() after that. However, do_set_mempolicy()->down_write(mmap_sem) can not prevent this race. This task can exec, change it's ->mm, and call do_set_mempolicy() after that; in this case they take 2 different locks. Change hold_task_mempolicy() to use get_task_policy(), it never returns NULL, and change show_numa_map() to use __get_vma_policy() or fall back to proc_priv->task_mempolicy. Note: this is the minimal fix, we will cleanup this code later. I think hold_task_mempolicy() and release_task_mempolicy() should die, we can move this logic into show_numa_map(). Or we can move get_task_policy() outside of ->mmap_sem and !CONFIG_NUMA code at least. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: David Rientjes <rientjes@google.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Hugh Dickins <hughd@google.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* proc/maps: make vm_is_stack() logic namespace-friendlyOleg Nesterov2016-09-284-24/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rename vm_is_stack() to task_of_stack() and change it to return "struct task_struct *" rather than the global (and thus wrong in general) pid_t. - Add the new pid_of_stack() helper which calls task_of_stack() and uses the right namespace to report the correct pid_t. Unfortunately we need to define this helper twice, in task_mmu.c and in task_nommu.c. perhaps it makes sense to add fs/proc/util.c and move at least pid_of_stack/task_of_stack there to avoid the code duplication. - Change show_map_vma() and show_numa_map() to use the new helper. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Greg Ungerer <gerg@uclinux.org> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Conflicts: fs/proc/task_nommu.c mm/util.c
* proc/maps: replace proc_maps_private->pid with "struct inode *inode"Oleg Nesterov2016-09-283-5/+5
| | | | | | | | | | | | | | | m_start() can use get_proc_task() instead, and "struct inode *" provides more potentially useful info, see the next changes. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Greg Ungerer <gerg@uclinux.org> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* fs/proc/task_mmu.c: update m->version in the main loop in m_start()Oleg Nesterov2016-09-281-1/+4
| | | | | | | | | | | | | | Change the main loop in m_start() to update m->version. Mostly for consistency, but this can help to avoid the same loop if the very 1st ->show() fails due to seq_overflow(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* fs/proc/task_mmu.c: reintroduce m->version logicOleg Nesterov2016-09-281-6/+19
| | | | | | | | | | | | | | | | | | | | | | | Add the "last_addr" optimization back. Like before, every ->show() method checks !seq_overflow() and sets m->version = vma->vm_start. However, it also checks that m_next_vma(vma) != NULL, otherwise it sets m->version = -1 for the lockless "EOF" fast-path in m_start(). m_start() can simply do find_vma() + m_next_vma() if last_addr is not zero, the code looks clear and simple and this case is clearly separated from "scan vmas" path. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Conflicts: fs/proc/task_mmu.c
* fs/proc/task_mmu.c: introduce m_next_vma() helperOleg Nesterov2016-09-281-5/+10
| | | | | | | | | | | | | Extract the tail_vma/vm_next calculation from m_next() into the new trivial helper, m_next_vma(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* fs/proc/task_mmu.c: simplify m_start() to make it readableOleg Nesterov2016-09-281-24/+10
| | | | | | | | | | | | | | | | | | | | | | Now that m->version is gone we can cleanup m_start(). In particular, - Remove the "unsigned long" typecast, m->index can't be negative or exceed ->map_count. But lets use "unsigned int pos" to make it clear that "pos < map_count" is safe. - Remove the unnecessary "vma != NULL" check in the main loop. It can't be NULL unless we have a vm bug. - This also means that "pos < map_count" case can simply return the valid vma and avoid "goto" and subsequent checks. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com>
* fs/proc/task_mmu.c: kill the suboptimal and confusing m->version logicOleg Nesterov2016-09-281-24/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | m_start() carefully documents, checks, and sets "m->version = -1" if we are going to return NULL. The only problem is that we will be never called again if m_start() returns NULL, so this is simply pointless and misleading. Otoh, ->show() methods m->version = 0 if vma == tail_vma and this is just wrong, we want -1 in this case. And in fact we also want -1 if ->vm_next == NULL and ->tail_vma == NULL. And it is not used consistently, the "scan vmas" loop in m_start() should update last_addr too. Finally, imo the whole "last_addr" logic in m_start() looks horrible. find_vma(last_addr) is called unconditionally even if we are not going to use the result. But the main problem is that this code participates in tail_vma-or-NULL mess, and this looks simply unfixable. Remove this optimization. We will add it back after some cleanups. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: W4TCH0UT <ateekujjawal@gmail.com> Signed-off-by: Anik1199 <anik9280@gmail.com> Conflicts: fs/proc/task_mmu.c Conflicts: fs/proc/task_mmu.c