From: Xie XiuQi <xiexiuqi@huawei.com>
To: <jeyu@redhat.com>, <rusty@rustcorp.com.au>
Cc: <linux-kernel@vger.kernel.org>, <zhangliguang@huawei.com>
Subject: [PATCH] module: fix failed to rmmod kernel module when it's name is too long
Date: Fri, 13 Jan 2017 17:19:03 +0800 [thread overview]
Message-ID: <1484299143-157054-1-git-send-email-xiexiuqi@huawei.com> (raw)
When the name of kernel module is more than 56 chars (include 56),
the module could be insmod successfully, but failed to rmmod.
$ strace rmmod tst_1111111111222222222233333333334444444444555555555566
...
open("/sys/module/tst_1111111111222222222233333333334444444444555555555566/initstate", O_RDONLY|O_CLOEXEC) = 3
read(3, "live\n", 31) = 5
read(3, "", 26) = 0
close(3) = 0
openat(AT_FDCWD, "/sys/module/tst_1111111111222222222233333333334444444444555555555566/holders", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
getdents(3, /* 2 entries */, 32768) = 48
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
open("/sys/module/tst_1111111111222222222233333333334444444444555555555566/refcnt", O_RDONLY|O_CLOEXEC) = 3
read(3, "0\n", 31) = 2
read(3, "", 29) = 0
close(3) = 0
delete_module("tst_1111111111222222222233333333334444444444555555555566", O_RDONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
write(2, "rmmod: ERROR: could not remove '"..., 117rmmod: ERROR: could not remove 'tst_1111111111222222222233333333334444444444555555555566': No such file or directory
) = 117
write(2, "rmmod: ERROR: could not remove m"..., 122rmmod: ERROR: could not remove module tst_1111111111222222222233333333334444444444555555555566: No such file or directory
) = 122
exit_group(1) = ?
+++ exited with 1 +++
In this patch, we just set the last char to '\0', to make sure
the name has the tailing '\0'.
Reported-by: Zhang Liguang <zhangliguang@huawei.com>
Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
---
kernel/module.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/module.c b/kernel/module.c
index 0e54d5b..3eac266 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2928,6 +2928,7 @@ static struct module *setup_load_info(struct load_info *info, int flags)
}
/* This is temporary: point mod into copy of data. */
mod = (void *)info->sechdrs[info->index.mod].sh_addr;
+ mod->name[MODULE_NAME_LEN - 1] = '\0';
if (info->index.sym == 0) {
pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
--
1.8.3.1
next reply other threads:[~2017-01-13 9:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 9:19 Xie XiuQi [this message]
2017-01-19 3:26 ` Jessica Yu
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=1484299143-157054-1-git-send-email-xiexiuqi@huawei.com \
--to=xiexiuqi@huawei.com \
--cc=jeyu@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=zhangliguang@huawei.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®