Skip to content

Commit 2d68df6

Browse files
sulixshuahkh
authored andcommitted
kunit: Always print actual pointer values in asserts
KUnit assertions and expectations will print the values being tested. If these are pointers (e.g., KUNIT_EXPECT_PTR_EQ(test, a, b)), these pointers are currently printed with the %pK format specifier, which -- to prevent information leaks which may compromise, e.g., ASLR -- are often either hashed or replaced with ____ptrval____ or similar, making debugging tests difficult. By replacing %pK with %px as Documentation/core-api/printk-formats.rst suggests, we disable this security feature for KUnit assertions and expectations, allowing the actual pointer values to be printed. Given that KUnit is not intended for use in production kernels, and the pointers are only printed on failing tests, this seems like a worthwhile tradeoff. Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 0476e69 commit 2d68df6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎lib/kunit/assert.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ void kunit_binary_ptr_assert_format(const struct kunit_assert *assert,
118118
binary_assert->left_text,
119119
binary_assert->operation,
120120
binary_assert->right_text);
121-
string_stream_add(stream, "\t\t%s == %pK\n",
121+
string_stream_add(stream, "\t\t%s == %px\n",
122122
binary_assert->left_text,
123123
binary_assert->left_value);
124-
string_stream_add(stream, "\t\t%s == %pK",
124+
string_stream_add(stream, "\t\t%s == %px",
125125
binary_assert->right_text,
126126
binary_assert->right_value);
127127
kunit_assert_print_msg(assert, stream);

0 commit comments

Comments
 (0)