lkml.org 
[lkml]   [2021]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] soc: qcom: mdt_loader: Read hash from firmware blob
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
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2021-01-07 00:43    [W:0.084 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site