Skip to content

Commit d514251

Browse files
committed
SUNRPC: Fix failures of checksum Kunit tests
Scott reports that when the new GSS krb5 Kunit tests are built as a separate module and loaded, the RFC 6803 and RFC 8009 checksum tests all fail, even though they pass when run under kunit.py. It appears that passing a buffer backed by static const memory to gss_krb5_checksum() is a problem. A printk in checksum_case() shows the correct plaintext, but by the time the buffer has been converted to a scatterlist and arrives at checksummer(), it contains all zeroes. Replacing this buffer with one that is dynamically allocated fixes the issue. Reported-by: Scott Mayhew <[email protected]> Fixes: 02142b2 ("SUNRPC: Add checksum KUnit tests for the RFC 6803 encryption types") Tested-by: Scott Mayhew <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent c8bc346 commit d514251

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/sunrpc/auth_gss/gss_krb5_test.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static void checksum_case(struct kunit *test)
7373
{
7474
const struct gss_krb5_test_param *param = test->param_value;
7575
struct xdr_buf buf = {
76-
.head[0].iov_base = param->plaintext->data,
7776
.head[0].iov_len = param->plaintext->len,
7877
.len = param->plaintext->len,
7978
};
@@ -99,6 +98,10 @@ static void checksum_case(struct kunit *test)
9998
err = crypto_ahash_setkey(tfm, Kc.data, Kc.len);
10099
KUNIT_ASSERT_EQ(test, err, 0);
101100

101+
buf.head[0].iov_base = kunit_kzalloc(test, buf.head[0].iov_len, GFP_KERNEL);
102+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf.head[0].iov_base);
103+
memcpy(buf.head[0].iov_base, param->plaintext->data, buf.head[0].iov_len);
104+
102105
checksum.len = gk5e->cksumlength;
103106
checksum.data = kunit_kzalloc(test, checksum.len, GFP_KERNEL);
104107
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, checksum.data);

0 commit comments

Comments
 (0)