From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Denis Efremov <efremov@linux.com>, Jens Axboe <axboe@kernel.dk>
Cc: Dongliang Mu <mudongliangabcd@gmail.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] driver: floppy: fix warning in __alloc_pages
Date: Tue, 12 Oct 2021 11:49:54 +0800 [thread overview]
Message-ID: <20211012034955.2802626-1-mudongliangabcd@gmail.com> (raw)
If the user-provided length (ptr->length) is longer than one threshold,
it will trigger a warning in __alloc_pages.
Fix this by checking get_order(ptr->length) >= MAX_ORDER.
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
drivers/block/floppy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index fef79ea52e3e..8b88960e2784 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3109,6 +3109,8 @@ static int raw_cmd_copyin(int cmd, void __user *param,
if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
if (ptr->length <= 0)
return -EINVAL;
+ if (get_order(ptr->length) >= MAX_ORDER)
+ return -EINVAL;
ptr->kernel_data = (char *)fd_dma_mem_alloc(ptr->length);
fallback_on_nodma_alloc(&ptr->kernel_data, ptr->length);
if (!ptr->kernel_data)
--
2.25.1
reply other threads:[~2021-10-12 3:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211012034955.2802626-1-mudongliangabcd@gmail.com \
--to=mudongliangabcd@gmail.com \
--cc=axboe@kernel.dk \
--cc=efremov@linux.com \
--cc=linux-block@vger.kernel.org \
--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
all inboxes | Powered by JetHome®