From: "Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
To: logang@deltatee.com, gregkh@linuxfoundation.org
Cc: axboe@kernel.dk, jlayton@poochiereds.net, bfields@fieldses.org,
linux-kernel@vger.kernel.org,
"Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
Subject: Change in register_blkdev() behavior
Date: Tue, 30 Jan 2018 16:56:32 -0800 [thread overview]
Message-ID: <a01cedbc-ca1a-3e3d-cf2c-3e995c63f793@csail.mit.edu> (raw)
Hi,
Before commit 133d55cdb2f "block: order /proc/devices by major number",
if register_blkdev() was called with major = [1..UINT_MAX], it used to
succeed (provided the requested major number was actually free).
However, while fixing the ordering in /proc/devices, commit 133d55cdb2f
also added this change:
@@ -309,6 +309,14 @@ int register_blkdev(unsigned int major, const char *name)
ret = major;
}
+ if (major >= BLKDEV_MAJOR_MAX) {
+ pr_err("register_blkdev: major requested (%d) is greater than the maximum (%d) for %s\n",
+ major, BLKDEV_MAJOR_MAX, name);
+
+ ret = -EINVAL;
+ goto out;
+ }
+
p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL);
if (p == NULL) {
ret = -ENOMEM;
So, after this commit, calls to register_blkdev() fail if the requested
major number is >= 512 (BLKDEV_MAJOR_MAX). I'm wondering if this was an
intentional change or not, as it wasn't explicitly called out in the
changelog (and the comment on top of register_blkdev() describing its
inputs seems quite out-of-date). This also breaks LTP testcase
block_dev/tc05, which tests for edge-cases and expects register_blkdev()
to succeed with major=UINT_MAX.
If the restriction on the major number was intentional, perhaps we
should get the LTP testcase modified for kernel versions >= 4.14.
Otherwise, we should fix register_blkdev to preserve the old behavior.
(I guess the same thing applies to commit 8a932f73e5b "char_dev: order
/proc/devices by major number" as well).
Thoughts?
Regards,
Srivatsa
next reply other threads:[~2018-01-31 0:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 0:56 Srivatsa S. Bhat [this message]
2018-01-31 1:26 ` Logan Gunthorpe
2018-02-02 0:23 ` Srivatsa S. Bhat
2018-02-02 1:10 ` Logan Gunthorpe
2018-02-02 2:17 ` Srivatsa S. Bhat
2018-02-02 6:12 ` Logan Gunthorpe
2018-01-31 14:24 ` Greg KH
2018-02-02 0:25 ` Srivatsa S. Bhat
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=a01cedbc-ca1a-3e3d-cf2c-3e995c63f793@csail.mit.edu \
--to=srivatsa@csail.mit.edu \
--cc=axboe@kernel.dk \
--cc=bfields@fieldses.org \
--cc=gregkh@linuxfoundation.org \
--cc=jlayton@poochiereds.net \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®