Hello Amir Goldstein, The patch 7ba39960c7f3: "fanotify: support reporting non-decodeable file handles" from May 2, 2023, leads to the following Smatch static checker warning: fs/notify/fanotify/fanotify.c:451 fanotify_encode_fh() warn: assigning signed to unsigned: 'fh->type = type' 's32min-(-1),1-254,256-s32max' (unpublished garbage Smatch check). fs/notify/fanotify/fanotify.c 403 static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, 404 unsigned int fh_len, unsigned int *hash, 405 gfp_t gfp) 406 { 407 int dwords, type = 0; 408 char *ext_buf = NULL; 409 void *buf = fh->buf; 410 int err; 411 412 fh->type = FILEID_ROOT; 413 fh->len = 0; 414 fh->flags = 0; 415 416 /* 417 * Invalid FHs are used by FAN_FS_ERROR for errors not 418 * linked to any inode. The f_handle won't be reported 419 * back to userspace. 420 */ 421 if (!inode) 422 goto out; 423 424 /* 425 * !gpf means preallocated variable size fh, but fh_len could 426 * be zero in that case if encoding fh len failed. 427 */ 428 err = -ENOENT; 429 if (fh_len < 4 || WARN_ON_ONCE(fh_len % 4) || fh_len > MAX_HANDLE_SZ) 430 goto out_err; 431 432 /* No external buffer in a variable size allocated fh */ 433 if (gfp && fh_len > FANOTIFY_INLINE_FH_LEN) { 434 /* Treat failure to allocate fh as failure to encode fh */ 435 err = -ENOMEM; 436 ext_buf = kmalloc(fh_len, gfp); 437 if (!ext_buf) 438 goto out_err; 439 440 *fanotify_fh_ext_buf_ptr(fh) = ext_buf; 441 buf = ext_buf; 442 fh->flags |= FANOTIFY_FH_FLAG_EXT_BUF; 443 } 444 445 dwords = fh_len >> 2; 446 type = exportfs_encode_fid(inode, buf, &dwords); 447 err = -EINVAL; 448 if (!type || type == FILEID_INVALID || fh_len != dwords << 2) exportfs_encode_fid() can return negative errors. Do we need to check if (!type etc? 449 goto out_err; 450 --> 451 fh->type = type; 452 fh->len = fh_len; 453 454 out: 455 /* 456 * Mix fh into event merge key. Hash might be NULL in case of 457 * unhashed FID events (i.e. FAN_FS_ERROR). 458 */ 459 if (hash) 460 *hash ^= fanotify_hash_fh(fh); 461 462 return FANOTIFY_FH_HDR_LEN + fh_len; 463 464 out_err: 465 pr_warn_ratelimited("fanotify: failed to encode fid (type=%d, len=%d, err=%i)\n", 466 type, fh_len, err); 467 kfree(ext_buf); 468 *fanotify_fh_ext_buf_ptr(fh) = NULL; 469 /* Report the event without a file identifier on encode error */ 470 fh->type = FILEID_INVALID; 471 fh->len = 0; 472 return 0; 473 } regards, dan carpenter