From 9042f3468b5a5910d9dde7e74fecffb48bad5407 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 28 Jan 2019 10:57:24 -0700 Subject: [PATCH] test/crypto_ut: change alignment of allocation This is intended to avoid a crypto failure when we have ASAN disabled. In order to appease a scan-build error, we have to assert that the memory address for two g_io_ctx->cry_iov.iov_base is different between runs of _crypto_operation_complete. However, when we have asan disabled, two subsequest calls to spdk_dma_malloc yield the same address, so change the alignment to prevent allocating the same address. Change-Id: Ia3dfbec5bb16d00bbe7dc136a886e0b9caea71a7 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/442413 Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System --- test/unit/lib/bdev/crypto.c/crypto_ut.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unit/lib/bdev/crypto.c/crypto_ut.c b/test/unit/lib/bdev/crypto.c/crypto_ut.c index 6908765c6..72edebc46 100644 --- a/test/unit/lib/bdev/crypto.c/crypto_ut.c +++ b/test/unit/lib/bdev/crypto.c/crypto_ut.c @@ -821,7 +821,10 @@ test_crypto_op_complete(void) g_completion_called = false; MOCK_SET(spdk_bdev_writev_blocks, -1); /* Code under test will free this, if not ASAN will complain. */ - g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x10, NULL); + g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x40, NULL); + /* To Do: remove this garbage assert as soon as scan-build stops throwing a + * heap use after free error. + */ SPDK_CU_ASSERT_FATAL(old_iov_base != orig_ctx->cry_iov.iov_base); _crypto_operation_complete(g_bdev_io); CU_ASSERT(g_bdev_io->internal.status == SPDK_BDEV_IO_STATUS_FAILED);