public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] fsinfo: Allow fsinfo() to look up a mount object by ID
@ 2020-07-13 10:12 dan.carpenter
  2020-07-17 17:31 ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: dan.carpenter @ 2020-07-13 10:12 UTC (permalink / raw)
  To: dhowells; +Cc: linux-fsdevel

Hello David Howells,

The patch 2421474bbbc8: "fsinfo: Allow fsinfo() to look up a mount
object by ID" from Jul 5, 2019, leads to the following static checker
warning:

	fs/fsinfo.c:618 vfs_fsinfo_mount()
	warn: AAA no lower bound on 'mnt_id'

fs/fsinfo.c
   589  static int vfs_fsinfo_mount(int dfd, const char __user *filename,
   590                              struct fsinfo_context *ctx)
   591  {
   592          struct path path;
   593          struct fd f = {};
   594          char *name;
   595          long mnt_id;
                ^^^^^^^^^^^

   596          int ret;
   597  
   598          if (!filename)
   599                  return -EINVAL;
   600  
   601          name = strndup_user(filename, 32);
   602          if (IS_ERR(name))
   603                  return PTR_ERR(name);
   604          ret = kstrtoul(name, 0, &mnt_id);
   605          if (ret < 0)
   606                  goto out_name;
   607          if (mnt_id > INT_MAX)
                    ^^^^^^^^^^^^^^^^
This can be negative.  Why do we need to check this at all?  Can we just
delete this check?

   608                  goto out_name;
   609  
   610          if (dfd != AT_FDCWD) {
   611                  ret = -EBADF;
   612                  f = fdget_raw(dfd);
   613                  if (!f.file)
   614                          goto out_name;
   615          }
   616  
   617          ret = lookup_mount_object(f.file ? &f.file->f_path : NULL,
   618                                    mnt_id, &path);
   619          if (ret < 0)
   620                  goto out_fd;
   621  
   622          ret = vfs_fsinfo(&path, ctx);
   623          path_put(&path);
   624  out_fd:
   625          fdput(f);
   626  out_name:
   627          kfree(name);
   628          return ret;
   629  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-17 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-13 10:12 [bug report] fsinfo: Allow fsinfo() to look up a mount object by ID dan.carpenter
2020-07-17 17:31 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox