samples/tsm-mr/tsm_mr_sample.c:52:undefined reference to `crypto_alloc_shash'

From: kernel test robot

Date: Tue Mar 17 2026 - 15:28:38 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2d1373e4246da3b58e1df058374ed6b101804e07
commit: f6953f1f9ec4ad68651d7c677f0c065cb4c1edf7 tsm-mr: Add tsm-mr sample code
date: 10 months ago
config: i386-randconfig-r134-20260317 (https://download.01.org/0day-ci/archive/20260318/202603180323.NgdTrvDk-lkp@xxxxxxxxx/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260318/202603180323.NgdTrvDk-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603180323.NgdTrvDk-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

ld: samples/tsm-mr/tsm_mr_sample.o: in function `sample_report_extend_mr':
>> samples/tsm-mr/tsm_mr_sample.c:52:(.text+0x4f): undefined reference to `crypto_alloc_shash'
ld: samples/tsm-mr/tsm_mr_sample.c:60:(.text+0x9d): undefined reference to `crypto_shash_update'
ld: samples/tsm-mr/tsm_mr_sample.c:62:(.text+0xb6): undefined reference to `crypto_shash_finup'
ld: samples/tsm-mr/tsm_mr_sample.o: in function `sample_report_refresh':
samples/tsm-mr/tsm_mr_sample.c:29:(.text+0x104): undefined reference to `crypto_alloc_shash'
>> ld: samples/tsm-mr/tsm_mr_sample.c:35:(.text+0x12b): undefined reference to `crypto_shash_tfm_digest'


vim +52 samples/tsm-mr/tsm_mr_sample.c

23
24 static int sample_report_refresh(const struct tsm_measurements *tm)
25 {
26 struct crypto_shash *tfm;
27 int rc;
28
29 tfm = crypto_alloc_shash(hash_algo_name[HASH_ALGO_SHA512], 0, 0);
30 if (IS_ERR(tfm)) {
31 pr_err("crypto_alloc_shash failed: %ld\n", PTR_ERR(tfm));
32 return PTR_ERR(tfm);
33 }
34
> 35 rc = crypto_shash_tfm_digest(tfm, (u8 *)&sample_report,
36 offsetof(typeof(sample_report),
37 report_digest),
38 sample_report.report_digest);
39 crypto_free_shash(tfm);
40 if (rc)
41 pr_err("crypto_shash_tfm_digest failed: %d\n", rc);
42 return rc;
43 }
44
45 static int sample_report_extend_mr(const struct tsm_measurements *tm,
46 const struct tsm_measurement_register *mr,
47 const u8 *data)
48 {
49 SHASH_DESC_ON_STACK(desc, 0);
50 int rc;
51
> 52 desc->tfm = crypto_alloc_shash(hash_algo_name[mr->mr_hash], 0, 0);
53 if (IS_ERR(desc->tfm)) {
54 pr_err("crypto_alloc_shash failed: %ld\n", PTR_ERR(desc->tfm));
55 return PTR_ERR(desc->tfm);
56 }
57
58 rc = crypto_shash_init(desc);
59 if (!rc)
60 rc = crypto_shash_update(desc, mr->mr_value, mr->mr_size);
61 if (!rc)
62 rc = crypto_shash_finup(desc, data, mr->mr_size, mr->mr_value);
63 crypto_free_shash(desc->tfm);
64 if (rc)
65 pr_err("SHA calculation failed: %d\n", rc);
66 return rc;
67 }
68

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki