linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Dmitry Smirnov <divis1969@gmail.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: Remount of debugfs succeeded even if mount() system call fails
Date: Wed, 30 Dec 2015 20:11:16 -0800	[thread overview]
Message-ID: <20151231041116.GA25732@kroah.com> (raw)
In-Reply-To: <CACf55T4p7Y0LcQd4JqBshkVh3Q_Y0hbd1898N5LgCLcD5aYNHA@mail.gmail.com>

On Tue, Dec 29, 2015 at 02:58:34PM +0300, Dmitry Smirnov wrote:
> Hi,
> 
> I've recently faced an issue when the debugfs was remounted read-only
> despite the system call fails with EACCESS error.
> 
> Here are the details.
> 1. The issue is found on android with kernel 3.4.0

A "clean" 3.4.0 kernel?  Or a hacked up vendor-specific one?

Also note that 3.4.0 is _very_ old, please try to reproduce this on a
kernel that we can actually help out with, like 4.4-rc or at the worst,
4.3.

> 2. debugfs is already mounted by init on boot (per the init.rc) in
> read-write mode
> 3. SELinux rules does not allow an application to mount a debugfs
> 4. Application is using /system/bin/mount (which implements a mount
> command-line utility) to do the mount:
>   system("/system/bin/mount -t debugfs none /sys/kernel/debug");
> 5. The mount utility logic is to try read-only mount if read-write
> fails with EACCESS.
> 6. This second system call also fails with EACCESS, but debugfs can
> sometimes be remounted read-only!
>     Note: is looks like read-only remounting sometimes fails in
> do_remount_sb() with EBUSY error which is ignored by mount_single. But
> do_remount_sb() can also succeed (!) and I suppose this is some race
> condition.
> In any case, system call fails with EACCESS (and SELinux error
> message) which is returned by security_sb_kern_mount in mount_fs() but
> AFTER the attempt to remount read-only!
> 
> I've briefly searched the latest kernel sources but did not find any
> change that could fix this issue.
> 
> Is this a security issue?

If root is the only thing allowed to read from debugfs, I don't see how
this is a security issue, do you?

thanks,

greg k-h

      reply	other threads:[~2015-12-31  4:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29 11:58 Remount of debugfs succeeded even if mount() system call fails Dmitry Smirnov
2015-12-31  4:11 ` Greg KH [this message]

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=20151231041116.GA25732@kroah.com \
    --to=greg@kroah.com \
    --cc=divis1969@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).