All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Jiri Pirko <jiri@nvidia.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [jpirko-mlxsw:wip_attestation_all_2 31/68] security/integrity/ima/ima_attestation.c:366:48: sparse: sparse: incorrect type in assignment (different base types)
Date: Fri, 13 Nov 2026 23:41:38 +0100	[thread overview]
Message-ID: <202611132302.hXUschnD-lkp@intel.com> (raw)

tree:   https://github.com/jpirko/linux_mlxsw wip_attestation_all_2
head:   7ff5e548abbc2312431d4eea9ad283347963a6e2
commit: 838a230dec9f155e7e064b2afb98e487f70fda7a [31/68] ima: Project the attestation journal through securityfs
config: s390-randconfig-r2301-20261113 (https://download.01.org/0day-ci/archive/20261113/202611132302.hXUschnD-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 8621950157210c1fa68f20f0614cb51310ec9dff)
sparse: v0.6.5-rc1-21-g84ec0658
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261113/202611132302.hXUschnD-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611132302.hXUschnD-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> security/integrity/ima/ima_attestation.c:366:48: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] encoded_length @@     got restricted __le32 [usertype] @@
   security/integrity/ima/ima_attestation.c:366:48: sparse:     expected unsigned int [usertype] encoded_length
   security/integrity/ima/ima_attestation.c:366:48: sparse:     got restricted __le32 [usertype]

vim +366 security/integrity/ima/ima_attestation.c

8d1b3ed1db2e379 Jiri Pirko 2026-09-30  319  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  320  static int
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  321  ima_attestation_template_copy(const struct ima_template_entry *entry,
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  322  			      u8 **data, size_t *data_length)
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  323  {
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  324  	const struct ima_template_desc *desc = entry->template_desc;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  325  	bool legacy = !strcmp(desc->name, IMA_TEMPLATE_IMA_NAME);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  326  	size_t length = 0;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  327  	size_t offset = 0;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  328  	int index;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  329  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  330  	for (index = 0; index < desc->num_fields; index++) {
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  331  		const struct ima_template_field *field = desc->fields[index];
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  332  		const struct ima_field_data *field_data =
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  333  			&entry->template_data[index];
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  334  		size_t field_length = field_data->len;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  335  		bool length_prefix = true;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  336  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  337  		if (legacy && !strcmp(field->field_id, "d"))
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  338  			length_prefix = false;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  339  		else if (legacy && !strcmp(field->field_id, "n"))
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  340  			field_length = strlen((char *)field_data->data);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  341  		if ((length_prefix &&
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  342  		     check_add_overflow(length, sizeof(u32), &length)) ||
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  343  		    check_add_overflow(length, field_length, &length) ||
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  344  		    length > 65536)
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  345  			return -EINVAL;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  346  	}
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  347  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  348  	*data = length ? kmalloc(length, GFP_NOFS) : NULL;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  349  	if (length && !*data)
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  350  		return -ENOMEM;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  351  	for (index = 0; index < desc->num_fields; index++) {
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  352  		const struct ima_template_field *field = desc->fields[index];
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  353  		const struct ima_field_data *field_data =
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  354  			&entry->template_data[index];
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  355  		size_t field_length = field_data->len;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  356  		bool length_prefix = true;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  357  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  358  		if (legacy && !strcmp(field->field_id, "d"))
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  359  			length_prefix = false;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  360  		else if (legacy && !strcmp(field->field_id, "n"))
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  361  			field_length = strlen((char *)field_data->data);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  362  		if (length_prefix) {
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  363  			u32 encoded_length = (u32)field_length;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  364  
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  365  			if (ima_canonical_fmt)
8d1b3ed1db2e379 Jiri Pirko 2026-09-30 @366  				encoded_length = cpu_to_le32(encoded_length);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  367  			memcpy(*data + offset, &encoded_length,
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  368  			       sizeof(encoded_length));
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  369  			offset += sizeof(encoded_length);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  370  		}
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  371  		memcpy(*data + offset, field_data->data, field_length);
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  372  		offset += field_length;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  373  	}
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  374  	*data_length = length;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  375  	return 0;
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  376  }
8d1b3ed1db2e379 Jiri Pirko 2026-09-30  377  

:::::: The code at line 366 was first introduced by commit
:::::: 8d1b3ed1db2e379ad99f0104f505e7724c92f8f4 ima: Route measurements through attestation

:::::: TO: Jiri Pirko <jiri@nvidia.com>
:::::: CC: Jiri Pirko <jiri@nvidia.com>

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

                 reply	other threads:[~2026-11-13 22:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202611132302.hXUschnD-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=jiri@nvidia.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.