All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: tianyu zhou <tyjoe.linux@gmail.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: Missing check for CAP_SYS_ADMIN in do_reconfigure_mnt()
Date: Mon, 31 May 2021 16:40:36 +0000	[thread overview]
Message-ID: <YLURhCHSEwlL2oCD@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <CAM6ytZrBUMB6xpP_srni8VParnNiuFPZZ2H-WsWUJEZH_vSk1w@mail.gmail.com>

On Mon, May 31, 2021 at 10:59:54PM +0800, tianyu zhou wrote:
> Hi, function do_remount() in fs/namespace.c checks the CAP_SYS_ADMIN
> before it calls set_mount_attributes().
> 
> --------------------
> // fs/namespace.c
> static int do_remount(struct path *path, int ms_flags, int sb_flags,
>               int mnt_flags, void *data)
> {
>         ....
>         if (ns_capable(sb->s_user_ns, CAP_SYS_ADMIN)) {
>             err = reconfigure_super(fc);
>             if (!err) {
>                 lock_mount_hash();
>                 set_mount_attributes(mnt, mnt_flags);       // <===
> protected function
>                 unlock_mount_hash();
>             }
>         ...
> }
> --------------------
> 
> However, in another caller of set_mount_attributes(),
> do_reconfigure_mnt(), I have not found any check for CAP_SYS_ADMIN.
> So, is there a missing check bug inside do_reconfigure_mnt() ? (which
> makes it possible for normal user to reach set_mount_attributes())

IDGI.  By the same token, there are callers of e.g. memcpy() with
CAP_SYS_ADMIN checks upstream of those, as well as those that are
called without any such checks whatsoever.  The answer to such
observation would obviously be "what of that?" and I really wonder
what your criteria are.

For another example, in the same function you have lock_mount_hash()
calls as well; are you going to report the calls of that made without
CAP_SYS_ADMIN?

IOW, what are the heuristics you are using to select the functions
you deem suspicious?

  reply	other threads:[~2021-05-31 17:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31 14:59 Missing check for CAP_SYS_ADMIN in do_reconfigure_mnt() tianyu zhou
2021-05-31 16:40 ` Al Viro [this message]
2021-05-31 17:07 ` Matthew Wilcox
2021-05-31 19:02   ` tianyu zhou
2021-06-01  8:45     ` Christian Brauner

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=YLURhCHSEwlL2oCD@zeniv-ca.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tyjoe.linux@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.