From: kernel test robot <[email protected]>
To: David Howells <[email protected]>
Cc: [email protected],
GNU/Weeb Mailing List <[email protected]>,
[email protected]
Subject: [ammarfaizi2-block:dhowells/linux-fs/netfs-maple 42/44] fs/afs/write.c:271:24: sparse: sparse: incorrect type in assignment (different base types)
Date: Sat, 23 Apr 2022 18:01:00 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
tree: https://github.com/ammarfaizi2/linux-block dhowells/linux-fs/netfs-maple
head: 931e50676c6598d0eda1954ead465519ff91874d
commit: 0565641524458774e47a4d1fd06f80d0bd62965f [42/44] afs: [DON'T MERGE] Implement trivial content crypto for testing purposes
config: alpha-randconfig-s031-20220422 (https://download.01.org/0day-ci/archive/20220423/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/ammarfaizi2/linux-block/commit/0565641524458774e47a4d1fd06f80d0bd62965f
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block dhowells/linux-fs/netfs-maple
git checkout 0565641524458774e47a4d1fd06f80d0bd62965f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash fs/afs/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> fs/afs/write.c:271:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] @@ got restricted __le64 [usertype] @@
fs/afs/write.c:271:24: sparse: expected restricted __be64 [usertype]
fs/afs/write.c:271:24: sparse: got restricted __le64 [usertype]
>> fs/afs/write.c:274:23: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] @@ got long long [usertype] pos @@
fs/afs/write.c:274:23: sparse: expected restricted __be64 [usertype]
fs/afs/write.c:274:23: sparse: got long long [usertype] pos
fs/afs/write.c:378:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] @@ got restricted __le64 [usertype] @@
fs/afs/write.c:378:24: sparse: expected restricted __be64 [usertype]
fs/afs/write.c:378:24: sparse: got restricted __le64 [usertype]
fs/afs/write.c:381:23: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] @@ got long long [usertype] pos @@
fs/afs/write.c:381:23: sparse: expected restricted __be64 [usertype]
fs/afs/write.c:381:23: sparse: got long long [usertype] pos
vim +271 fs/afs/write.c
230
231 /*
232 * Encrypt part of a write for fscrypt. The caller reserved an extra
233 * scatterlist element before each of source_sg and dest_sg for our purposes,
234 * should we need them.
235 */
236 int afs_encrypt_block(struct netfs_io_request *wreq, loff_t pos, size_t len,
237 struct scatterlist *source_sg, unsigned int n_source,
238 struct scatterlist *dest_sg, unsigned int n_dest)
239 {
240 struct crypto_sync_skcipher *ci;
241 struct skcipher_request *req;
242 struct crypto_skcipher *tfm;
243 struct sha256_state *sha;
244 void *buf = NULL;
245 __be64 *session_key;
246 u8 *iv, *b0;
247 int ret;
248
249 ci = crypto_alloc_sync_skcipher("cts(cbc(aes))", 0, 0);
250 if (IS_ERR(ci)) {
251 ret = PTR_ERR(ci);
252 pr_err("Can't allocate cipher: %d\n", ret);
253 goto error;
254 }
255 tfm = &ci->base;
256
257 if (crypto_sync_skcipher_ivsize(ci) > 16 &&
258 crypto_sync_skcipher_blocksize(ci) > 16) {
259 pr_err("iv wrong size: %u\n", crypto_sync_skcipher_ivsize(ci));
260 ret = -EINVAL;
261 goto error_ci;
262 }
263
264 buf = kzalloc(4 * 16 + sizeof(*sha), GFP_KERNEL);
265 if (!buf)
266 goto error_ci;
267 b0 = buf;
268 iv = buf + 32;
269 session_key = buf + 48;
270 session_key[0] = cpu_to_be64(pos);
> 271 session_key[1] = cpu_to_le64(pos);
272 sha = buf + 64;
273
> 274 *(__be64 *)iv = pos;
275
276 ret = crypto_sync_skcipher_setkey(ci, (u8 *)session_key, 16);
277 if (ret < 0) {
278 pr_err("Setkey failed: %d\n", ret);
279 goto error_ci;
280 }
281
282 ret = -ENOMEM;
283 req = skcipher_request_alloc(tfm, GFP_NOFS);
284 if (!req)
285 goto error_ci;
286
287 skcipher_request_set_sync_tfm(req, ci);
288 skcipher_request_set_callback(req, 0, NULL, NULL);
289
290 /* If the length is so short that the CTS algorithm will refuse to
291 * handle it, prepend a predictable block on the front and discard the
292 * output. Since CTS does draw data backwards, we can regenerate the
293 * encryption on just that block at decryption time.
294 */
295 if (len < 16) {
296 unsigned int i;
297 u8 *p = buf + 16;
298
299 kdebug("preblock %16phN", iv);
300 sha256_init(sha);
301 sha256_update(sha, iv, 32); /* iv and session key */
302 sha256_final(sha, b0);
303 kdebug("preblock %16phN", b0);
304
305 netfs_dump_sg("SRC", source_sg, n_source);
306 if (sg_copy_to_buffer(source_sg, n_source, p, len) != len) {
307 ret = -EIO;
308 goto error_req;
309 }
310
311 for (i = 0; i < len; i++)
312 p[i] += b0[i];
313
314 if (sg_copy_from_buffer(dest_sg, n_dest, p, len) != len) {
315 ret = -EIO;
316 goto error_req;
317 }
318 netfs_dump_sg("DST", dest_sg, n_dest);
319 ret = 0;
320 } else {
321 netfs_dump_sg("SRC", source_sg, n_source);
322 skcipher_request_set_crypt(req, source_sg, dest_sg, len, iv);
323 ret = crypto_skcipher_encrypt(req);
324 if (ret < 0)
325 pr_err("Encrypt failed: %d\n", ret);
326 netfs_dump_sg("DST", dest_sg, n_dest);
327 }
328
329 error_req:
330 skcipher_request_free(req);
331 error_ci:
332 kfree(buf);
333 crypto_free_sync_skcipher(ci);
334 error:
335 return ret;
336 }
337
--
0-DAY CI Kernel Test Service
https://01.org/lkp
reply other threads:[~2022-04-23 10:01 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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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