aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-02-28selftests: rtnetlink: use internal netns switch for ip commandsDavid Ahern1-61/+61
'ip' can switch network namespaces internally and then run a given command relative to that namespace without the need to fork and exec another ip instance. Update all references of the form: ip netns exec "$testns" ip ... to ip -netns "$testns" ... Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-27selftests: pmtu: add explicit tests for PMTU exceptions cleanupPaolo Abeni1-1/+67
Add a couple of new tests, explicitly checking that the kernel timely releases PMTU exceptions on related device removal. This is mostly a regression test vs the issue fixed by commit f5b51fe804ec ("ipv6: route: purge exception on removal") Only 2 new test cases have been added, instead of extending all the existing ones, because the reproducer requires executing several commands and would slow down too much the tests otherwise. v2 -> v3: - more cleanup, still from Stefano v1 -> v2: - several script cleanups, as suggested by Stefano Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-27selftests: pmtu: disable DAD in all namespacesPaolo Abeni1-15/+13
Otherwise, the configured IPv6 address could be still "tentative" at test time, possibly causing tests failures. We can also drop some sleep along the code and decrease the timeout for most commands so that the test runtime decreases. v1 -> v2: - fix comment (Stefano) Fixes: d1f1b9cbf34c ("selftests: net: Introduce first PMTU test") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-27tools/bpf: selftests: add map lookup to test_map_in_map bpf progYonghong Song1-0/+4
The bpf_map_lookup_elem is added in the bpf program. Without previous patch, the test change will trigger the following error: $ ./test_maps ... ; value_p = bpf_map_lookup_elem(map, &key); 20: (bf) r1 = r7 21: (bf) r2 = r8 22: (85) call bpf_map_lookup_elem#1 ; if (!value_p || *value_p != 123) 23: (15) if r0 == 0x0 goto pc+16 R0=map_value(id=2,off=0,ks=4,vs=4,imm=0) R6=inv1 R7=map_ptr(id=0,off=0,ks=4,vs=4,imm=0) R8=fp-8,call_-1 R10=fp0,call_-1 fp-8=mmmmmmmm ; if (!value_p || *value_p != 123) 24: (61) r1 = *(u32 *)(r0 +0) R0=map_value(id=2,off=0,ks=4,vs=4,imm=0) R6=inv1 R7=map_ptr(id=0,off=0,ks=4,vs=4,imm=0) R8=fp-8,call_-1 R10=fp0,call_-1 fp-8=mmmmmmmm bpf_spin_lock cannot be accessed directly by load/store With the kernel fix in the previous commit, the error goes away. Signed-off-by: Yonghong Song <yhs@fb.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-02-27netfilter: nat: merge nf_nat_ipv4,6 into nat coreFlorian Westphal1-2/+1
before: text data bss dec hex filename 16566 1576 4136 22278 5706 nf_nat.ko 3598 844 0 4442 115a nf_nat_ipv6.ko 3187 844 0 4031 fbf nf_nat_ipv4.ko after: text data bss dec hex filename 22948 1612 4136 28696 7018 nf_nat.ko ... with ipv4/v6 nat now provided directly via nf_nat.ko. Also changes: ret = nf_nat_ipv4_fn(priv, skb, state); if (ret != NF_DROP && ret != NF_STOLEN && into if (ret != NF_ACCEPT) return ret; everywhere. The nat hooks never should return anything other than ACCEPT or DROP (and the latter only in rare error cases). The original code uses multi-line ANDing including assignment-in-if: if (ret != NF_DROP && ret != NF_STOLEN && !(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) && (ct = nf_ct_get(skb, &ctinfo)) != NULL) { I removed this while moving, breaking those in separate conditionals and moving the assignments into extra lines. checkpatch still generates some warnings: 1. Overly long lines (of moved code). Breaking them is even more ugly. so I kept this as-is. 2. use of extern function declarations in a .c file. This is necessary evil, we must call nf_nat_l3proto_register() from the nat core now. All l3proto related functions are removed later in this series, those prototypes are then removed as well. v2: keep empty nf_nat_ipv6_csum_update stub for CONFIG_IPV6=n case. v3: remove IS_ENABLED(NF_NAT_IPV4/6) tests, NF_NAT_IPVx toggles are removed here. v4: also get rid of the assignments in conditionals. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2019-02-26tc-testing: gitignore, ignore local tdc config fileVlad Buslov1-0/+1
Comment in tdc_config.py recommends putting customizations in tdc_config_local.py file that wasn't included in gitignore. Add the local config file to gitignore. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-26tools: selftests: rtnetlink: add testcases for vxlan flag setsRoopa Prabhu1-0/+52
This patch extends rtnetlink.sh to cover some vxlan flag netlink attribute sets. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-26selftests/powerpc: Remove duplicate headerMichael Ellerman1-1/+0
Remove duplicate headers which are included twice. Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> [mpe: Split out of larger patch] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-02-25selftests/bpf: make sure signal interrupts BPF_PROG_TEST_RUNStanislav Fomichev1-0/+44
Simple test that I used to reproduce the issue in the previous commit: Do BPF_PROG_TEST_RUN with max iterations, each program is 4096 simple move instructions. File alarm in 0.1 second and check that bpf_prog_test_run is interrupted (i.e. test doesn't hang). Note: reposting this for bpf-next to avoid linux-next conflict. In this version I test both BPF_PROG_TYPE_SOCKET_FILTER (which uses generic bpf_test_run implementation) and BPF_PROG_TYPE_FLOW_DISSECTOR (which has it own loop with preempt handling in bpf_prog_test_run_flow_dissector). Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-02-25selftests/ftrace: Handle the absence of tputJuerg Haefliger1-2/+2
In environments where tput is not available, we get the following error $ ./ftracetest: 163: [: Illegal number: because ncolors is an empty string. Fix that by setting it to 0 if the tput command fails. Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Juerg Haefliger <juergh@canonical.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-24selftests: mlxsw: spectrum-2: Add massive delta rehash testJiri Pirko1-0/+166
Do insertions and removal of filters during rehash in higher volumes. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: mlxsw: spectrum-2: Check migrate end traceJiri Pirko1-0/+8
Add checking of newly added trace. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: mlxsw: spectrum-2: Add IPv6 variant of simple delta rehash testJiri Pirko1-0/+71
Track the basic codepaths of delta rehash handling, using mlxsw tracepoints. Use IPv6 addresses. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify parallel replace/deleteVlad Buslov1-0/+26
Implement test that runs 5 instances of tc replace filter in parallel with 5 instances of tc del filter from same tp instance. Each instance uses its own filter handle and key range. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify parallel add/deleteVlad Buslov2-3/+49
Implement test that runs 5 instances of tc add filter in parallel with 5 instances of tc del filter from same tp instance. Each instance uses its own filter handle and key range. Extend tdc_multibatch.py with additional options required to implement the test: common prefix for all generated batch files, first value of filter handle range, MAC address prefix modifier. These are necessary to allow creating batch files with unique keys and handle ranges with multiple invocation of tdc_multibatch.py helper script. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify concurrent deleteVlad Buslov1-0/+25
Implement test that verifies concurrent deletion of rules by executing 10 tc instances that delete flower filters in same handle range. In this case only one tc instance succeeds in deleting a filter with particular handle. To mitigate expected failures of all other instances, run tc with 'force' option to continue processing batch file in case of errors and expect xargs to return code '123' that indicates that invocation of command(s) exited with error in range 1-125. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify concurrent replaceVlad Buslov2-1/+33
Implement test that verifies concurrent replacement of rules by executing 10 tc instances that replace flower filters in same handle range. Extend tdc_multibatch.py script with new optional CLI argument that is used to generate all batch files with same filter handle range. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify parallel rules replaceVlad Buslov1-0/+25
Implement test that verifies parallel rules replacement by adding 1 million flower filters and then replacing them with 10 concurrent tc instances. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify parallel rules deletionVlad Buslov1-0/+25
Implement test that verifies parallel rules deletion by adding 1 million flower filters and then deleting them with 10 concurrent tc instances. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: concurrency: add test to verify parallel rules insertionVlad Buslov3-0/+64
Implement test that verifies parallel rules insertion by adding 1 million flower filters with 10 concurrent tc instances. Put it to standalone 'concurrency' category. Implement tdc_multibatch.py helper script that is used to generate multiple batch files for concurrent tc execution. Extend config with new 'BATCH_DIR' variable to specify temporary output directory that is used to store batch files generated by tdc_multibatch.py. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24selftests: tdc_batch.py: add options needed for concurrency testsVlad Buslov1-4/+54
Extend tdc_batch.py with several optional CLI arguments that are used for implementation of concurrency tests in following patches in this set: - Add optional argument to specify range of filter handles used in batch file [fitler_handle, filter_handle+number). This is needed for testing filter deletion where it is necessary to know exact handles of configured filters. - Add optional argument to specify filter operation type (possible values are ['add', 'del', 'replace']) instead of hardcoded "add" value. This allows generation of batches for filter addition, deletion and replacement. - Add optional argument to allow user to change mac address prefix that is used for all filters in batch. This is necessary to allow generating multiple batches with unique flower classifier keys. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-24Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller2-0/+11
Three conflicts, one of which, for marvell10g.c is non-trivial and requires some follow-up from Heiner or someone else. The issue is that Heiner converted the marvell10g driver over to use the generic c45 code as much as possible. However, in 'net' a bug fix appeared which makes sure that a new local mask (MDIO_AN_10GBT_CTRL_ADV_NBT_MASK) with value 0x01e0 is cleared. Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-23selftests: fib_tests: sleep after changing carrier. again.Thadeu Lima de Souza Cascardo1-0/+1
Just like commit e2ba732a1681 ("selftests: fib_tests: sleep after changing carrier"), wait one second to allow linkwatch to propagate the carrier change to the stack. There are two sets of carrier tests. The first slept after the carrier was set to off, and when the second set ran, it was likely that the linkwatch would be able to run again without much delay, reducing the likelihood of a race. However, if you run 'fib_tests.sh -t carrier' on a loop, you will quickly notice the failures. Sleeping on the second set of tests make the failures go away. Cc: David Ahern <dsahern@gmail.com> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-22selftests/ftrace: Replace \e with \033Juerg Haefliger1-4/+4
The \e sequence character is not POSIX. Fix that by using \033 instead. Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Juerg Haefliger <juergh@canonical.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-22selftests/ftrace: Replace echo -e with printfJuerg Haefliger1-2/+7
echo -e is not POSIX. Depending on what /bin/sh is, we can get incorrect output like: $ -e -n [1] Basic trace file check $ -e [PASS] Fix that by using printf instead. Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Juerg Haefliger <juergh@canonical.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-22bpf, lpm: fix lookup bug in map_delete_elemAlban Crequy1-0/+10
trie_delete_elem() was deleting an entry even though it was not matching if the prefixlen was correct. This patch adds a check on matchlen. Reproducer: $ sudo bpftool map create /sys/fs/bpf/mylpm type lpm_trie key 8 value 1 entries 128 name mylpm flags 1 $ sudo bpftool map update pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 aa bb cc dd value hex 01 $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm key: 10 00 00 00 aa bb cc dd value: 01 Found 1 element $ sudo bpftool map delete pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 ff ff ff ff $ echo $? 0 $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm Found 0 elements A similar reproducer is added in the selftests. Without the patch: $ sudo ./tools/testing/selftests/bpf/test_lpm_map test_lpm_map: test_lpm_map.c:485: test_lpm_delete: Assertion `bpf_map_delete_elem(map_fd, key) == -1 && errno == ENOENT' failed. Aborted With the patch: test_lpm_map runs without errors. Fixes: e454cf595853 ("bpf: Implement map_delete_elem for BPF_MAP_TYPE_LPM_TRIE") Cc: Craig Gallek <kraig@google.com> Signed-off-by: Alban Crequy <alban@kinvolk.io> Acked-by: Craig Gallek <kraig@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-02-22tools/selftest/vm: allow choosing mem size and page size in map_hugetlbChristophe Leroy1-2/+27
map_hugetlb maps 256Mbytes of memory with default hugepage size. This patch allows the user to pass the size and page shift as an argument in order to use different size and page size. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-02-22powerpc/selftest: fix type of mftb() in null_syscallChristophe Leroy1-1/+1
All callers of mftb() expect 'unsigned long', and the function itself only returns lower part of the TB so it really is 'unsigned long' not 'unsigned long long' Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-02-20selftest/tls: Add test to verify received 'type' of non-data recordVakul Garg1-0/+14
Test case 'control_msg' has been updated to peek non-data record and then verify the type of record received. Subsequently, the same record is retrieved without MSG_PEEK flag in recvmsg(). Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-20tracing: Add hist trigger action 'expected fail' test caseTom Zanussi1-0/+30
Add a test case verifying that basic action combinations fail as expected. Link: http://lkml.kernel.org/r/1790bf93e01dbdfa1b4af945f42147d92bd565aa.1550100284.git.tom.zanussi@linux.intel.com Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-02-20tracing: Add alternative synthetic event trace action test caseTom Zanussi1-0/+42
Add a test case for the alternative trace(<synthetic_event, params) synthetic event generation syntax. Link: http://lkml.kernel.org/r/0616d18423ab1dfdbf333bce9c92ac4fa0779207.1550100284.git.tom.zanussi@linux.intel.com Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-02-20tracing: Add hist trigger onchange() handler test caseTom Zanussi1-0/+28
Add a test case verifying the basic functionality of the hist:onchange($var) handler. Link: http://lkml.kernel.org/r/bec87aa8ed7d81794510b3d465096a750c71fce7.1550100284.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-02-20tracing: Add hist trigger snapshot() action test caseTom Zanussi1-0/+43
Add a test case verifying the basic functionality of the hist:snapshot() action. Link: http://lkml.kernel.org/r/c0555f462cbfe56dadfec6e63e531e109bd72930.1550100284.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-02-20tracing: Add SPDX license GPL-2.0 license identifier to inter-event testcasesTom Zanussi8-0/+8
Apparently this directory was missed in the license cleanup process - add the missing identifiers to the trigger/inter-event test cases. Link: http://lkml.kernel.org/r/6f9828c2cfb0b378ebd217a39a1b44f063fc17fb.1550100284.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-02-18media: rc: rcmm decoder and encoderPatrick Lerda1-0/+9
media: add support for RCMM infrared remote controls. Signed-off-by: Patrick Lerda <patrick9876@free.fr> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-16Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-nextDavid S. Miller61-53/+1391
Alexei Starovoitov says: ==================== pull-request: bpf-next 2019-02-16 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) numerous libbpf API improvements, from Andrii, Andrey, Yonghong. 2) test all bpf progs in alu32 mode, from Jiong. 3) skb->sk access and bpf_sk_fullsock(), bpf_tcp_sock() helpers, from Martin. 4) support for IP encap in lwt bpf progs, from Peter. 5) remove XDP_QUERY_XSK_UMEM dead code, from Jan. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-16selftests: bpf: test_lwt_ip_encap: add negative tests.Peter Oskolkov1-23/+88
As requested by David Ahern: - add negative tests (no routes, explicitly unreachable destinations) to exercize error handling code paths; - do not exit on test failures, but instead print a summary of passed/failed tests at the end. Future patches will add TSO and VRF tests. Signed-off-by: Peter Oskolkov <posk@google.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-02-15selftests: forwarding: Add some missing configuration symbolsFlorian Fainelli1-0/+2
For the forwarding selftests to work, we need network namespaces when using veth/vrf otherwise ping/ping6 commands like these: ip vrf exec vveth0 /bin/ping 192.0.2.2 -c 10 -i 0.1 -w 5 will fail because network namespaces may not be enabled. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-15Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-3/+0
The netfilter conflicts were rather simple overlapping changes. However, the cls_tcindex.c stuff was a bit more complex. On the 'net' side, Cong is fixing several races and memory leaks. Whilst on the 'net-next' side we have Vlad adding the rtnl-ness support. What I've decided to do, in order to resolve this, is revert the conversion over to using a workqueue that Cong did, bringing us back to pure RCU. I did it this way because I believe that either Cong's races don't apply with have Vlad did things, or Cong will have to implement the race fix slightly differently. Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-14selftests: fix timestamping MakefileDeepa Dinamani1-3/+0
The clean target in the makefile conflicts with the generic kselftests lib.mk, and fails to properly remove the compiled test programs. Remove the redundant rule, the TEST_GEN_FILES will be already removed by the CLEAN macro in lib.mk. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: Shuah Khan <shuah@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-13selftests: bpf: add test_lwt_ip_encap selftestPeter Oskolkov3-1/+398
This patch adds a bpf self-test to cover BPF_LWT_ENCAP_IP mode in bpf_lwt_push_encap. Covered: - encapping in LWT_IN and LWT_XMIT - IPv4 and IPv6 A follow-up patch will add GSO and VRF-enabled tests. Signed-off-by: Peter Oskolkov <posk@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-02-13Merge tag 'tpmdd-next-20190213' of git://git.infradead.org/users/jjs/linux-tpmdd into next-tpmJames Morris6-0/+936
tpmdd updates for Linux v5.1 From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Clean up the transmission flow ============================== Cleaned up the whole transmission flow. Locking of the chip is now done in the level of tpm_try_get_ops() and tpm_put_ops() instead taking the chip lock inside tpm_transmit(). The nested calls inside tpm_transmit(), used with the resource manager, have been refactored out. Should make easier to perform more complex transactions with the TPM without making the subsystem a bigger mess (e.g. encrypted channel patches by James Bottomley). PPI 1.3 support =============== TPM PPI 1.3 introduces an additional optional command parameter that may be needed for some commands. Display the parameter if the command requires such a parameter. Only command 23 (SetPCRBanks) needs one. The PPI request file will show output like this then: # echo "23 16" > request # cat request 23 16 # echo "5" > request # cat request 5 Extend all PCR banks in IMA =========================== Instead of static PCR banks array, the array of available PCR banks is now allocated dynamically. The digests sizes are determined dynamically using a probe PCR read without relying crypto's static list of hash algorithms. This should finally make sealing of measurements in IMA safe and secure. TPM 2.0 selftests ================= Added a test suite to tools/testing/selftests/tpm2 previously outside of the kernel tree: https://github.com/jsakkine-intel/tpm2-scripts.
2019-02-13selftests: ir: skip when non-root user runs the testShuah Khan1-0/+5
Skip instead of fail when non-root user runs the test. Signed-off-by: Shuah Khan <shuah@kernel.org> Acked-by: Sean Young <sean@mess.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests: ir: skip when lirc device doesn't exist.Shuah Khan1-1/+1
Skip instead of fail when lirc device doesn't exist. Signed-off-by: Shuah Khan <shuah@kernel.org> Acked-by: Sean Young <sean@mess.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests: ir: fix warning: "%s" directive output may be truncated ’ directive output may be truncatedShuah Khan1-1/+3
Fix the following warning by sizing the buffer to max. of sysfs path max. size + d_name max. size. gcc -Wall -O2 -I../../../include/uapi ir_loopback.c -o ../tools/testing/selftests/ir/ir_loopback ir_loopback.c: In function ‘lirc_open’: ir_loopback.c:71:37: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 95 [-Wformat-truncation=] snprintf(buf, sizeof(buf), "/dev/%s", dent->d_name); ^~ In file included from /usr/include/stdio.h:862:0, from ir_loopback.c:14: /usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 6 and 261 bytes into a destination of size 100 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Shuah Khan <shuah@kernel.org> Acked-by: Sean Young <sean@mess.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests/seccomp: Actually sleep for 1/10th secondKees Cook1-2/+3
Clang noticed that some none-zero sleep()s were actually using zero anyway. This switches to nanosleep() to gain sub-second granularity. seccomp_bpf.c:2625:9: warning: implicit conversion from 'double' to 'unsigned int' changes value from 0.1 to 0 [-Wliteral-conversion] sleep(0.1); ~~~~~ ^~~ Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests/harness: Update named initializer syntaxKees Cook1-5/+5
The harness was still using old-style GNU named initializer syntax. Fix this so Clang will stop warning: seccomp_bpf.c:2924:1: warning: use of GNU old-style field designator extension [-Wgnu-designator] ./../kselftest_harness.h:147:25: note: expanded from macro 'TEST' ^ ./../kselftest_harness.h:172:5: note: expanded from macro '__TEST_IMPL' fn: &test_name, termsig: _signal }; \ ^ Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests: unshare userns in seccomp pidns testcasesTycho Andersen1-1/+3
The pid ns cannot be unshare()d as an unprivileged user without owning the userns as well. Let's unshare the userns so that we can subsequently unshare the pidns. This also means that we don't need to set the no new privs bit as in the other test cases, since we're unsharing the userns. Signed-off-by: Tycho Andersen <tycho@tycho.ws> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests: set NO_NEW_PRIVS bit in seccomp user testsTycho Andersen1-0/+24
seccomp() doesn't allow users who aren't root in their userns to attach filters unless they have the nnp bit set, so let's set it so that these tests can pass when run as an unprivileged user. This idea stolen from the other seccomp tests, which use this trick :) Signed-off-by: Tycho Andersen <tycho@tycho.ws> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13selftests: skip seccomp get_metadata test if not real rootTycho Andersen1-0/+6
The get_metadata() test requires real root, so let's skip it if we're not real root. Note that I used XFAIL here because that's what the test does later if CONFIG_CHEKCKPOINT_RESTORE happens to not be enabled. After looking at the code, there doesn't seem to be a nice way to skip tests defined as TEST(), since there's no return code (I tried exit(KSFT_SKIP), but that didn't work either...). So let's do it this way to be consistent, and easier to fix when someone comes along and fixes it. Signed-off-by: Tycho Andersen <tycho@tycho.ws> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <shuah@kernel.org>