Re: [PATCH bpf-next v4 00/20] Add return value range check for BPF LSM

2024-07-18 Thread Xu Kuohai
On 7/19/2024 10:13 AM, Paul Moore wrote: On Fri, Jul 12, 2024 at 5:44 PM Paul Moore wrote: On Thu, Jul 11, 2024 at 7:13 AM Xu Kuohai wrote: From: Xu Kuohai LSM BPF prog returning a positive number attached to the hook file_alloc_security makes kernel panic. Here is a panic log: [ 441.235

Re: [PATCH] mm, memcg: cg2 memory{.swap,}.peak write handlers

2024-07-18 Thread Waiman Long
On 7/18/24 17:49, David Finkel wrote: I spent some time today attempting to implement this. Here's a branch on github that compiles, and I think is close to what you described, but is definitely still a WIP: https://github.com/torvalds/linux/compare/master...dfinkel:linux:memcg2_memory_peak_fd

Re: [PATCH bpf-next v4 00/20] Add return value range check for BPF LSM

2024-07-18 Thread Paul Moore
On Fri, Jul 12, 2024 at 5:44 PM Paul Moore wrote: > On Thu, Jul 11, 2024 at 7:13 AM Xu Kuohai wrote: > > From: Xu Kuohai > > > > LSM BPF prog returning a positive number attached to the hook > > file_alloc_security makes kernel panic. > > > > Here is a panic log: > > > > [ 441.235774] BUG: kern

Re: [PATCH v4 10/20] lsm: Refactor return value of LSM hook audit_rule_match

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook audit_rule_match to 0 or a negative error code. > > Before: > - Hook audit_rule_match returns 1 if the rule matches, 0 if it not, > and negative error code otherwise. > > After: > - H

Re: [PATCH v4 9/20] lsm: Refactor return value of LSM hook key_getsecurity

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook key_getsecurity to 0 or a negative error code. > > Before: > - Hook key_getsecurity returns length of value on success or a > negative error code on failure. > > After: > - Hook key_g

Re: [PATCH v4 8/20] lsm: Refactor return value of LSM hook getprocattr

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook getprocattr to 0 or a negative error code. > > Before: > - Hook getprocattr returns length of value on success or a negative > error code on failure. > > After: > - Hook getprocattr r

Re: [PATCH v4 7/20] lsm: Refactor return value of LSM hook setprocattr

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook setprocattr to 0 or a negative error code. > > Before: > - Hook setprocattr returns the number of bytes written on success > or a negative error code on failure. > > After: > - Hook s

Re: [PATCH v4 6/20] lsm: Refactor return value of LSM hook getselfattr

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook getselfattr to 0 or a negative error code. > > Before: > - Hook getselfattr returns number of attributes found on success > or a negative error code on failure. > > After: > - Hook ge

Re: [PATCH v4 5/20] lsm: Refactor return value of LSM hook inode_copy_up_xattr

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook inode_copy_up_xattr to 0 or a negative error code. > > Before: > - Hook inode_copy_up_xattr returns 0 when accepting xattr, 1 when > discarding xattr, -EOPNOTSUPP if it does not know x

Re: [PATCH v4 4/20] lsm: Refactor return value of LSM hook inode_listsecurity

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook inode_listsecurity to 0 or a negative error code. > > Before: > - Hook inode_listsecurity returns number of bytes used/required on > success or a negative error code on failure. > > A

Re: [PATCH v4 3/20] lsm: Refactor return value of LSM hook inode_getsecurity

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook inode_getsecurity to 0 or a negative error code. > > Before: > - Hook inode_getsecurity returns size of buffer on success or a > negative error code on failure. > > After: > - Hook in

Re: [PATCH v4 2/20] lsm: Refactor return value of LSM hook inode_need_killpriv

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook inode_need_killpriv to 0 or a negative error code. > > Before: > - Both hook inode_need_killpriv and func security_inode_need_killpriv > return > 0 if security_inode_killpriv is requir

Re: [PATCH v4 1/20] lsm: Refactor return value of LSM hook vm_enough_memory

2024-07-18 Thread Paul Moore
On Jul 11, 2024 Xu Kuohai wrote: > > To be consistent with most LSM hooks, convert the return value of > hook vm_enough_memory to 0 or a negative error code. > > Before: > - Hook vm_enough_memory returns 1 if permission is granted, 0 if not. > - LSM_RET_DEFAULT(vm_enough_memory_mm) is 1. > > Af

Re: [PATCH v9 38/39] kselftest/arm64: Add a GCS stress test

2024-07-18 Thread Thiago Jung Bauermann
Thiago Jung Bauermann writes: > # # Finishing up... > # # Thread-4030 exited with error code 255 > # not ok 1 Thread-4030 > # # Thread-4031 exited with error code 255 > # not ok 2 Thread-4031 > # # Thread-4032 exited with error code 255 > # not ok 3 Thread-4032 > # # Thread-4033 exited with error

Re: [PATCH v9 38/39] kselftest/arm64: Add a GCS stress test

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > Add a stress test which runs one more process than we have CPUs spinning > through a very recursive function with frequent syscalls immediately prior > to return and signals being injected every 100ms. The goal is to flag up > any scheduling related issues, for example failur

Re: [PATCH v9 37/39] kselftest/arm64: Add GCS signal tests

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > Do some testing of the signal handling for GCS, checking that a GCS > frame has the expected information in it and that the expected signals > are delivered with invalid operations. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/se

Re: [PATCH bpf-next v3 5/5] selftests/bpf: Drop make_socket in sk_lookup

2024-07-18 Thread Martin KaFai Lau
On 7/17/24 11:22 PM, Geliang Tang wrote: From: Geliang Tang Use local helper make_client() in drop_on_lookup(), drop_on_reuseport() and run_multi_prog_lookup() instead of using make_socket() + connect(). Then make_socket() and inetaddr_len() can be dropped. Signed-off-by: Geliang Tang --- .

Re: [PATCH v9 35/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > On Thu, Jul 18, 2024 at 01:14:41PM -0300, Thiago Jung Bauermann wrote: > >> In my FVP VM, this test gets a GCS SIGSEGV before running the first test: > > Do you have THP enabled? That still doesn't work (I'm expecting it to > be fixed with -rc1). I did have it enabled. Afte

Re: [PATCH] mm, memcg: cg2 memory{.swap,}.peak write handlers

2024-07-18 Thread David Finkel
On Wed, Jul 17, 2024 at 1:04 PM Johannes Weiner wrote: > > On Tue, Jul 16, 2024 at 06:44:11AM -1000, Tejun Heo wrote: > > Hello, > > > > On Tue, Jul 16, 2024 at 03:48:17PM +0200, Michal Hocko wrote: > > ... > > > > This behavior is particularly useful for work scheduling systems that > > > > need

Re: [PATCH bpf-next v3 4/5] selftests/bpf: Use connect_to_addr_str in sk_lookup

2024-07-18 Thread Martin KaFai Lau
On 7/17/24 11:22 PM, Geliang Tang wrote: From: Geliang Tang This patch uses the new helper connect_to_addr_str() in make_client() instead of using local defined function make_socket() + connect(). This local function can be dropped latter. A new parameter "expect_errno" is added for make_clien

Re: [PATCH bpf-next v3 2/5] selftests/bpf: Drop must_fail from network_helper_opts

2024-07-18 Thread Martin KaFai Lau
On 7/17/24 11:22 PM, Geliang Tang wrote: diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 15e0e0bb7553..48c27c810db7 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -

[PATCH v8 8/8] clk: Add KUnit tests for clks registered with struct clk_parent_data

2024-07-18 Thread Stephen Boyd
Test that clks registered with 'struct clk_parent_data' work as intended and can find their parents. Cc: Christian Marangi Cc: Brendan Higgins Reviewed-by: David Gow Cc: Rae Moar Signed-off-by: Stephen Boyd --- drivers/clk/Kconfig | 2 + drivers/clk/Makefile

[PATCH v8 7/8] clk: Add KUnit tests for clk fixed rate basic type

2024-07-18 Thread Stephen Boyd
Test that the fixed rate basic type clk works as intended. Cc: Brendan Higgins Cc: David Gow Cc: Rae Moar Signed-off-by: Stephen Boyd --- drivers/clk/.kunitconfig | 2 + drivers/clk/Kconfig| 9 + drivers/clk/Makefile | 2 +

[PATCH v8 6/8] clk: Add test managed clk provider/consumer APIs

2024-07-18 Thread Stephen Boyd
Unit tests are more ergonomic and simpler to understand if they don't have to hoist a bunch of code into the test harness init and exit functions. Add some test managed wrappers for the clk APIs so that clk unit tests can write more code in the actual test and less code in the harness. Only add AP

[PATCH v8 5/8] platform: Add test managed platform_device/driver APIs

2024-07-18 Thread Stephen Boyd
Introduce KUnit resource wrappers around platform_driver_register(), platform_device_alloc(), and platform_device_add() so that test authors can register platform drivers/devices from their tests and have the drivers/devices automatically be unregistered when the test is done. This makes test setu

[PATCH v8 4/8] of: Add a KUnit test for overlays and test managed APIs

2024-07-18 Thread Stephen Boyd
Test the KUnit test managed overlay APIs. Confirm that platform devices are created and destroyed properly. This provides us confidence that the test managed APIs work correctly and can be relied upon to provide tests with fake platform devices and device nodes via overlays compiled into the kernel

[PATCH v8 3/8] dt-bindings: vendor-prefixes: Add "test" vendor for KUnit and friends

2024-07-18 Thread Stephen Boyd
Add the vendor prefix "test" to reserve a vendor prefix for bindings that are purely for testing device tree code. This allows test code to write bindings that can be checked by the schema validator. Reviewed-by: Rob Herring Reviewed-by: David Gow Cc: Krzysztof Kozlowski Cc: Conor Dooley Signe

[PATCH v8 2/8] of: Add test managed wrappers for of_overlay_apply()/of_node_put()

2024-07-18 Thread Stephen Boyd
Add test managed wrappers for of_overlay_apply() that automatically removes the overlay when the test is finished. This API is intended for use by KUnit tests that test code which relies on 'struct device_node's and of_*() APIs. KUnit tests will call of_overlay_apply_kunit() to load an overlay tha

Re: [PATCH v2 09/25] KVM: VMX: Switch FRED RSP0 between host and guest

2024-07-18 Thread H. Peter Anvin
On July 12, 2024 8:12:51 AM PDT, Sean Christopherson wrote: >On Wed, Jul 10, 2024, Xin3 Li wrote: >> > On Wed, Feb 07, 2024, Xin Li wrote: >> > > Switch MSR_IA32_FRED_RSP0 between host and guest in >> > > vmx_prepare_switch_to_{host,guest}(). >> > > >> > > MSR_IA32_FRED_RSP0 is used during ring 3

[PATCH v8 1/8] of/platform: Allow overlays to create platform devices from the root node

2024-07-18 Thread Stephen Boyd
We'd like to apply overlays to the root node in KUnit so we can test platform devices created as children of the root node. On some architectures (powerpc), the root node isn't marked with OF_POPULATED_BUS. If an overlay tries to modify the root node on these platforms it will fail, while on other

[PATCH v8 0/8] clk: Add kunit tests for fixed rate and parent data

2024-07-18 Thread Stephen Boyd
This patch series adds unit tests for the clk fixed rate basic type and the clk registration functions that use struct clk_parent_data. To get there, we add support for loading device tree overlays onto the live DTB along with probing platform drivers to bind to device nodes in the overlays. With t

RE: [PATCH v2 09/25] KVM: VMX: Switch FRED RSP0 between host and guest

2024-07-18 Thread Li, Xin3
> > thus we need to: > > > > 1) *always* save guest FRED RSP0 in vmx_prepare_switch_to_host(). > > > > 2) *always* restore guest FRED RSP0 in vmx_prepare_switch_to_guest(), > >because sometimes context switches happen but the CPU does NOT > >return to user mode thus the user return framewor

Re: [PATCH bpf-next v1 0/3] add bpf_file_d_path helper and selftests

2024-07-18 Thread Martin KaFai Lau
On 7/18/24 4:51 AM, Lin Yikai wrote: v1: - patch 2: - [1/2] add bpf_file_d_path helper - [2/2] add selftest to it Hi, we are looking to add the "bpf_file_d_path" helper, used to retrieve the path from a struct file object. bpf_file_d_path(void *file, char *dst, u32 size);

Re: [PATCH v9 35/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-07-18 Thread Mark Brown
On Thu, Jul 18, 2024 at 01:14:41PM -0300, Thiago Jung Bauermann wrote: > In my FVP VM, this test gets a GCS SIGSEGV before running the first test: Do you have THP enabled? That still doesn't work (I'm expecting it to be fixed with -rc1). signature.asc Description: PGP signature

Re: [PATCH v9 35/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > There are things like threads which nolibc struggles with which we want > to add coverage for, and the ABI allows us to test most of these even if > libc itself does not understand GCS so add a test application built > using the system libc. > > Reviewed-by: Thiago Jung Bauer

Re: [PATCH v3 0/4] selftest: x86: improve tests

2024-07-18 Thread Shuah Khan
On 7/18/24 05:32, Muhammad Usama Anjum wrote: Changes since v1: - Correct the description of patches with what improvements they are bringing and why they are required Changes since v2: - Update descriptions of patches and add output before/after Muhammad Usama Anjum (4): selftests: x86:

Re: [PATCH v3 1/4] selftests: x86: check_initial_reg_state: remove manual counting and increase maintainability

2024-07-18 Thread Shuah Khan
On 7/18/24 05:32, Muhammad Usama Anjum wrote: Removes manual counting of pass and fail tests. This increases readability of tests, but also improves maintainability of the tests. Print logs in standard format (without [RUN], [OK] tags) Signed-off-by: Muhammad Usama Anjum --- Changes since v1: -

Re: [PATCH] kselftest: missing arg in ptrace.c

2024-07-18 Thread Will Deacon
On Tue, Jul 16, 2024 at 09:49:12AM +0530, Dev Jain wrote: > > On 7/13/24 04:47, Remington Brasga wrote: > > The string passed to ksft_test_result_skip is missing the `type_name` > > > > Signed-off-by: Remington Brasga > > --- > > clang-tidy reported clang-diagnostic-format-insufficient-args warn

Re: [PATCH v2 0/2] kselftest/alsa: Diagnostic improvements

2024-07-18 Thread Takashi Iwai
On Tue, 16 Jul 2024 16:47:58 +0200, Mark Brown wrote: > > The first patch fixes unstable naming of tests due to probe ordering not > being stable, the second just provides a bit more information. > > Signed-off-by: Mark Brown > --- > Changes in v2: > - Switch to using ID rather than longame. > -

Re: [PATCH v2 09/25] KVM: VMX: Switch FRED RSP0 between host and guest

2024-07-18 Thread Sean Christopherson
On Wed, Jul 17, 2024, Xin3 Li wrote: > > > > > E.g. if it's somewhere in task_struct, then kvm_on_user_return() > > > > > would restore the current task's desired RSP0. > > > > > > > > So you're suggesting to extend the framework to allow per task > > > > constants? > > > > > > Yeah, or more likel

[PATCH bpf-next v1 2/3] selftests/bpf:Adding test for bpf_file_d_path helper

2024-07-18 Thread Lin Yikai
Hi, Adding test for bpf_file_d_path helper. It passed the test in my environment using QEMU (./test_progs -t file_d_path) Below are some partial results: ''' + [ -x /etc/rcS.d/S50-startup ] + /etc/rcS.d/S50-startup ./test_progs -t file_d_path Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED '''

[PATCH bpf-next v1 1/3] bpf: Add bpf_file_d_path helper

2024-07-18 Thread Lin Yikai
Add the "bpf_file_d_path" helper function to retrieve the path from a struct file object. But there is no need to include vmlinux.h or reference the definition of struct file. Additionally, update the bpf.h tools uapi header. Signed-off-by: Lin Yikai --- include/uapi/linux/bpf.h | 20

[PATCH bpf-next v1 0/3] add bpf_file_d_path helper and selftests

2024-07-18 Thread Lin Yikai
v1: - patch 2: - [1/2] add bpf_file_d_path helper - [2/2] add selftest to it Hi, we are looking to add the "bpf_file_d_path" helper, used to retrieve the path from a struct file object. bpf_file_d_path(void *file, char *dst, u32 size); It's worth noting that the "file" par

[PATCH v3 4/4] selftests: x86: entry_from_vm86: remove manual counting and increase maintainability

2024-07-18 Thread Muhammad Usama Anjum
Remove the manual pass/fail tests counting and use kselftests helpers which improves readability as well. Print details about errno if error occurs and also print logs in standard format. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - correct description of the patch Changes since v

[PATCH v3 3/4] selftests: x86: fsgsbase_restore: remove manual counting and increase maintainability

2024-07-18 Thread Muhammad Usama Anjum
Add the test skip support instead of returning success at skip time for the kselftest runner script to understand correct exit status. Add logs to print details about errno if error occurs. Needless to say, all of this improves readability and maintainability. Signed-off-by: Muhammad Usama Anjum

[PATCH v3 2/4] selftests: x86: corrupt_xstate_header: remove manual counting and increase maintainability

2024-07-18 Thread Muhammad Usama Anjum
Correct the skip, pass and fail return codes. Otherwise the test always return 0. After the chaanges, correct number of stats about passed or failed tests is being returned. Also print logs in standard format. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - correct description of the

[PATCH v3 1/4] selftests: x86: check_initial_reg_state: remove manual counting and increase maintainability

2024-07-18 Thread Muhammad Usama Anjum
Removes manual counting of pass and fail tests. This increases readability of tests, but also improves maintainability of the tests. Print logs in standard format (without [RUN], [OK] tags) Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - correct description of the patch Changes since

[PATCH v3 0/4] selftest: x86: improve tests

2024-07-18 Thread Muhammad Usama Anjum
Changes since v1: - Correct the description of patches with what improvements they are bringing and why they are required Changes since v2: - Update descriptions of patches and add output before/after Muhammad Usama Anjum (4): selftests: x86: check_initial_reg_state: remove manual counting an

RE: [PATCH v3 1/7] iommu: Introduce a replace API for device pasid

2024-07-18 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, June 28, 2024 5:06 PM > > @@ -3289,7 +3290,20 @@ static int __iommu_set_group_pasid(struct > iommu_domain *domain, > > if (device == last_gdev) > break; > - ops->remove_dev_pasid(device->dev, pasid, domain); > +

Re: [PATCH] mm, memcg: cg2 memory{.swap,}.peak write handlers

2024-07-18 Thread Michal Hocko
On Wed 17-07-24 16:44:53, Johannes Weiner wrote: [...] > The problem is that once global resetting is allowed, it makes the > number reported in memory.peak unreliable for everyone. You just don't > know, and can't tell, if somebody wrote to it recently. It's not too > much of a leap to say this br

Re: [PATCH 2/2] selftests: x86: vdso_restorer: Return correct exit statuses

2024-07-18 Thread Muhammad Usama Anjum
On 7/17/24 3:01 AM, Shuah Khan wrote: > On 7/12/24 01:30, Muhammad Usama Anjum wrote: >> Return correct exit status, KSFT_SKIP if the pre-conditions aren't met. >> Return KSFT_FAIL if error occurs. Use ksft_finished() which will >> compmare the total planned tests with passed tests to return the ex