Re: [PATCH v10 0/25] security: Move IMA and EVM to the LSM infrastructure

2024-02-15 Thread Roberto Sassu
On Thu, 2024-02-15 at 23:43 -0500, Paul Moore wrote: > On Feb 15, 2024 Roberto Sassu wrote: > > > > IMA and EVM are not effectively LSMs, especially due to the fact that in > > the past they could not provide a security blob while there is another LSM > > active. > > > > That changed in the

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-15 Thread Martin KaFai Lau
On 2/14/24 9:18 AM, Benjamin Tissoires wrote: +static void bpf_timer_work_cb(struct work_struct *work) +{ + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); + struct bpf_map *map = t->map; + void *value = t->value; + bpf_callback_t callback_fn; +

Re: [PATCH v10 0/25] security: Move IMA and EVM to the LSM infrastructure

2024-02-15 Thread Paul Moore
On Feb 15, 2024 Roberto Sassu wrote: > > IMA and EVM are not effectively LSMs, especially due to the fact that in > the past they could not provide a security blob while there is another LSM > active. > > That changed in the recent years, the LSM stacking feature now makes it > possible to

[RFC 7/7] selftests: kselftest_harness: let PASS / FAIL provide diagnostic

2024-02-15 Thread Jakub Kicinski
Switch to printing KTAP line for PASS / FAIL with ksft_test_result_code(), this gives us the ability to report diagnostic messages for free. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/kselftest_harness.h | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git

[RFC 5/7] selftests: kselftest_harness: print test name for SKIP and XFAIL

2024-02-15 Thread Jakub Kicinski
Jakub points out that for parsers it's rather useful to always have the test name on the result line. Currently if we SKIP or XFAIL, we will print: ok 17 # SKIP SCTP doesn't support IP_BIND_ADDRESS_NO_PORT ^ no test name Always print the test name. KTAP format seems to allow or even

[RFC 6/7] selftests: kselftest_harness: let ksft_test_result_code() handle line termination

2024-02-15 Thread Jakub Kicinski
According to the spec we should always print a # if we add a diagnostic message. Having the caller pass in the new line as part of diagnostic message makes handling this a bit counter-intuitive. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/kselftest.h | 5 +

[RFC 4/7] selftests: kselftest: add ksft_test_result_code(), handling all exit codes

2024-02-15 Thread Jakub Kicinski
For generic test harness code it's more useful to deal with exit codes directly, rather than having to switch on them and call the right ksft_test_result_*() helper. Add such function to kselftest.h. Note that "directive" and "diagnostic" are what ktap docs call those parts of the message.

[RFC 3/7] selftests: kselftest_harness: use exit code to store skip and xfail

2024-02-15 Thread Jakub Kicinski
We always use skip / xfail with combination of exit_code being 0 (KSFT_PASS). This are just basic KSFT / KTAP semantics. Store the right KSFT_* code in exit_code directly. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/kselftest_harness.h | 35 ++--- 1 file changed, 9

[RFC 2/7] selftests: kselftest_harness: save full exit code in metadata

2024-02-15 Thread Jakub Kicinski
Instead of tracking passed = 0/1 rename the field to exit_code and invert the values so that they match the KSFT_* exit codes. This will allow us to fold SKIP / XFAIL into the same value. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/kselftest_harness.h | 52 -

[RFC 1/7] selftests: kselftest_harness: generate test name once

2024-02-15 Thread Jakub Kicinski
Since we added variant support generating full test case name takes 4 string arguments. We're about to need it in another two places. Stop the duplication and print once into a temporary buffer. Suggested-by: Jakub Sitnicki Signed-off-by: Jakub Kicinski ---

[RFC 0/7] selftests: kselftest_harness: use common result printing helper

2024-02-15 Thread Jakub Kicinski
Add a common result printing helper and always include test name in the result line. Previously when SKIP or XPASS would happen we printed: ok 1 # SKIP unknown without the test name. Now we'll print: ok 1 global.no_pad # SKIP unknown This appears to be more inline with:

[PATCH net-next v2 4/4] selftests: ip_local_port_range: use XFAIL instead of SKIP

2024-02-15 Thread Jakub Kicinski
SCTP does not support IP_LOCAL_PORT_RANGE and we know it, so use XFAIL instead of SKIP. Reviewed-by: Kees Cook Tested-by: Jakub Sitnicki Signed-off-by: Jakub Kicinski --- tools/testing/selftests/net/ip_local_port_range.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH net-next v2 3/4] selftests: kselftest_harness: support using xfail

2024-02-15 Thread Jakub Kicinski
Selftest summary includes XFAIL but there's no way to use it from within the harness. Support it in a similar way to skip. Currently tests report skip for things they expect to fail e.g. when given combination of parameters is known to be unsupported. This is confusing because in an ideal

[PATCH net-next v2 1/4] selftests: kselftest_harness: pass step via shared memory

2024-02-15 Thread Jakub Kicinski
Commit 0ef67a888375 ("selftests/harness: Report skip reason") added shared memory to communicate between harness and test. Use that instead of exit codes to send the failing step back to the harness. The exit codes are limited and because of the step passing we can't use the full range of KSFT_*

[PATCH net-next v2 2/4] selftests: kselftest_harness: use KSFT_* exit codes

2024-02-15 Thread Jakub Kicinski
Now that we no longer need low exit codes to communicate assertion steps - use normal KSFT exit codes. Acked-by: Kees Cook Tested-by: Jakub Sitnicki Signed-off-by: Jakub Kicinski --- tools/testing/selftests/kselftest_harness.h | 13 ++--- 1 file changed, 6 insertions(+), 7

[PATCH net-next v2 0/4] selftests: kselftest_harness: support using xfail

2024-02-15 Thread Jakub Kicinski
Hi! When running selftests for our subsystem in our CI we'd like all tests to pass. Currently some tests use SKIP for cases they expect to fail, because the kselftest_harness limits the return codes to pass/fail/skip. Clean up and support the use of the full range of ksft exit codes under

Re: [PATCH v10 19/25] integrity: Move integrity_kernel_module_request() to IMA

2024-02-15 Thread Mimi Zohar
On Thu, 2024-02-15 at 17:09 +0100, Roberto Sassu wrote: > On Thu, 2024-02-15 at 11:31 +0100, Roberto Sassu wrote: > > From: Roberto Sassu > > > > In preparation for removing the 'integrity' LSM, move > > integrity_kernel_module_request() to IMA, and rename it to > > ima_kernel_module_request().

Re: [PATCH net-next 3/4] selftests: kselftest_harness: support using xfail

2024-02-15 Thread Jakub Kicinski
On Thu, 15 Feb 2024 14:06:58 -0800 Kees Cook wrote: > Oh! I just noticed this while testing changes to use XFAIL, there is an > alignment issue: one too many spaces after "XFAIL" above, which leads > to misaligned output. > > fprintf(TH_LOG_STREAM, "# XFAIL %s\n", \ >

Re: [PATCH net-next 3/4] selftests: kselftest_harness: support using xfail

2024-02-15 Thread Kees Cook
On Tue, Feb 13, 2024 at 07:44:15AM -0800, Jakub Kicinski wrote: > [...] > +/** > + * XFAIL() > + * > + * @statement: statement to run after reporting XFAIL > + * @fmt: format string > + * @...: optional arguments > + * > + * .. code-block:: c > + * > + * XFAIL(statement, fmt, ...); > + * > + *

Re: [PATCH v3 7/7] of: Add KUnit test to confirm DTB is loaded

2024-02-15 Thread Stephen Boyd
Quoting Rob Herring (2024-02-13 09:52:00) > On Fri, Feb 9, 2024 at 8:59 PM Stephen Boyd wrote: > > > > ---8<--- > > diff --git a/init/main.c b/init/main.c > > index e24b0780fdff..02f5cf8be6c1 100644 > > --- a/init/main.c > > +++ b/init/main.c > > @@ -97,6 +97,8 @@ > > #include > > #include >

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Michal Suchánek
On Thu, Feb 15, 2024 at 01:39:27PM -0600, Nathan Lynch wrote: > Michal Suchánek writes: > > On Thu, Feb 15, 2024 at 01:13:34PM -0600, Nathan Lynch wrote: > >> Michal Suchanek writes: > >> > > >> > Without the headers the tests don't build. > >> > > >> > Fixes: 9118c5d32bdd ("powerpc/selftests:

[PATCH v2 0/2] KVM: s390: Fix AR parameter in MEM_OP ioctl

2024-02-15 Thread Eric Farman
Hi Christian, Janosch, Heiko, Here is a new version for the AR/MEM_OP issue I'm attempting to address, with Heiko's feedback to v1. Patch 1 performs the host/guest access register swap that Christian suggested (instead of a full sync_reg/store_reg process). Patch 2 provides a selftest patch

[PATCH v2 1/2] KVM: s390: load guest access registers in MEM_OP ioctl

2024-02-15 Thread Eric Farman
The routine ar_translation() can be reached by both the instruction intercept path (where the access registers had been loaded with the guest register contents), and the MEM_OP ioctls (which hadn't). This latter case means that any ALET the guest expects to be used would be ignored. Fix this by

[PATCH v2 2/2] KVM: s390: selftests: memop: add a simple AR test

2024-02-15 Thread Eric Farman
There is a selftest that checks for an (expected) error when an invalid AR is specified, but not one that exercises the AR path. Add a simple test that mirrors the vanilla write/read test while providing an AR. An AR that contains zero will direct the CPU to use the primary address space normally

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Nathan Lynch
Michal Suchánek writes: > On Thu, Feb 15, 2024 at 01:13:34PM -0600, Nathan Lynch wrote: >> Michal Suchanek writes: >> > >> > Without the headers the tests don't build. >> > >> > Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd") >> > Fixes: 76b2ec3faeaa ("powerpc/selftests: Add

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Michal Suchánek
On Thu, Feb 15, 2024 at 01:13:34PM -0600, Nathan Lynch wrote: > Michal Suchanek writes: > > > > Without the headers the tests don't build. > > > > Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd") > > Fixes: 76b2ec3faeaa ("powerpc/selftests: Add test for papr-sysparm") > >

Re: [PATCH 02/31] ntsync: Introduce NTSYNC_IOC_CREATE_SEM.

2024-02-15 Thread Elizabeth Figura
On Thursday, 15 February 2024 01:28:32 CST Greg Kroah-Hartman wrote: > On Wed, Feb 14, 2024 at 05:36:38PM -0600, Elizabeth Figura wrote: > > This corresponds to the NT syscall NtCreateSemaphore(). > > > > Semaphores are one of three types of object to be implemented in this > > driver, > > the

Re: [PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Nathan Lynch
Michal Suchanek writes: > > Without the headers the tests don't build. > > Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd") > Fixes: 76b2ec3faeaa ("powerpc/selftests: Add test for papr-sysparm") > Signed-off-by: Michal Suchanek > --- >

Re: [PATCH 01/31] ntsync: Introduce the ntsync driver and character device.

2024-02-15 Thread Elizabeth Figura
On Wednesday, 14 February 2024 19:57:23 CST Randy Dunlap wrote: > Hi, > > On 2/14/24 15:36, Elizabeth Figura wrote: > > ntsync uses a misc device as the simplest and least intrusive uAPI > > interface. > > > > Each file description on the device represents an isolated NT instance, > > intended

[PATCH net 13/13] selftests: mptcp: diag: unique 'cestab' subtest names

2024-02-15 Thread Matthieu Baerts (NGI0)
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name. Some 'cestab' subtests from the diag selftest had the same names, e.g.: chk 0 cestab Now the previous value is taken, to have different names, e.g.: chk 2->0

Re: [PATCH v4 5/5] KVM: selftests: aarch64: Add invalid filter test in pmu_event_filter_test

2024-02-15 Thread Eric Auger
Hi Shaoqin, On 2/2/24 03:56, Shaoqin Huang wrote: > Add the invalid filter test includes sets the filter beyond the event s/includes/which > space and sets the invalid action to double check if the > KVM_ARM_VCPU_PMU_V3_FILTER will return the expected error. > > Signed-off-by: Shaoqin Huang >

[PATCH net 12/13] selftests: mptcp: diag: unique 'in use' subtest names

2024-02-15 Thread Matthieu Baerts (NGI0)
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name. Some 'in use' subtests from the diag selftest had the same names, e.g.: chk 0 msk in use after flush Now the previous value is taken, to have different names, e.g.: chk

[PATCH net 11/13] selftests: mptcp: userspace_pm: unique subtest names

2024-02-15 Thread Matthieu Baerts (NGI0)
It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated names. Some subtests from the userspace_pm selftest had the same names. That's because different subflows are created (and deleted) between the same pair of IP addresses. Simply adding

[PATCH net 10/13] selftests: mptcp: simult flows: fix some subtest names

2024-02-15 Thread Matthieu Baerts (NGI0)
The selftest was correctly recording all the results, but the 'reverse direction' part was missing in the name when needed. It is important to have a unique (sub)test name in TAP, because some CI environments drop tests with duplicated name. Fixes: 675d99338e7a ("selftests: mptcp: simult flows:

[PATCH net 09/13] selftests: mptcp: diag: fix bash warnings on older kernels

2024-02-15 Thread Matthieu Baerts (NGI0)
Since the 'Fixes' commit mentioned below, the command that is executed in __chk_nr() helper can return nothing if the feature is not supported. This is the case when the MPTCP CURRESTAB counter is not supported. To avoid this warning ... ./diag.sh: line 65: [: !=: unary operator expected ...

[PATCH net 08/13] selftests: mptcp: pm nl: avoid error msg on older kernels

2024-02-15 Thread Matthieu Baerts (NGI0)
Since the 'Fixes' commit mentioned below, and if the kernel being tested doesn't support the 'fullmesh' flag, this error will be printed: netlink error -22 (Invalid argument) ./pm_nl_ctl: bailing out due to netlink error[s] But that can be normal if the kernel doesn't support the feature, no

[PATCH net 07/13] selftests: mptcp: pm nl: also list skipped tests

2024-02-15 Thread Matthieu Baerts (NGI0)
If the feature is not supported by older kernels, and instead of just ignoring some tests, we should mark them as skipped, so we can still track them. Fixes: d8ac11f9 ("selftests: mptcp: pm_netlink: format subtests results in TAP") Cc: sta...@vger.kernel.org Reviewed-by: Geliang Tang

[PATCH net 06/13] mptcp: fix duplicate subflow creation

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Paolo Abeni Fullmesh endpoints could end-up unexpectedly generating duplicate subflows - same local and remote addresses - when multiple incoming ADD_ADDR are processed before the PM creates the subflow for the local endpoints. Address the issue explicitly checking for duplicates at

[PATCH net 05/13] mptcp: fix data races on remote_id

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Paolo Abeni Similar to the previous patch, address the data race on remote_id, adding the suitable ONCE annotations. Fixes: bedee0b56113 ("mptcp: address lookup improvements") Cc: sta...@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts

[PATCH net 03/13] mptcp: fix lockless access in subflow ULP diag

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Paolo Abeni Since the introduction of the subflow ULP diag interface, the dump callback accessed all the subflow data with lockless. We need either to annotate all the read and write operation accordingly, or acquire the subflow socket lock. Let's do latter, even if slower, to avoid a

[PATCH net 04/13] mptcp: fix data races on local_id

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Paolo Abeni The local address id is accessed lockless by the NL PM, add all the required ONCE annotation. There is a caveat: the local id can be initialized late in the subflow life-cycle, and its validity is controlled by the local_id_valid flag. Remove such flag and encode the validity

[PATCH net 02/13] mptcp: add needs_id for netlink appending addr

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Geliang Tang Just the same as userspace PM, a new parameter needs_id is added for in-kernel PM mptcp_pm_nl_append_new_local_addr() too. Add a new helper mptcp_pm_has_addr_attr_id() to check whether an address ID is set from PM or not. In mptcp_pm_nl_get_local_id(), needs_id is always

[PATCH net 01/13] mptcp: add needs_id for userspace appending addr

2024-02-15 Thread Matthieu Baerts (NGI0)
From: Geliang Tang When userspace PM requires to create an ID 0 subflow in "userspace pm create id 0 subflow" test like this: userspace_pm_add_sf $ns2 10.0.3.2 0 An ID 1 subflow, in fact, is created. Since in mptcp_pm_nl_append_new_local_addr(), 'id 0' will be treated as no ID is set

[PATCH net 00/13] mptcp: misc. fixes for v6.8

2024-02-15 Thread Matthieu Baerts (NGI0)
8 ++- tools/testing/selftests/net/mptcp/simult_flows.sh | 3 +- tools/testing/selftests/net/mptcp/userspace_pm.sh | 4 +- 12 files changed, 116 insertions(+), 68 deletions(-) --- base-commit: c40c0d3a768c78a023a72fb2ceea00743e3a695d change-id: 20240215-upstream-net-20240215-misc-fixes-03815ec14d

[PATCH 3/3] selftests: livepatch: Add initial .gitignore

2024-02-15 Thread Marcos Paulo de Souza
Ignore the binary used to test livepatching a syscall. Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/livepatch/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/livepatch/.gitignore b/tools/testing/selftests/livepatch/.gitignore new file

[PATCH 2/3] selftests: lib.mk: Simplify TEST_GEN_MODS_DIR handling

2024-02-15 Thread Marcos Paulo de Souza
We don't need new targets only to run two make modules and make clean. We can test if TEST_GEN_MODS_DIR is specified, and then run the commands. Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/lib.mk | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff

[PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR

2024-02-15 Thread Marcos Paulo de Souza
The directory itself doesn't need have path handling, since it's only to mean where is the directory that contains modules to be built. Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/lib.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/testing/selftests/lib.mk

[PATCH 0/3] Improvements to livepatch kselftests on top of kselftest-next

2024-02-15 Thread Marcos Paulo de Souza
/selftests/livepatch/.gitignore | 1 + 2 files changed, 8 insertions(+), 12 deletions(-) --- base-commit: 345e8abe4c355bc24bab3f4a5634122e55be8665 change-id: 20240215-lp-selftests-fixes-7d4bab3c0712 Best regards, -- Marcos Paulo de Souza

Re: [KTAP V2 PATCH v3] ktap_v2: add test metadata

2024-02-15 Thread Kees Cook
On Thu, Feb 15, 2024 at 05:18:59PM +, Rae Moar wrote: > Add specification for test metadata to the KTAP v2 spec. > > KTAP v1 only specifies the output format of very basic test information: > test result and test name. Any additional test information either gets > added to general diagnostic

[KTAP V2 PATCH v3] ktap_v2: add test metadata

2024-02-15 Thread Rae Moar
Add specification for test metadata to the KTAP v2 spec. KTAP v1 only specifies the output format of very basic test information: test result and test name. Any additional test information either gets added to general diagnostic data or is not included in the output at all. The purpose of KTAP

[PATCH] selftests: powerpc: Add header symlinks for building papr character device tests

2024-02-15 Thread Michal Suchanek
From: root Without the headers the tests don't build. Fixes: 9118c5d32bdd ("powerpc/selftests: Add test for papr-vpd") Fixes: 76b2ec3faeaa ("powerpc/selftests: Add test for papr-sysparm") Signed-off-by: Michal Suchanek --- tools/testing/selftests/powerpc/include/asm/papr-miscdev.h | 1 +

[PATCH net 1/5] tls: break out of main loop when PEEK gets a non-data record

2024-02-15 Thread Sabrina Dubroca
PEEK needs to leave decrypted records on the rx_list so that we can receive them later on, so it jumps back into the async code that queues the skb. Unfortunately that makes us skip the TLS_RECORD_TYPE_DATA check at the bottom of the main loop, so if two records of the same (non-DATA) type are

[PATCH net 4/5] selftests: tls: add test for merging of same-type control messages

2024-02-15 Thread Sabrina Dubroca
Two consecutive control messages of the same type should never be merged into one large received blob of data. Signed-off-by: Sabrina Dubroca --- tools/testing/selftests/net/tls.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/tools/testing/selftests/net/tls.c

[PATCH net 3/5] tls: don't skip over different type records from the rx_list

2024-02-15 Thread Sabrina Dubroca
If we queue 3 records: - record 1, type DATA - record 2, some other type - record 3, type DATA and do a recv(PEEK), the rx_list will contain the first two records. The next large recv will walk through the rx_list and copy data from record 1, then stop because record 2 is a different type.

[PATCH net 2/5] tls: stop recv() if initial process_rx_list gave us non-DATA

2024-02-15 Thread Sabrina Dubroca
If we have a non-DATA record on the rx_list and another record of the same type still on the queue, we will end up merging them: - process_rx_list copies the non-DATA record - we start the loop and process the first available record since it's of the same type - we break out of the loop

[PATCH net 5/5] selftests: tls: add test for peeking past a record of a different type

2024-02-15 Thread Sabrina Dubroca
If we queue 3 records: - record 1, type DATA - record 2, some other type - record 3, type DATA the current code can look past the 2nd record and merge the 2 data records. Signed-off-by: Sabrina Dubroca --- tools/testing/selftests/net/tls.c | 19 +++ 1 file changed, 19

[PATCH net 0/5] tls: fixes for record type handling with PEEK

2024-02-15 Thread Sabrina Dubroca
There are multiple bugs in tls_sw_recvmsg's handling of record types when MSG_PEEK flag is used, which can lead to incorrectly merging two records: - consecutive non-DATA records shouldn't be merged, even if they're the same type (partly handled by the test at the end of the main loop) -

Re: [PATCH v10 19/25] integrity: Move integrity_kernel_module_request() to IMA

2024-02-15 Thread Roberto Sassu
On Thu, 2024-02-15 at 11:31 +0100, Roberto Sassu wrote: > From: Roberto Sassu > > In preparation for removing the 'integrity' LSM, move > integrity_kernel_module_request() to IMA, and rename it to > ima_kernel_module_request(). Rewrite the function documentation, to explain > better what the

[PATCH v13 15/21] KVM: selftests: re-map Xen's vcpu_info using HVA rather than GPA

2024-02-15 Thread Paul Durrant
From: Paul Durrant If the relevant capability (KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA) is present then re-map vcpu_info using the HVA part way through the tests to make sure then there is no functional change. Signed-off-by: Paul Durrant Reviewed-by: David Woodhouse --- Cc: Sean Christopherson

[PATCH v13 11/21] KVM: x86/xen: re-initialize shared_info if guest (32/64-bit) mode is set

2024-02-15 Thread Paul Durrant
From: Paul Durrant If the shared_info PFN cache has already been initialized then the content of the shared_info page needs to be re-initialized whenever the guest mode is (re)set. Setting the guest mode is either done explicitly by the VMM via the KVM_XEN_ATTR_TYPE_LONG_MODE attribute, or

[PATCH v13 21/21] KVM: pfncache: rework __kvm_gpc_refresh() to fix locking issues

2024-02-15 Thread Paul Durrant
From: David Woodhouse This function can race with kvm_gpc_deactivate(), which does not take the ->refresh_lock. This means kvm_gpc_deactivate() can wipe the ->pfn and ->khva fields, and unmap the latter, while hva_to_pfn_retry() has temporarily dropped its write lock on gpc->lock. Then if

[PATCH v13 17/21] KVM: x86/xen: split up kvm_xen_set_evtchn_fast()

2024-02-15 Thread Paul Durrant
From: Paul Durrant The implementation of kvm_xen_set_evtchn_fast() is a rather lengthy piece of code that performs two operations: updating of the shared_info evtchn_pending mask, and updating of the vcpu_info evtchn_pending_sel mask. Introduce a separate function to perform each of those

[PATCH v13 10/21] KVM: x86/xen: separate initialization of shared_info cache and content

2024-02-15 Thread Paul Durrant
From: Paul Durrant A subsequent patch will allow shared_info to be initialized using either a GPA or a user-space (i.e. VMM) HVA. To make that patch cleaner, separate the initialization of the shared_info content from the activation of the pfncache. Signed-off-by: Paul Durrant Reviewed-by:

[PATCH v13 14/21] KVM: selftests: map Xen's shared_info page using HVA rather than GFN

2024-02-15 Thread Paul Durrant
From: Paul Durrant Using the HVA of the shared_info page is more efficient, so if the capability (KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA) is present use that method to do the mapping. NOTE: Have the juggle_shinfo_state() thread map and unmap using both GFN and HVA, to make sure the older

[PATCH v13 16/21] KVM: x86/xen: advertize the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA capability

2024-02-15 Thread Paul Durrant
From: Paul Durrant Now that all relevant kernel changes and selftests are in place, enable the new capability. Signed-off-by: Paul Durrant Reviewed-by: David Woodhouse --- Cc: Sean Christopherson Cc: Paolo Bonzini Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen

[PATCH v13 18/21] KVM: x86/xen: don't block on pfncache locks in kvm_xen_set_evtchn_fast()

2024-02-15 Thread Paul Durrant
From: Paul Durrant As described in [1] compiling with CONFIG_PROVE_RAW_LOCK_NESTING shows that kvm_xen_set_evtchn_fast() is blocking on pfncache locks in IRQ context. There is only actually blocking with PREEMPT_RT because the locks will turned into mutexes. There is no 'raw' version of rwlock_t

[PATCH v13 13/21] KVM: x86/xen: allow vcpu_info to be mapped by fixed HVA

2024-02-15 Thread Paul Durrant
From: Paul Durrant If the guest does not explicitly set the GPA of vcpu_info structure in memory then, for guests with 32 vCPUs or fewer, the vcpu_info embedded in the shared_info page may be used. As described in a previous commit, the shared_info page is an overlay at a fixed HVA within the

[PATCH v13 19/21] KVM: pfncache: check the need for invalidation under read lock first

2024-02-15 Thread Paul Durrant
From: Paul Durrant When processing mmu_notifier invalidations for gpc caches, pre-check for overlap with the invalidation event while holding gpc->lock for read, and only take gpc->lock for write if the cache needs to be invalidated. Doing a pre-check without taking gpc->lock for write avoids

[PATCH v13 12/21] KVM: x86/xen: allow shared_info to be mapped by fixed HVA

2024-02-15 Thread Paul Durrant
From: Paul Durrant The shared_info page is not guest memory as such. It is a dedicated page allocated by the VMM and overlaid onto guest memory in a GFN chosen by the guest and specified in the XENMEM_add_to_physmap hypercall. The guest may even request that shared_info be moved from one GFN to

[PATCH v13 20/21] KVM: x86/xen: allow vcpu_info content to be 'safely' copied

2024-02-15 Thread Paul Durrant
From: Paul Durrant If the guest sets an explicit vcpu_info GPA then, for any of the first 32 vCPUs, the content of the default vcpu_info in the shared_info page must be copied into the new location. Because this copy may race with event delivery (which updates the 'evtchn_pending_sel' field in

[PATCH v13 00/21] KVM: xen: update shared_info and vcpu_info handling

2024-02-15 Thread Paul Durrant
From: Paul Durrant This series contains a new patch from Sean added since v12 [1]: * KVM: s390: Refactor kvm_is_error_gpa() into kvm_is_gpa_in_memslot() This frees up the function name kvm_is_error_gpa() such that it can then be re-defined in: * KVM: pfncache: allow a cache to be activated

[PATCH v13 06/21] KVM: pfncache: stop open-coding offset_in_page()

2024-02-15 Thread Paul Durrant
From: Paul Durrant Some code in pfncache uses offset_in_page() but in other places it is open- coded. Use offset_in_page() consistently everywhere. Signed-off-by: Paul Durrant Reviewed-by: David Woodhouse --- Cc: Sean Christopherson Cc: Paolo Bonzini Cc: David Woodhouse v8: - New in this

[PATCH v13 09/21] KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA

2024-02-15 Thread Paul Durrant
From: Paul Durrant Some pfncache pages may actually be overlays on guest memory that have a fixed HVA within the VMM. It's pointless to invalidate such cached mappings if the overlay is moved so allow a cache to be activated directly with the HVA to cater for such cases. A subsequent patch will

[PATCH v13 07/21] KVM: pfncache: include page offset in uhva and use it consistently

2024-02-15 Thread Paul Durrant
From: Paul Durrant Currently the pfncache page offset is sometimes determined using the gpa and sometimes the khva, whilst the uhva is always page-aligned. After a subsequent patch is applied the gpa will not always be valid so adjust the code to include the page offset in the uhva and use it

[PATCH v13 08/21] KVM: s390: Refactor kvm_is_error_gpa() into kvm_is_gpa_in_memslot()

2024-02-15 Thread Paul Durrant
From: Sean Christopherson Rename kvm_is_error_gpa() to kvm_is_gpa_in_memslot() and invert the polarity accordingly in order to (a) free up kvm_is_error_gpa() to match with kvm_is_error_{hva,page}(), and (b) to make it more obvious that the helper is doing a memslot lookup, i.e. not simply

[PATCH v13 05/21] KVM: pfncache: remove KVM_GUEST_USES_PFN usage

2024-02-15 Thread Paul Durrant
From: Paul Durrant As noted in [1] the KVM_GUEST_USES_PFN usage flag is never set by any callers of kvm_gpc_init(), which also makes the 'vcpu' argument redundant. Moreover, all existing callers specify KVM_HOST_USES_PFN so the usage check in hva_to_pfn_retry() and hence the 'usage' argument to

[PATCH v13 01/21] KVM: pfncache: Add a map helper function

2024-02-15 Thread Paul Durrant
From: Paul Durrant There is a pfncache unmap helper but mapping is open-coded. Arguably this is fine because mapping is done in only one place, hva_to_pfn_retry(), but adding the helper does make that function more readable. No functional change intended. Signed-off-by: Paul Durrant

[PATCH v13 04/21] KVM: pfncache: add a mark-dirty helper

2024-02-15 Thread Paul Durrant
From: Paul Durrant At the moment pages are marked dirty by open-coded calls to mark_page_dirty_in_slot(), directly deferefencing the gpa and memslot from the cache. After a subsequent patch these may not always be set so add a helper now so that caller will protected from the need to know about

[PATCH v13 03/21] KVM: x86/xen: mark guest pages dirty with the pfncache lock held

2024-02-15 Thread Paul Durrant
From: Paul Durrant Sampling gpa and memslot from an unlocked pfncache may yield inconsistent values so, since there is no problem with calling mark_page_dirty_in_slot() with the pfncache lock held, relocate the calls in kvm_xen_update_runstate_guest() and kvm_xen_inject_pending_events()

[PATCH v13 02/21] KVM: pfncache: remove unnecessary exports

2024-02-15 Thread Paul Durrant
From: Paul Durrant There is no need for the existing kvm_gpc_XXX() functions to be exported. Clean up now before additional functions are added in subsequent patches. Signed-off-by: Paul Durrant Reviewed-by: David Woodhouse --- Cc: Sean Christopherson Cc: David Woodhouse Cc: Paolo Bonzini

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-15 Thread Benjamin Tissoires
On Feb 14 2024, Benjamin Tissoires wrote: > They are implemented as a kfunc, which means a little bit of tweaks in > the verifier. > > Signed-off-by: Benjamin Tissoires > > --- > > changes in v2 (compared to the one attaches to v1 0/9): > - make use of a kfunc > - add a (non-used)

Re: [PATCH v9 12/25] security: Introduce file_post_open hook

2024-02-15 Thread Paul Moore
On Thu, Feb 15, 2024 at 3:18 AM Mimi Zohar wrote: > On Wed, 2024-02-14 at 16:21 -0500, Paul Moore wrote: > > I'm not a big fan of sharing topic branches across different subsystem > > trees, I'd much rather just agree that one tree or another takes the > > patchset and the others plan

Re: [PATCH v4 4/5] KVM: selftests: aarch64: Introduce pmu_event_filter_test

2024-02-15 Thread Eric Auger
Hi Shaoqin, On 2/2/24 09:34, Oliver Upton wrote: > On Thu, Feb 01, 2024 at 09:56:53PM -0500, Shaoqin Huang wrote: >> Introduce pmu_event_filter_test for arm64 platforms. The test configures >> PMUv3 for a vCPU, and sets different pmu event filters for the vCPU, and >> check if the guest can see

[PATCH resend] selftests: timers: clocksource-switch: Adapt progress to kselftest framework

2024-02-15 Thread Geert Uytterhoeven
When adapting the test to the kselftest framework, a few printf() calls indicating test progress were not updated. Fix this by replacing these printf() calls by ksft_print_msg() calls. Fixes: ce7d101750ff8450 ("selftests: timers: clocksource-switch: adapt to kselftest framework") Signed-off-by:

Re: [PATCH] papr_vpd.c: calling devfd before get_system_loc_code

2024-02-15 Thread Michael Ellerman
On Wed, 31 Jan 2024 18:38:59 +0530, R Nageswara Sastry wrote: > Calling get_system_loc_code before checking devfd and errno - fails the test > when the device is not available, expected a SKIP. > Change the order of 'SKIP_IF_MSG' correctly SKIP when the /dev/papr-vpd device > is not available. >

[PATCH] selftests/bpf: Move test_dev_cgroup to prog_tests

2024-02-15 Thread Muhammad Usama Anjum
Move test_dev_cgroup to prog_tests to be able to run it with test_progs. Replace dev_cgroup.bpf.o with skel header file, dev_cgroup.skel.h and load program from it accourdingly. ./test_progs -t test_dev_cgroup mknod: /tmp/test_dev_cgroup_null: Operation not permitted 64+0 records in 64+0

[PATCH v10 25/25] integrity: Remove LSM

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu Since now IMA and EVM use their own integrity metadata, it is safe to remove the 'integrity' LSM, with its management of integrity metadata. Keep the iint.c file only for loading IMA and EVM keys at boot, and for creating the integrity directory in securityfs (we need to

[PATCH v10 24/25] ima: Make it independent from 'integrity' LSM

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu Make the 'ima' LSM independent from the 'integrity' LSM by introducing IMA own integrity metadata (ima_iint_cache structure, with IMA-specific fields from the integrity_iint_cache structure), and by managing it directly from the 'ima' LSM. Create ima_iint.c and introduce the

[PATCH v10 23/25] evm: Make it independent from 'integrity' LSM

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu Define a new structure for EVM-specific metadata, called evm_iint_cache, and embed it in the inode security blob. Introduce evm_iint_inode() to retrieve metadata, and register evm_inode_alloc_security() for the inode_alloc_security LSM hook, to initialize the structure

[PATCH v10 22/25] evm: Move to LSM infrastructure

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu As for IMA, move hardcoded EVM function calls from various places in the kernel to the LSM infrastructure, by introducing a new LSM named 'evm' (last and always enabled like 'ima'). The order in the Makefile ensures that 'evm' hooks are executed after 'ima' ones. Make EVM

[PATCH v10 21/25] ima: Move IMA-Appraisal to LSM infrastructure

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu A few additional IMA hooks are needed to reset the cached appraisal status, causing the file's integrity to be re-evaluated on next access. Register these IMA-appraisal only functions separately from the rest of IMA functions, as appraisal is a separate feature not

[PATCH v10 20/25] ima: Move to LSM infrastructure

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu Move hardcoded IMA function calls (not appraisal-specific functions) from various places in the kernel to the LSM infrastructure, by introducing a new LSM named 'ima' (at the end of the LSM list and always enabled like 'integrity'). Having IMA before EVM in the Makefile is

[PATCH v10 19/25] integrity: Move integrity_kernel_module_request() to IMA

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for removing the 'integrity' LSM, move integrity_kernel_module_request() to IMA, and rename it to ima_kernel_module_request(). Rewrite the function documentation, to explain better what the problem is. Compile it conditionally if

[PATCH v10 18/25] security: Introduce key_post_create_or_update hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the key_post_create_or_update hook. Depending on policy, IMA measures the key content after creation or update, so that remote verifiers are aware of the operation. Other LSMs could similarly take

[PATCH v10 17/25] security: Introduce inode_post_remove_acl hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the inode_post_remove_acl hook. At inode_remove_acl hook, EVM verifies the file's existing HMAC value. At inode_post_remove_acl, EVM re-calculates the file's HMAC with the passed POSIX ACL removed and

[PATCH v10 16/25] security: Introduce inode_post_set_acl hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the inode_post_set_acl hook. At inode_set_acl hook, EVM verifies the file's existing HMAC value. At inode_post_set_acl, EVM re-calculates the file's HMAC based on the modified POSIX ACL and other file

[PATCH v10 15/25] security: Introduce inode_post_create_tmpfile hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the inode_post_create_tmpfile hook. As temp files can be made persistent, treat new temp files like other new files, so that the file hash is calculated and stored in the security xattr. LSMs could

[PATCH v10 14/25] security: Introduce path_post_mknod hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the path_post_mknod hook. IMA-appraisal requires all existing files in policy to have a file hash/signature stored in security.ima. An exception is made for empty files created by mknod, by tagging

[PATCH v10 13/25] security: Introduce file_release hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation for moving IMA and EVM to the LSM infrastructure, introduce the file_release hook. IMA calculates at file close the new digest of the file content and writes it to security.ima, so that appraisal at next file access succeeds. The new hook cannot return an

[PATCH v10 12/25] security: Introduce file_post_open hook

2024-02-15 Thread Roberto Sassu
From: Roberto Sassu In preparation to move IMA and EVM to the LSM infrastructure, introduce the file_post_open hook. Also, export security_file_post_open() for NFS. Based on policy, IMA calculates the digest of the file content and extends the TPM with the digest, verifies the file's integrity

  1   2   >