public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: ioctl32_unregister_conversion & modules
Date: Fri, 9 May 2003 17:24:36 +0200	[thread overview]
Message-ID: <20030509152436.GA762@elf.ucw.cz> (raw)
In-Reply-To: <200305091213.h49CDuO4029947@post.webmailer.de>

Hi!

> > ...what is the problem?
> > 
> > It seems that function pointers into modules do not need any special
> > treatmeant [I *know* there was talk about this on l-k; but I can't
> > find anything in Documentation/]:
> > 
> >                 if (!capable(CAP_SYS_ADMIN))
> >                         return -EACCES;
> >                 if (disk->fops->ioctl) {
> >                         ret = disk->fops->ioctl(inode, file, cmd, arg);
> >                         if (ret != -EINVAL)
> >                                 return ret;
> >                 }
> 
> This is protected against unload by the reference counting done in 
> open()/release(). ->ioctl() can be called only for open devices,
> so you know the ioctl handler is not getting unloaded while it
> is running.
>  
> > So... what's the problem with {un}register_ioctl32_conversion being
> > called from module_init/module_exit? Drivers in the tree do it
> > already...
> 
> The problem is that when the conversion handler is called, the reference
> counting is only done for the module listed as ->owner in the
> file operations. For example in the patch you submitted to add 
> register_ioctl32_conversion() to drivers/serial/core.c I see nothing
> stopping you from unloading core.ko while the handler is running
> on a device owned by drivers/char/cyclades.c or any other serial driver.
> It does not even have to be run on a serial driver, a user might try
> to do ioctl(TIOCGSERIAL, ...) on a regular file...

Oh.... Yep, that's pretty clear.

So what you are saying is that all existing
register_ioctl32_conversion-s that are in unloadable module are
broken. Ouch.

Fixing that would require resgister_ioctl32_conversion() to have 3-rd
parameter "this module" and some magic inside fs/compat_ioctl.c,
right?

								Pavel
-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

  reply	other threads:[~2003-05-09 15:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030509100039$6904@gated-at.bofh.it>
2003-05-09 12:10 ` ioctl32_unregister_conversion & modules Arnd Bergmann
2003-05-09 15:24   ` Pavel Machek [this message]
2003-05-09 16:13     ` David S. Miller
2003-05-09 17:11       ` Pavel Machek
2003-05-09 17:16         ` David S. Miller
2003-05-09 19:30     ` Arnd Bergmann
2003-05-09  9:32 Pavel Machek

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=20030509152436.GA762@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@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