public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Siddharth Gupta <sidgup@codeaurora.org>,
	bjorn.andersson@linaro.org, agross@kernel.org, ohad@wizery.com,
	linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: kbuild-all@lists.01.org, Siddharth Gupta <sidgup@codeaurora.org>,
	psodagud@codeaurora.org, rishabhb@codeaurora.org
Subject: Re: [PATCH 3/3] soc: qcom: mdt_loader: Read hash from firmware blob
Date: Thu, 7 Jan 2021 07:41:11 +0800	[thread overview]
Message-ID: <202101070723.eUvtm9Em-lkp@intel.com> (raw)
In-Reply-To: <1609968211-7579-4-git-send-email-sidgup@codeaurora.org>

[-- Attachment #1: Type: text/plain, Size: 5160 bytes --]

Hi Siddharth,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.11-rc2 next-20210104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Siddharth-Gupta/soc-qcom-mdt_loader-General-improvements/20210107-052704
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ecd3796eaac75caf4abf7386c0c82546c104511a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Siddharth-Gupta/soc-qcom-mdt_loader-General-improvements/20210107-052704
        git checkout ecd3796eaac75caf4abf7386c0c82546c104511a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/soc/qcom/mdt_loader.c: In function 'qcom_mdt_read_metadata':
>> drivers/soc/qcom/mdt_loader.c:152:51: warning: format '%d' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
     152 |   snprintf(fw_name + strlen(fw_name) - 3, 4, "b%02d", hash_index);
         |                                                ~~~^   ~~~~~~~~~~
         |                                                   |   |
         |                                                   int size_t {aka long unsigned int}
         |                                                %02ld


vim +152 drivers/soc/qcom/mdt_loader.c

    88	
    89	/**
    90	 * qcom_mdt_read_metadata() - read header and metadata from mdt or mbn
    91	 * @fw:		firmware of mdt header or mbn
    92	 * @data_len:	length of the read metadata blob
    93	 *
    94	 * The mechanism that performs the authentication of the loading firmware
    95	 * expects an ELF header directly followed by the segment of hashes, with no
    96	 * padding inbetween. This function allocates a chunk of memory for this pair
    97	 * and copy the two pieces into the buffer.
    98	 *
    99	 * In the case of split firmware the hash is found directly following the ELF
   100	 * header, rather than at p_offset described by the second program header.
   101	 *
   102	 * The caller is responsible to free (kfree()) the returned pointer.
   103	 *
   104	 * Return: pointer to data, or ERR_PTR()
   105	 */
   106	void *qcom_mdt_read_metadata(struct device *dev, const struct firmware *fw, const char *firmware,
   107				     size_t *data_len)
   108	{
   109		const struct elf32_phdr *phdrs;
   110		const struct elf32_hdr *ehdr;
   111		const struct firmware *seg_fw;
   112		size_t hash_index;
   113		size_t hash_size;
   114		size_t ehdr_size;
   115		char *fw_name;
   116		void *data;
   117		int ret;
   118	
   119		ehdr = (struct elf32_hdr *)fw->data;
   120		phdrs = (struct elf32_phdr *)(ehdr + 1);
   121	
   122		if (ehdr->e_phnum < 2)
   123			return ERR_PTR(-EINVAL);
   124	
   125		if (phdrs[0].p_type == PT_LOAD)
   126			return ERR_PTR(-EINVAL);
   127	
   128		for (hash_index = 1; hash_index < ehdr->e_phnum; hash_index++) {
   129			if (phdrs[hash_index].p_type != PT_LOAD &&
   130			   (phdrs[hash_index].p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH)
   131				break;
   132		}
   133		if (hash_index >= ehdr->e_phnum)
   134			return ERR_PTR(-EINVAL);
   135	
   136		ehdr_size = phdrs[0].p_filesz;
   137		hash_size = phdrs[hash_index].p_filesz;
   138	
   139		data = kmalloc(ehdr_size + hash_size, GFP_KERNEL);
   140		if (!data)
   141			return ERR_PTR(-ENOMEM);
   142	
   143		/* copy elf header */
   144		memcpy(data, fw->data, ehdr_size);
   145	
   146		if (qcom_mdt_bins_are_split(fw)) {
   147			fw_name = kstrdup(firmware, GFP_KERNEL);
   148			if (!fw_name) {
   149				kfree(data);
   150				return ERR_PTR(-ENOMEM);
   151			}
 > 152			snprintf(fw_name + strlen(fw_name) - 3, 4, "b%02d", hash_index);
   153	
   154			ret = request_firmware_into_buf(&seg_fw, fw_name, dev, data + ehdr_size, hash_size);
   155			kfree(fw_name);
   156	
   157			if (ret) {
   158				kfree(data);
   159				return ERR_PTR(ret);
   160			}
   161	
   162			release_firmware(seg_fw);
   163		} else {
   164			memcpy(data + ehdr_size, fw->data + phdrs[hash_index].p_offset, hash_size);
   165		}
   166	
   167		*data_len = ehdr_size + hash_size;
   168	
   169		return data;
   170	}
   171	EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);
   172	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 76477 bytes --]

  reply	other threads:[~2021-01-06 23:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 21:23 [PATCH 0/3] soc: qcom: mdt_loader: General improvements Siddharth Gupta
2021-01-06 21:23 ` [PATCH 1/3] soc: qcom: mdt_loader: Allow hash at any phdr Siddharth Gupta
2021-01-08  0:03   ` Bjorn Andersson
2021-01-06 21:23 ` [PATCH 2/3] soc: qcom: mdt_loader: Handle split bins correctly Siddharth Gupta
2021-01-08  0:07   ` Bjorn Andersson
2021-01-06 21:23 ` [PATCH 3/3] soc: qcom: mdt_loader: Read hash from firmware blob Siddharth Gupta
2021-01-06 23:41   ` kernel test robot [this message]
2021-01-08  0:21   ` Bjorn Andersson
2021-01-13 23:01     ` Siddharth Gupta
2021-01-14 17:46       ` Bjorn Andersson
2021-01-17 23:03         ` Siddharth Gupta

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=202101070723.eUvtm9Em-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=psodagud@codeaurora.org \
    --cc=rishabhb@codeaurora.org \
    --cc=sidgup@codeaurora.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox