From: Sebastian Ott <sebott@linux.vnet.ibm.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
Alan Stern <stern@rowland.harvard.edu>,
Joerg Roedel <joerg.roedel@amd.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Michael Buesch <m@bues.ch>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Incorrect uses of get_driver()/put_driver()
Date: Tue, 10 Jan 2012 11:18:13 +0100 (CET) [thread overview]
Message-ID: <alpine.LFD.2.02.1201101114300.1750@c4eb> (raw)
In-Reply-To: <20120110092046.GB32291@core.coreip.homeip.net>
On Tue, 10 Jan 2012, Dmitry Torokhov wrote:
> On Tue, Jan 10, 2012 at 10:05:41AM +0100, Martin Schwidefsky wrote:
> > On Mon, 9 Jan 2012 12:35:09 -0500 (EST)
> > Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > > drivers/s390/cio/device.c:1681: drv = get_driver(&cdrv->driver);
> > > drivers/s390/cio/device.c:1687: put_driver(drv);
> > >
> > > Martin, these calls seem to be useless. The calls in ccwgroup.c are
> > > definitely useless; there's no reason to take a reference to a driver
> > > while it's being unregistered, since it can't go away until the
> > > unregistration is finished.
> >
> > The get_driver/put_driver in ccwgroup.c are obviously useless, the caller
> > passed ccwgroup_driver_unregister a ccwgroup_driver reference.
> > I am not so sure about the code in device.c. get_ccwdev_by_busid() gets
> > used e.g. by vmur like this:
>
> It does not matter how it is being used. Either get_ccwdev_by_busid()
> gets a valid driver structure or you already lost. You can not say that
> get_driver() protects anything, since if there is a chance driver can
> disappear it can disappear before we get to executing get_driver() code.
>
> So while you might want to audit callers get/put_driver inside of
> get_ccwdev_by_busid() is utterly useless.
Yes, the caller has to ensure valid driver pointers. We have one offender
here:
[PATCH] zfcp: fops add owner
Set the owner member of zfcp_cfdc_fops, to ensure that the
caller of these functions holds a module reference.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/s390/scsi/zfcp_cfdc.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/s390/scsi/zfcp_cfdc.c
+++ b/drivers/s390/scsi/zfcp_cfdc.c
@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/module.h>
#include <linux/miscdevice.h>
#include <asm/compat.h>
#include <asm/ccwdev.h>
@@ -249,6 +250,7 @@ static long zfcp_cfdc_dev_ioctl(struct f
}
static const struct file_operations zfcp_cfdc_fops = {
+ .owner = THIS_MODULE,
.open = nonseekable_open,
.unlocked_ioctl = zfcp_cfdc_dev_ioctl,
#ifdef CONFIG_COMPAT
>
> Thanks.
>
> --
> Dmitry
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
next prev parent reply other threads:[~2012-01-10 10:18 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 16:31 Problems with get_driver() and driver_attach() (and new_id too) Alan Stern
2012-01-05 18:01 ` Dmitry Torokhov
2012-01-05 18:55 ` Alan Stern
2012-01-05 20:05 ` Dmitry Torokhov
2012-01-05 20:48 ` Alan Stern
2012-01-05 23:17 ` Greg KH
2012-01-06 14:42 ` Alan Stern
2012-01-06 15:42 ` Alan Stern
2012-01-06 20:29 ` Alan Stern
2012-01-09 8:48 ` Dmitry Torokhov
2012-01-09 16:37 ` Alan Stern
2012-01-09 16:50 ` Dmitry Torokhov
2012-01-09 17:01 ` Alan Stern
2012-01-09 17:05 ` Dmitry Torokhov
2012-01-09 17:35 ` Incorrect uses of get_driver()/put_driver() Alan Stern
2012-01-09 17:48 ` Konrad Rzeszutek Wilk
2012-01-09 18:20 ` Dmitry Torokhov
2012-01-09 18:34 ` Konrad Rzeszutek Wilk
2012-01-09 18:49 ` Dmitry Torokhov
2012-01-09 19:36 ` Alan Stern
2012-01-09 18:03 ` Michael Büsch
2012-01-09 18:14 ` Dmitry Torokhov
2012-01-09 19:48 ` Alan Stern
2012-01-09 20:07 ` Michael Büsch
2012-01-09 22:44 ` Alan Stern
2012-01-09 23:05 ` Michael Büsch
2012-01-09 18:04 ` Joerg Roedel
2012-01-10 9:05 ` Martin Schwidefsky
2012-01-10 9:20 ` Dmitry Torokhov
2012-01-10 10:03 ` Martin Schwidefsky
2012-01-10 10:18 ` Sebastian Ott [this message]
2012-01-10 10:21 ` Sebastian Ott
2012-01-10 20:32 ` Alan Stern
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=alpine.LFD.2.02.1201101114300.1750@c4eb \
--to=sebott@linux.vnet.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--cc=joerg.roedel@amd.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m@bues.ch \
--cc=schwidefsky@de.ibm.com \
--cc=stern@rowland.harvard.edu \
/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