Re: [Devel] [PATCH rh7] cgroup: do not virtualize output of cgroup_path

2015-08-24 Thread Cyrill Gorcunov
On Mon, Aug 24, 2015 at 02:58:07PM +0300, Vladimir Davydov wrote: > > As you wish. Thank you! > --- > From: Vladimir Davydov > Subject: [PATCH rh7] cgroup: do not virtualize output of cgroup_path > > When cgroup_path() is called from inside a container, its output is > "virtualized", i.e. cgro

Re: [Devel] [PATCH rh7] cgroup: do not virtualize output of cgroup_path

2015-08-24 Thread Vladimir Davydov
On Mon, Aug 24, 2015 at 02:46:31PM +0300, Cyrill Gorcunov wrote: ... > > diff --git a/kernel/cgroup.c b/kernel/cgroup.c > > index aa3546d93f88..0ff3b5254b5f 100644 > > --- a/kernel/cgroup.c > > +++ b/kernel/cgroup.c > > @@ -1804,11 +1804,13 @@ static struct kobject *cgroup_kobj; > > * inode's i_m

Re: [Devel] [PATCH rh7] cgroup: do not virtualize output of cgroup_path

2015-08-24 Thread Cyrill Gorcunov
On Mon, Aug 24, 2015 at 01:04:35PM +0300, Vladimir Davydov wrote: > When cgroup_path() is called from inside a container, its output is > "virtualized", i.e. cgroup /CTID/A/B is reported as /A/B. This was done > for userspace tools to not get confused by the output of some proc files > (namely, /pr

[Devel] [RFC rh7 v5] ve/tty: vt -- Implement per VE support for console and terminals

2015-08-24 Thread Cyrill Gorcunov
Previously in commit 8674c044330fad1458bd59b02f9037fb97e8b7af stubs for virtual terminals have been added, they support writes from kernel side which simply drops into the void. In the patch the code has been moved from kernel/ve/console.c to drivers/tty/pty.c to reuse a couple of pty helpers. No

[Devel] [PATCH 39/39] x86/kasan: Add message about KASAN being initialized

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 8515522949951d81fe2d06c0a3292f171f2b8ec4 upstream. Print informational message to tell user that kernel runs with KASAN enabled. Add a "kasan: " prefix to all messages in kasan_init_64.c. Signed-off-by: Andrey Ryabinin Cc: Alexander Popov Cc: Alexander Potapenko

Re: [Devel] [RFC rh7 v4] ve/tty: vt -- Implement per VE support for console and terminals

2015-08-24 Thread Vladimir Davydov
On Fri, Aug 21, 2015 at 06:22:18PM +0300, Cyrill Gorcunov wrote: > >> +static envid_t vtty_get_context(void) > >> +{ > >> + BUILD_BUG_ON(sizeof(current_veid) < sizeof(envid_t)); > >> + lockdep_assert_held(&tty_mutex); > >> + > >> + if (likely(current_veid == VTTY_USE_EXEC_VEID)) > > > > Nit: l

[Devel] [PATCH 38/39] x86/kasan: Fix boot crash on AMD processors

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit d4f86beacc21d538dc41e1fc75a22e084f547edf upstream. While populating zero shadow wrong bits in upper level page tables used. __PAGE_KERNEL_RO that was used for pgd/pud/pmd has _PAGE_BIT_GLOBAL set. Global bit is present only in the lowest level of the page translation

[Devel] [PATCH 37/39] x86/kasan: Flush TLBs after switching CR3

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 241d2c54c62fa0939fc9a9512b48ac3434e90a89 upstream. load_cr3() doesn't cause tlb_flush if PGE enabled. This may cause tons of false positive reports spamming the kernel to death. To fix this __flush_tlb_all() should be called explicitly after CR3 changed. Signed-of

[Devel] [PATCH 36/39] x86/kasan: Fix KASAN shadow region page tables

2015-08-24 Thread Andrey Ryabinin
From: Alexander Popov commit 5d5aa3cfca5cf74cd928daf3674642e6004328d1 upstream. Currently KASAN shadow region page tables created without respect of physical offset (phys_base). This causes kernel halt when phys_base is not zero. So let's initialize KASAN shadow region page tables in kasan_earl

[Devel] [PATCH 35/39] x86/init: Clear 'init_level4_pgt' earlier

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit d0f77d4d04b222a817925d33ba3589b190bfa863 upstream. Currently x86_64_start_kernel() has two KASAN related function calls. The first call maps shadow to early_level4_pgt, the second maps shadow to init_level4_pgt. If we move clear_page(init_level4_pgt) earlier, we cou

[Devel] [PATCH 34/39] kasan: Makefile: shut up warnings if CONFIG_COMPILE_TEST=y

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 6e54abac1b8e0b7febffdbad37b605daef1cfcff upstream. It might be annoying to constantly see this: scripts/Makefile.kasan:16: Cannot use CONFIG_KASAN: -fsanitize=kernel-address is not supported by compiler while performing allmodconfig/allyesconfig build test

[Devel] [PATCH 33/39] mm/mempool.c: kasan: poison mempool elements

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 923936157b158f36bd6a3d86496dce82b1a957de upstream. Mempools keep allocated objects in reserved for situations when ordinary allocation may not be possible to satisfy. These objects shouldn't be accessed before they leave the pool. This patch poison elements when ge

[Devel] [PATCH 32/39] mm, mempool: poison elements backed by slab allocator

2015-08-24 Thread Andrey Ryabinin
From: David Rientjes commit bdfedb76f4f5aa5e37380e3b71adee4a39f30fc6 upstream. Mempools keep elements in a reserved pool for contexts in which allocation may not be possible. When an element is allocated from the reserved pool, its memory contents is the same as when it was added to the reserve

[Devel] [PATCH 31/39] kasan, module: move MODULE_ALIGN macro into

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit d3733e5c98e952d419e77fa721912f09d15a2806 upstream. include/linux/moduleloader.h is more suitable place for this macro. Also change alignment to PAGE_SIZE for CONFIG_KASAN=n as such alignment already assumed in several places. Signed-off-by: Andrey Ryabinin Cc: Dmit

[Devel] [PATCH 30/39] kasan, module, vmalloc: rework shadow allocation for modules

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit a5af5aa8b67dfdba36c853b70564fd2dfe73d478 upstream. Current approach in handling shadow memory for modules is broken. Shadow memory could be freed only after memory shadow corresponds it is no longer used. vfree() called from interrupt context could use memory its f

[Devel] [PATCH 29/39] kasan: enable instrumentation of global variables

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit bebf56a1b176c2e1c9efe44e7e6915532cc682cf upstream. This feature let us to detect accesses out of bounds of global variables. This will work as for globals in kernel image, so for globals in modules. Currently this won't work for symbols in user-specified sections (e.

[Devel] [PATCH 28/39] module: fix types of device tables aliases

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 6301939d97d079f0d3dbe71e750f4daf5d39fc33 upstream. MODULE_DEVICE_TABLE() macro used to create aliases to device tables. Normally alias should have the same type as aliased symbol. Device tables are arrays, so they have 'struct type##_device_id[x]' types. Alias creat

[Devel] [PATCH 27/39] kernel: add support for .init_array.* constructors

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 9ddf82521c86ae07af79dbe5a93c52890f2bab23 upstream. KASan uses constructors for initializing redzones for global variables. Globals instrumentation in GCC 4.9.2 produces constructors with priority (.init_array.00099) Currently kernel ignores such constructors. Only

[Devel] [PATCH 26/39] mm: vmalloc: pass additional vm_flags to __vmalloc_node_range()

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit cb9e3c292d0115499c660028ad35ac5501d722b5 upstream. For instrumenting global variables KASan will shadow memory backing memory for modules. So on module loading we will need to allocate memory for shadow and map it at address in shadow that corresponds to the address

[Devel] [PATCH 25/39] mm: vmalloc: add flag preventing guard hole allocation

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 71394fe50146202f2c8d92cf50f5ebc761acf254 upstream. For instrumenting global variables KASan will shadow memory backing memory for modules. So on module loading we will need to allocate memory for shadow and map it at address in shadow that corresponds to the address

[Devel] [PATCH 24/39] kasan: enable stack instrumentation

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit c420f167db8c799d69fe43a801c58a7f02e9d57c upstream. Stack instrumentation allows to detect out of bounds memory accesses for variables allocated on stack. Compiler adds redzones around every variable on stack and poisons redzones in function's prologue. Such approac

[Devel] [PATCH 23/39] x86_64: kasan: add interceptors for memset/memmove/memcpy functions

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 393f203f5fd54421fddb1e2a263f64d3876eeadb upstream. Recently instrumentation of builtin functions calls was removed from GCC 5.0. To check the memory accessed by such functions, userspace asan always uses interceptors for them. So now we should do this as well. Thi

[Devel] [PATCH 22/39] lib: add kasan test module

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 3f15801cdc2379ca4bf507f48bffd788f9e508ae upstream. This is a test module doing various nasty things like out of bounds accesses, use after free. It is useful for testing kernel debugging features like kernel address sanitizer. It mostly concentrates on testing of s

[Devel] [PATCH 21/39] kmemleak: disable kasan instrumentation for kmemleak

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit e79ed2f13faab8fc9d4ad76d5f5a241724e45836 upstream. kmalloc internally round up allocation size, and kmemleak uses rounded up size as object's size. This makes kasan to complain while kmemleak scans memory or calculates of object's checksum. The simplest solution he

[Devel] [PATCH 20/39] fs: dcache: manually unpoison dname after allocation to shut up kasan's reports

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit df4c0e36f1b1782b0611a77c52cc240e5c4752dd upstream. We need to manually unpoison rounded up allocation size for dname to avoid kasan's reports in dentry_string_cmp(). When CONFIG_DCACHE_WORD_ACCESS=y dentry_string_cmp may access few bytes beyound requested in kmalloc

[Devel] [PATCH 19/39] mm: slub: add kernel address sanitizer support for slub allocator

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 0316bec22ec95ea2faca6406437b0b5950553b7c upstream. With this patch kasan will be able to catch bugs in memory allocated by slub. Initially all objects in newly allocated slab page, marked as redzone. Later, when allocation of slub object happens, requested by calle

[Devel] [PATCH 18/39] mm: slub: introduce metadata_access_enable()/metadata_access_disable()

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit a79316c6178ca419e35feef47d47f50b4e0ee9f2 upstream. It's ok for slub to access memory that marked by kasan as inaccessible (object's metadata). Kasan shouldn't print report in that case because these accesses are valid. Disabling instrumentation of slub.c code is no

[Devel] [PATCH 17/39] mm: slub: share object_err function

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 75c66def8d815201aa0386ecc7c66a5c8dbca1ee upstream. Remove static and add function declarations to linux/slub_def.h so it could be used by kernel address sanitizer. Signed-off-by: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Konstantin Serebryany Cc: Dmitry Chernenkov S

[Devel] [PATCH 16/39] mm: slub: introduce virt_to_obj function

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 912f5fbf1d3060f25d6994aed0265c55b974b2e9 upstream. virt_to_obj takes kmem_cache address, address of slab page, address x pointing somewhere inside slab object, and returns address of the beginning of object. Signed-off-by: Andrey Ryabinin Acked-by: Christoph Lamete

[Devel] [PATCH 15/39] mm: page_alloc: add kasan hooks on alloc and free paths

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit b8c73fc2493d42517be95cf2c89659fc6c6f4d02 upstream. Add kernel address sanitizer hooks to mark allocated page's addresses as accessible in corresponding shadow region. Mark freed pages as inaccessible. Signed-off-by: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Konstanti

[Devel] [PATCH 14/39] x86_64: add KASan support

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit ef7f0d6a6ca8c9e4b27d78895af86c2fbfaeedb2 upstream. This patch adds arch specific code for kernel address sanitizer. 16TB of virtual addressed used for shadow memory. It's located in range [ec00 - fc00] between vmemmap and %esp fixup stacks.

[Devel] [PATCH 13/39] kasan: disable memory hotplug

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 786a8959912eb94fc2381c2ae487a96ce55dabca upstream. Currently memory hotplug won't work with KASan. As we don't have shadow for hotplugged memory, kernel will crash on the first access to it. To make this work we will need to allocate shadow for new memory. At some

[Devel] [PATCH 12/39] kasan: add kernel address sanitizer infrastructure

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 0b24becc810dc3be6e3f94103a866f214c282394 upstream. Kernel Address sanitizer (KASan) is a dynamic memory error detector. It provides fast and comprehensive solution for finding use-after-free and out-of-bounds bugs. KASAN uses compile-time instrumentation for checki

[Devel] [PATCH 11/39] compiler: introduce __alias(symbol) shortcut

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit cb4188ac8e5779f66b9f55888ac2c75b391cde44 upstream. To be consistent with other compiler attributes introduce __alias(symbol) macro expanding into __attribute__((alias(#symbol))) Signed-off-by: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Konstantin Serebryany Cc: Dmitry

[Devel] [PATCH 10/39] MODULE_DEVICE_TABLE: fix some callsites

2015-08-24 Thread Andrey Ryabinin
From: Andrew Morton commit 0f989f749b51ec1fd94bb5a42f8ad10c8b9f73cb upstream. The patch "module: fix types of device tables aliases" newly requires that invocations of MODULE_DEVICE_TABLE(type, name); come *after* the definition of `name'. That is reasonable, but some drivers weren't doing th

[Devel] [PATCH 09/39] mm: slub: SLUB_DEBUG=n: use the same alloc/free hooks as for SLUB_DEBUG=y

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 02e72cc61713185013d958baba508288ba2a0157 upstream. There are two versions of alloc/free hooks now - one for CONFIG_SLUB_DEBUG=y and another one for CONFIG_SLUB_DEBUG=n. I see no reason why calls to other debugging subsystems (LOCKDEP, DEBUG_ATOMIC_SLEEP, KMEMCHECK a

[Devel] [PATCH 08/39] mm: move slab related stuff from util.c to slab_common.c

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 928cec9cd6db53a68f54bc9ef1c54c674ba1c6bb upstream. Functions krealloc(), __krealloc(), kzfree() belongs to slab API, so should be placed in slab_common.c Also move slab allocator's tracepoints defenitions to slab_common.c No functional changes here. Signed-off-by:

[Devel] [PATCH 07/39] MIPS: Use NUMA_NO_NODE instead of -1 for node ID.

2015-08-24 Thread Andrey Ryabinin
From: Ralf Baechle commit 761845f0f68cf6eba9cad0a58d977b89f8d4486f upstream. Original patch by Jianguo Wu . Signed-off-by: Ralf Baechle Signed-off-by: Andrey Ryabinin --- arch/mips/kernel/module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/module.c

[Devel] [PATCH 06/39] mm/arch: use NUMA_NO_NODE

2015-08-24 Thread Andrey Ryabinin
From: Jianguo Wu commit 40c3baa7c66f1352521378ee83509fb8f4c465de upstream. Use more appropriate NUMA_NO_NODE instead of -1 in all archs' module_alloc() Signed-off-by: Jianguo Wu Acked-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Andrey Ryabini

[Devel] [PATCH 05/39] mm/vmalloc: use wrapper function get_vm_area_size to caculate size of vm area

2015-08-24 Thread Andrey Ryabinin
From: Wanpeng Li commit 762216ab4e175f49d17bc7ad778c57b9028184e6 upstream. Use wrapper function get_vm_area_size to calculate size of vm area. Signed-off-by: Wanpeng Li Cc: Dave Hansen Cc: Rik van Riel Cc: Fengguang Wu Cc: Joonsoo Kim Cc: Johannes Weiner Cc: Tejun Heo Cc: Yasuaki Ishimat

[Devel] [PATCH 04/39] lib/idr.c: fix out-of-bounds pointer dereference

2015-08-24 Thread Andrey Ryabinin
From: Andrey Ryabinin commit 93b7aca35dd7bf0c3ba7ea0542b556bcfdb28e76 upstream. I'm working on address sanitizer project for kernel. Recently we started experiments with stack instrumentation, to detect out-of-bounds read/write bugs on stack. Just after booting I've hit out-of-bounds read on s

[Devel] [PATCH 03/39] sched/numa: Fix initialization of sched_domain_topology for NUMA

2015-08-24 Thread Andrey Ryabinin
From: Vincent Guittot commit c515db8cd311ef77b2dc7cbd6b695022655bb0f3 upstream. Jet Chen has reported a kernel panics when booting qemu-system-x86_64 with kvm64 cpu. A panic occured while building the sched_domain. In sched_init_numa, we create a new topology table in which both default levels

[Devel] [PATCH 02/39] compiler-gcc: integrate the various compiler-gcc[345].h files

2015-08-24 Thread Andrey Ryabinin
From: Joe Perches commit cb984d101b30eb7478d32df56a0023e4603cba7f upstream. As gcc major version numbers are going to advance rather rapidly in the future, there's no real value in separate files for each compiler version. Deduplicate some of the macros #defined in each file too. Neaten commen

[Devel] [PATCH 01/39] kernel: use the gnu89 standard explicitly

2015-08-24 Thread Andrey Ryabinin
From: "Kirill A. Shutemov" commit 51b97e354ba9fce1890cf38ecc754aa49677fc89 upstream. Sasha Levin reports: "gcc5 changes the default standard to c11, which makes kernel build unhappy Explicitly define the kernel standard to be gnu89 which should keep everything working exactly like it was

[Devel] [PATCH 00/39] KASAN backport.

2015-08-24 Thread Andrey Ryabinin
paches: 1-2 - fixes compilation with gcc >= 5 3-4 - small bugfixes. 5-11 - misc pathces, clenups mostly, needed to avoid a lot of confilcts for the rest series. 6 - 39 - KASAN related patches 0001-kernel-use-the-gnu89-standard-explicitly.patch 0002-compiler-gcc-integrate-the-various-co

[Devel] [PATCH rh7] cgroup: do not virtualize output of cgroup_path

2015-08-24 Thread Vladimir Davydov
When cgroup_path() is called from inside a container, its output is "virtualized", i.e. cgroup /CTID/A/B is reported as /A/B. This was done for userspace tools to not get confused by the output of some proc files (namely, /proc/PID/{cgroup,cpuset}). However, it is wrong to virtualize cgroup_path()

Re: [Devel] [PATCH rh7] kmod: allow to load nf_log_ipv[46]

2015-08-24 Thread Kirill Tkhai
On 22.08.2015 17:51, Vladimir Davydov wrote: > These modules are required for adding the LOG iptables target. > > In PCS6 the LOG target is provided by ipt_LOG (in case of ipv4) or > ip6t_LOG (in case of ipv6) module. In Vz7 it is split between xt_LOG > (generic) and nf_log_ipv[46] (ipv[46] spec