From: Greg KH <gregkh@linuxfoundation.org>
To: cgxu519 <cgxu519@gmx.com>
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 2/2] chardev: showing minor range for chardev in the output of /proc/devices
Date: Tue, 12 Feb 2019 19:32:25 +0100 [thread overview]
Message-ID: <20190212183225.GA14528@kroah.com> (raw)
In-Reply-To: <f6f02cb9-79ad-aeb0-a911-89dfb1f90aae@gmx.com>
On Tue, Feb 12, 2019 at 11:41:35PM +0800, cgxu519 wrote:
> On 2/12/19 11:20 PM, Greg KH wrote:
> > On Tue, Feb 12, 2019 at 11:18:22PM +0800, cgxu519 wrote:
> > > On 2/12/19 5:02 PM, Greg KH wrote:
> > > > On Tue, Feb 12, 2019 at 04:47:39PM +0800, Chengguang Xu wrote:
> > > > > Currently chardev allows to share major, showing
> > > > > major with minor range for chardev will be more
> > > > > helpful.
> > > > >
> > > > > Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> > > > > ---
> > > > > fs/char_dev.c | 4 +++-
> > > > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/fs/char_dev.c b/fs/char_dev.c
> > > > > index b25b1da097d5..6f00acdeb308 100644
> > > > > --- a/fs/char_dev.c
> > > > > +++ b/fs/char_dev.c
> > > > > @@ -55,7 +55,9 @@ void chrdev_show(struct seq_file *f, off_t offset)
> > > > > mutex_lock(&chrdevs_lock);
> > > > > for (cd = chrdevs[major_to_index(offset)]; cd; cd = cd->next) {
> > > > > if (cd->major == offset)
> > > > > - seq_printf(f, "%3d %s\n", cd->major, cd->name);
> > > > > + seq_printf(f, "%3d %s (%u-%u)\n", cd->major, cd->name,
> > > > > + cd->baseminor,
> > > > > + cd->baseminor + cd->minorct - 1);
> > > > You are changing the format of a userspace file, what tools are going to
> > > > break when you do this?
> > > I'll remove this part in V2. Do you have any idea how to get the minor
> > > range info for particular major? Or adding a similar file to somewhere
> > > under /sys is acceptable?
> > Why do you need to know the minor range? What can userspace do with
> > this that actually matters?
>
> Assume that when we try to load a driver module and fail with -EBUSY
> because of minor range overlapping, then what can we do for this case?
> we even don't know what range has occupied and what range is available.
Why would drivers ever have minor range overlapping? Either they are
using a reserved range which is properly documented in the kernel file,
or they are using a dynamic range and that will never overlap as they
are allocated as needed.
So when has this ever happened in the real world?
> Also, I think we can obviously notice range overlapping bugs by showing
> all registered minor ranges.
Again, how can a range overlap? If so, that's a bug that we can fix
now and has nothing to do with the proc file, which will not show an
overlap as that can not happen at runtime.
thanks,
greg k-h
next prev parent reply other threads:[~2019-02-12 18:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 8:47 [PATCH 1/2] chardev: fix an overlap misjudgement case in __register_chrdev_region() Chengguang Xu
2019-02-12 8:47 ` [PATCH 2/2] chardev: showing minor range for chardev in the output of /proc/devices Chengguang Xu
2019-02-12 9:02 ` Greg KH
2019-02-12 15:18 ` cgxu519
2019-02-12 15:20 ` Greg KH
2019-02-12 15:41 ` cgxu519
2019-02-12 18:32 ` Greg KH [this message]
2019-02-12 9:01 ` [PATCH 1/2] chardev: fix an overlap misjudgement case in __register_chrdev_region() Greg KH
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=20190212183225.GA14528@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=cgxu519@gmx.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).