Re: [RFC PATCH v1 2/2] vsock/test: SO_RCVLOWAT + deferred credit update test

2023-11-15 Thread Stefano Garzarella
On Wed, Nov 08, 2023 at 10:20:04AM +0300, Arseniy Krasnov wrote: This adds test which checks, that updating SO_RCVLOWAT value also sends You can avoid "This adds", and write just "Add test ...". See https://docs.kernel.org/process/submitting-patches.html#describe-your-changes Describe

Re: [RFC PATCH v1 0/2] send credit update during setting SO_RCVLOWAT

2023-11-15 Thread Stefano Garzarella
On Wed, Nov 08, 2023 at 10:20:02AM +0300, Arseniy Krasnov wrote: Hello, DESCRIPTION This patchset fixes old problem with hungup of both rx/tx sides and adds test for it. This happens due to non-default SO_RCVLOWAT value and deferred credit update in virtio/vsock.

Re: [RFC PATCH v1 1/2] virtio/vsock: send credit update during setting SO_RCVLOWAT

2023-11-15 Thread Stefano Garzarella
On Wed, Nov 08, 2023 at 10:20:03AM +0300, Arseniy Krasnov wrote: This adds sending credit update message when SO_RCVLOWAT is updated and it is bigger than number of bytes in rx queue. It is needed, because 'poll()' will wait until number of bytes in rx queue will be not smaller than SO_RCVLOWAT,

Re: [PATCH v6 12/12] selftests/sgx: Add scripts for EPC cgroup testing

2023-11-15 Thread Haitao Huang
+CG_ROOT=/sys/fs/cgroup +if [ ! -d "/sys/fs/cgroup/misc" ]; then +echo "# cgroup V2 is in use." +else +echo "# cgroup V1 is in use." +CG_ROOT=/sys/fs/cgroup/misc +fi Does the test need to support v1 cgroups? I thought some distro may still only support V1. I do my most work on

Re: [PATCH v7 00/13] selftests/sgx: Fix compilation errors

2023-11-15 Thread Jarkko Sakkinen
On Wed Nov 8, 2023 at 10:46 PM EET, Dave Hansen wrote: > On 11/8/23 12:31, Jo Van Bulck wrote: > > Just a kind follow-up: from what I can see, this series has not been > > merged into the x86/sgx branch of tip yet (assuming that's where it > > should go next)? > > > > Apologies if I've overlooked

Re: [PATCH v7 00/13] selftests/sgx: Fix compilation errors

2023-11-15 Thread Jarkko Sakkinen
On Wed Nov 8, 2023 at 10:31 PM EET, Jo Van Bulck wrote: > On 23.10.23 23:32, Jarkko Sakkinen wrote: > > On Fri Oct 13, 2023 at 2:45 PM EEST, Jo Van Bulck wrote: > >> On 10.10.23 11:44, Jarkko Sakkinen wrote: > >>> Folks (sorry for top posting): I've now taken my old NUC7 out of the > >>> dust and

[PATCH] MAINTAINERS: TRACING: Add Mathieu Desnoyers as Reviewer

2023-11-15 Thread Mathieu Desnoyers
In order to make sure I get CC'd on tracing changes for which my input would be relevant, add my name as reviewer of the TRACING subsystem. Signed-off-by: Mathieu Desnoyers Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: linux-trace-ker...@vger.kernel.org --- MAINTAINERS | 1 + 1 file changed, 1

[PATCH 28/32] s390/traps: Unpoison the kernel_stack_overflow()'s pt_regs

2023-11-15 Thread Ilya Leoshkevich
This is normally done by the generic entry code, but the kernel_stack_overflow() flow bypasses it. Signed-off-by: Ilya Leoshkevich --- arch/s390/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index

[PATCH 20/32] s390: Turn off KMSAN for boot, vdso and purgatory

2023-11-15 Thread Ilya Leoshkevich
All other sanitizers are disabled for these components as well. Reviewed-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich --- arch/s390/boot/Makefile | 1 + arch/s390/kernel/vdso32/Makefile | 1 + arch/s390/kernel/vdso64/Makefile | 1 + arch/s390/purgatory/Makefile | 1 + 4

[PATCH 24/32] s390/cpacf: Unpoison the results of cpacf_trng()

2023-11-15 Thread Ilya Leoshkevich
Prevent KMSAN from complaining about buffers filled by cpacf_trng() being uninitialized. Tested-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/cpacf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/include/asm/cpacf.h

Re: [PATCH v6 04/12] x86/sgx: Implement basic EPC misc cgroup functionality

2023-11-15 Thread Jarkko Sakkinen
On Mon Oct 30, 2023 at 8:20 PM EET, Haitao Huang wrote: > From: Kristen Carlson Accardi > > Implement support for cgroup control of SGX Enclave Page Cache (EPC) > memory using the misc cgroup controller. EPC memory is independent > from normal system memory, e.g. must be reserved at boot from RAM

[PATCH 2/3] modpost: Extended modversion support

2023-11-15 Thread Matthew Maurer
Adds a new format for modversions which stores each field in a separate elf section. This initially adds support for variable length names, but could later be used to add additional fields to modversions in a backwards compatible way if needed. Adding support for variable length names makes it

[PATCH 10/32] kmsan: Expose kmsan_get_metadata()

2023-11-15 Thread Ilya Leoshkevich
Each s390 CPU has lowcore pages associated with it. Each CPU sees its own lowcore at virtual address 0 through a hardware mechanism called prefixing. Additionally, all lowcores are mapped to non-0 virtual addresses stored in the lowcore_ptr[] array. When lowcore is accessed through virtual

[PATCH 16/32] mm: kfence: Disable KMSAN when checking the canary

2023-11-15 Thread Ilya Leoshkevich
KMSAN warns about check_canary() accessing the canary. The reason is that, even though set_canary() is properly instrumented and sets shadow, slub explicitly poisons the canary's address range afterwards. Unpoisoning the canary is not the right thing to do: only check_canary() is supposed to

[PATCH 17/32] lib/string: Add KMSAN support to strlcpy() and strlcat()

2023-11-15 Thread Ilya Leoshkevich
Currently KMSAN does not fully propagate metadata in strlcpy() and strlcat(), because they are built with -ffreestanding and call memcpy(). In this combination memcpy() calls are not instrumented. Fix by copying the metadata manually. Add the __STDC_HOSTED__ #ifdef in case the code is compiled

[PATCH 11/32] kmsan: Export panic_on_kmsan

2023-11-15 Thread Ilya Leoshkevich
When building the kmsan test as a module, modpost fails with the following error message: ERROR: modpost: "panic_on_kmsan" [mm/kmsan/kmsan_test.ko] undefined! Export panic_on_kmsan in order to improve the KMSAN usability for modules. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/report.c |

[PATCH 13/32] kmsan: Support SLAB_POISON

2023-11-15 Thread Ilya Leoshkevich
Avoid false KMSAN negatives with SLUB_DEBUG by allowing kmsan_slab_free() to poison the freed memory, and by preventing init_object() from unpoisoning new allocations. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/hooks.c | 2 +- mm/slub.c| 3 ++- 2 files changed, 3 insertions(+), 2

[PATCH 12/32] kmsan: Allow disabling KMSAN checks for the current task

2023-11-15 Thread Ilya Leoshkevich
Like for KASAN, it's useful to temporarily disable KMSAN checks around, e.g., redzone accesses. Introduce kmsan_disable_current() and kmsan_enable_current(), which are similar to their KASAN counterparts. Even though it's not strictly necessary, make them reentrant, in order to match the KASAN

[PATCH 01/32] ftrace: Unpoison ftrace_regs in ftrace_ops_list_func()

2023-11-15 Thread Ilya Leoshkevich
Architectures use assembly code to initialize ftrace_regs and call ftrace_ops_list_func(). Therefore, from the KMSAN's point of view, ftrace_regs is poisoned on ftrace_ops_list_func entry(). This causes KMSAN warnings when running the ftrace testsuite. Fix by trusting the architecture-specific

[PATCH 02/32] kmsan: Make the tests compatible with kmsan.panic=1

2023-11-15 Thread Ilya Leoshkevich
It's useful to have both tests and kmsan.panic=1 during development, but right now the warnings, that the tests cause, lead to kernel panics. Temporarily set kmsan.panic=0 for the duration of the KMSAN testing. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/kmsan_test.c | 5 + 1 file

[PATCH 00/32] kmsan: Enable on s390

2023-11-15 Thread Ilya Leoshkevich
Hi, This series provides the minimal support for Kernel Memory Sanitizer on s390. Kernel Memory Sanitizer is clang-only instrumentation for finding accesses to uninitialized memory. The clang support for s390 has already been merged [1]. With this series, I can successfully boot s390 defconfig

[PATCH 06/32] kmsan: Fix kmsan_copy_to_user() on arches with overlapping address spaces

2023-11-15 Thread Ilya Leoshkevich
Comparing pointers with TASK_SIZE does not make sense when kernel and userspace overlap. Assume that we are handling user memory access in this case. Reported-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich --- mm/kmsan/hooks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

[PATCH 03/32] kmsan: Disable KMSAN when DEFERRED_STRUCT_PAGE_INIT is enabled

2023-11-15 Thread Ilya Leoshkevich
KMSAN relies on memblock returning all available pages to it (see kmsan_memblock_free_pages()). It partitions these pages into 3 categories: pages available to the buddy allocator, shadow pages and origin pages. This partitioning is static. If new pages appear after kmsan_init_runtime(), it is

[PATCH 09/32] kmsan: Introduce kmsan_memmove_metadata()

2023-11-15 Thread Ilya Leoshkevich
It is useful to manually copy metadata in order to describe the effects of memmove()-like logic in uninstrumented code or inline asm. Introduce kmsan_memmove_metadata() for this purpose. Signed-off-by: Ilya Leoshkevich --- include/linux/kmsan-checks.h | 14 ++ mm/kmsan/hooks.c

[PATCH 19/32] kmsan: Accept ranges starting with 0 on s390

2023-11-15 Thread Ilya Leoshkevich
On s390 the virtual address 0 is valid (current CPU's lowcore is mapped there), therefore KMSAN should not complain about it. Disable the respective check on s390. There doesn't seem to be a Kconfig option to describe this situation, so explicitly check for s390. Signed-off-by: Ilya Leoshkevich

[PATCH 18/32] lib/zlib: Unpoison DFLTCC output buffers

2023-11-15 Thread Ilya Leoshkevich
The constraints of the DFLTCC inline assembly are not precise: they do not communicate the size of the output buffers to the compiler, so it cannot automatically instrument it. Add the manual kmsan_unpoison_memory() calls for the output buffers. The logic is the same as in [1]. [1]

[PATCH 07/32] kmsan: Remove a useless assignment from kmsan_vmap_pages_range_noflush()

2023-11-15 Thread Ilya Leoshkevich
The value assigned to prot is immediately overwritten on the next line with PAGE_KERNEL. The right hand side of the assignment has no side-effects. Fixes: b073d7f8aee4 ("mm: kmsan: maintain KMSAN metadata for page operations") Suggested-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich ---

[PATCH 15/32] mm: slub: Let KMSAN access metadata

2023-11-15 Thread Ilya Leoshkevich
Building the kernel with CONFIG_SLUB_DEBUG and CONFIG_KMSAN causes KMSAN to complain about touching redzones in kfree(). Fix by extending the existing KASAN-related metadata_access_enable() and metadata_access_disable() functions to KMSAN. Signed-off-by: Ilya Leoshkevich --- mm/slub.c | 2 ++

[PATCH 14/32] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata()

2023-11-15 Thread Ilya Leoshkevich
Improve the readability by replacing the custom aligning logic with ALIGN_DOWN(). Unlike other places where a similar sequence is used, there is no size parameter that needs to be adjusted, so the standard macro fits. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/shadow.c | 8 +++- 1 file

[PATCH 05/32] kmsan: Fix is_bad_asm_addr() on arches with overlapping address spaces

2023-11-15 Thread Ilya Leoshkevich
Comparing pointers with TASK_SIZE does not make sense when kernel and userspace overlap. Skip the comparison when this is the case. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/instrumentation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kmsan/instrumentation.c

[PATCH 08/32] kmsan: Remove an x86-specific #include from kmsan.h

2023-11-15 Thread Ilya Leoshkevich
Replace the x86-specific asm/pgtable_64_types.h #include with the linux/pgtable.h one, which all architectures have. Fixes: f80be4571b19 ("kmsan: add KMSAN runtime core") Suggested-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich --- mm/kmsan/kmsan.h | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH 04/32] kmsan: Increase the maximum store size to 4096

2023-11-15 Thread Ilya Leoshkevich
The inline assembly block in s390's chsc() stores that much. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/instrumentation.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/kmsan/instrumentation.c b/mm/kmsan/instrumentation.c index cc3907a9c33a..470b0b4afcc4 100644

Re: [PATCH v6 08/12] x86/sgx: Use a list to track to-be-reclaimed pages

2023-11-15 Thread Jarkko Sakkinen
On Mon Oct 30, 2023 at 8:20 PM EET, Haitao Huang wrote: > From: Sean Christopherson > > Change sgx_reclaim_pages() to use a list rather than an array for > storing the epc_pages which will be reclaimed. This change is needed > to transition to the LRU implementation for EPC cgroup support. > >

Re: [PATCH v6 01/12] cgroup/misc: Add per resource callbacks for CSS events

2023-11-15 Thread Jarkko Sakkinen
On Mon Oct 30, 2023 at 8:20 PM EET, Haitao Huang wrote: > From: Kristen Carlson Accardi > > The misc cgroup controller (subsystem) currently does not perform > resource type specific action for Cgroups Subsystem State (CSS) events: > the 'css_alloc' event when a cgroup is created and the

[PATCH 32/32] kmsan: Enable on s390

2023-11-15 Thread Ilya Leoshkevich
Now that everything else is in place, enable KMSAN in Kconfig. Signed-off-by: Ilya Leoshkevich --- arch/s390/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 3bec98d20283..160ad2220c53 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig

[PATCH 27/32] s390/string: Add KMSAN support

2023-11-15 Thread Ilya Leoshkevich
Add KMSAN support for the s390 implementations of the string functions. Do this similar to how it's already done for KASAN, except that the optimized memset{16,32,64}() functions need to be disabled: it's important for KMSAN to know that they initialized something. Signed-off-by: Ilya Leoshkevich

[PATCH 23/32] s390/checksum: Add a KMSAN check

2023-11-15 Thread Ilya Leoshkevich
Add a KMSAN check to the CKSM inline assembly, similar to how it was done for ASAN in commit e42ac7789df6 ("s390/checksum: always use cksm instruction"). Acked-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/checksum.h | 2 ++ 1 file changed, 2 insertions(+)

[PATCH 26/32] s390/mm: Define KMSAN metadata for vmalloc and modules

2023-11-15 Thread Ilya Leoshkevich
The pages for the KMSAN metadata associated with most kernel mappings are taken from memblock by the common code. However, vmalloc and module metadata needs to be defined by the architectures. Be a little bit more careful than x86: allocate exactly MODULES_LEN for the module shadow and origins,

[PATCH 29/32] s390/uaccess: Add KMSAN support to put_user() and get_user()

2023-11-15 Thread Ilya Leoshkevich
put_user() uses inline assembly with precise constraints, so Clang is in principle capable of instrumenting it automatically. Unfortunately, one of the constraints contains a dereferenced user pointer, and Clang does not currently distinguish user and kernel pointers. Therefore KMSAN attempts to

[PATCH 22/32] s390/boot: Add the KMSAN runtime stub

2023-11-15 Thread Ilya Leoshkevich
It should be possible to have inline functions in the s390 header files, which call kmsan_unpoison_memory(). The problem is that these header files might be included by the decompressor, which does not contain KMSAN runtime, causing linker errors. Not compiling these calls if __SANITIZE_MEMORY__

[PATCH 21/32] s390: Use a larger stack for KMSAN

2023-11-15 Thread Ilya Leoshkevich
Adjust the stack size for the KMSAN-enabled kernel like it was done for the KASAN-enabled one in commit 7fef92ccadd7 ("s390/kasan: double the stack size"). Both tools have similar requirements. Reviewed-by: Alexander Gordeev Signed-off-by: Ilya Leoshkevich --- arch/s390/Makefile

[PATCH 30/32] s390/unwind: Disable KMSAN checks

2023-11-15 Thread Ilya Leoshkevich
The unwind code can read uninitialized frames. Furthermore, even in the good case, KMSAN does not emit shadow for backchains. Therefore disable it for the unwinding functions. Signed-off-by: Ilya Leoshkevich --- arch/s390/kernel/unwind_bc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH 25/32] s390/ftrace: Unpoison ftrace_regs in kprobe_ftrace_handler()

2023-11-15 Thread Ilya Leoshkevich
s390 uses assembly code to initialize ftrace_regs and call kprobe_ftrace_handler(). Therefore, from the KMSAN's point of view, ftrace_regs is poisoned on kprobe_ftrace_handler() entry. This causes KMSAN warnings when running the ftrace testsuite. Fix by trusting the assembly code and always

[PATCH 31/32] s390: Implement the architecture-specific kmsan functions

2023-11-15 Thread Ilya Leoshkevich
arch_kmsan_get_meta_or_null() finds the lowcore shadow by querying the prefix and calling kmsan_get_metadata() again. kmsan_virt_addr_valid() delegates to virt_addr_valid(). Signed-off-by: Ilya Leoshkevich --- arch/s390/include/asm/kmsan.h | 36 +++ 1 file

Re: [PATCH v6 12/12] selftests/sgx: Add scripts for EPC cgroup testing

2023-11-15 Thread Jarkko Sakkinen
On Mon Oct 30, 2023 at 8:20 PM EET, Haitao Huang wrote: > The scripts rely on cgroup-tools package from libcgroup [1]. > > To run selftests for epc cgroup: > > sudo ./run_epc_cg_selftests.sh > > With different cgroups, the script starts one or multiple concurrent SGX > selftests, each to run one

Re: [PATCH v6 07/12] x86/sgx: Introduce EPC page states

2023-11-15 Thread Jarkko Sakkinen
On Mon Oct 30, 2023 at 8:20 PM EET, Haitao Huang wrote: > Use the lower 2 bits in the flags field of sgx_epc_page struct to track > EPC states and define an enum for possible states for EPC pages tracked > for reclamation. > > Add the RECLAIM_IN_PROGRESS state to explicitly indicate a page that is