lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240210235009.2405808-36-ukaszb@chromium.org>
Date: Sun, 11 Feb 2024 00:50:05 +0100
From: Łukasz Bartosik <ukaszb@...omium.org>
To: Jason Baron <jbaron@...mai.com>,
	Jim Cromie <jim.cromie@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Kees Cook <keescook@...omium.org>,
	Douglas Anderson <dianders@...omium.org>
Cc: Guenter Roeck <groeck@...gle.com>,
	Yaniv Tzoreff <yanivt@...gle.com>,
	Benson Leung <bleung@...gle.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Vincent Whitchurch <vincent.whitchurch@...s.com>,
	Pekka Paalanen <ppaalanen@...il.com>,
	Sean Paul <seanpaul@...omium.org>,
	Daniel Vetter <daniel@...ll.ch>,
	Simon Ser <contact@...rsion.fr>,
	John Ogness <john.ogness@...utronix.de>,
	Petr Mladek <pmladek@...e.com>,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	linux-kernel@...r.kernel.org,
	upstream@...ihalf.com
Subject: [PATCH v4 35/39] dyndbg-test: add test which verifies default dst

Add test which verifies default trace destination feature.

Signed-off-by: Łukasz Bartosik <ukaszb@...omium.org>
---
 .../dynamic_debug/dyndbg_selftest.sh          | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
index 4a0340d2c3e8..ae386e4de6a4 100755
--- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
+++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
@@ -195,6 +195,16 @@ function check_err_msg() {
     fi
 }
 
+# $1 - default destination to check
+function check_default_dst() {
+    dst=$(tail -50 /proc/dynamic_debug/control | grep "#: Default trace destination" | \
+	  cut -d':' -f3 | sed -e 's/^[[:space:]]*//')
+    if [ "$dst" != "$1" ]; then
+        echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO default dest '$dst' does not match with '$1'"
+        exit
+    fi
+}
+
 function basic_tests {
     echo -e "${GREEN}# BASIC_TESTS ${NC}"
     ddcmd =_ # zero everything (except class'd sites)
@@ -343,6 +353,70 @@ function test_flags {
     ifrmmod test_dynamic_debug
 }
 
+# test verifies default destination
+function test_default_destination {
+    echo -e "${GREEN}# TEST_DEFAULT_DESTINATION ${NC}"
+
+    check_default_dst 0
+    modprobe test_dynamic_debug
+
+    ddcmd class,D2_CORE,+T	# default dest is 0
+    check_match_ct =T 1 -v
+
+    ddcmd open foo		# foo becomes default dest
+    is_trace_instance_opened foo
+    check_trace_instance_dir foo 1
+    check_default_dst foo
+
+    ddcmd class,D2_CORE,+T	# default dest is foo
+    check_match_ct =T:foo 1 -v
+
+    ddcmd open,0		# reopening sets default dest to 0
+    check_default_dst 0
+
+    ddcmd class,D2_CORE,-T
+    check_match_ct =:foo 1 -v
+
+    ddcmd class,D2_CORE,+T      # default dest is 0 but since callsite was already labelled
+                                # then reuse label
+    check_match_ct =T:foo 1 -v
+
+    ddcmd open bar		# bar becomes default dest
+    is_trace_instance_opened bar
+    check_trace_instance_dir bar 1
+    check_default_dst bar
+
+    ddcmd class,D2_KMS,+T	# default dest is bar
+    check_match_ct =T:bar 1 -v
+
+    ddcmd class,D2_KMS,+T:0	# set 0 dest explicitly
+    check_match_ct =T 1 -v
+
+    ddcmd class,D2_KMS,-T
+
+    ddcmd open,foo		# reopening sets default dest to foo
+    check_default_dst foo
+
+    ddcmd class,D2_KMS,+T       # default dest is 0 but since callsite was already labelled
+                                # then reuse label
+    check_match_ct =T:foo 2 -v
+
+    ddcmd "class D2_CORE -T:0"
+    ddcmd "class D2_KMS -T:0"
+    check_default_dst foo
+
+    ddcmd close foo
+    is_trace_instance_closed foo
+    check_default_dst 0         # after closing foo which was default dest we revert
+                                # to 0 as default dest
+
+    ddcmd close bar
+    is_trace_instance_closed bar
+    check_default_dst 0
+
+    ifrmmod test_dynamic_debug
+}
+
 function test_actual_trace {
     echo -e "${GREEN}# TEST_ACTUAL_TRACE ${NC}"
     ddcmd =_
@@ -790,6 +864,7 @@ tests_list=(
     comma_terminator_tests
     test_percent_splitting
     test_flags
+    test_default_destination
     test_actual_trace
     cycle_tests_normal
     cycle_not_best_practices
-- 
2.43.0.687.g38aa6559b0-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ