From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com
Subject: [PATCH 2.6 PKT_SCHED]: Fix scheduler/classifier module unload race
Date: Sun, 07 Nov 2004 23:41:27 +0100 [thread overview]
Message-ID: <418EA497.10302@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
This patch fixes an scheduler/classifier module unload race.
struct Qdisc_ops which includes the owner field is also part
of the module's memory, so ops might already be freed when
try_module_get(ops->owner) is called outside of the locked
section.
Regards
Patrick
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 2062 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/11/07 05:03:11+01:00 kaber@coreworks.de
# [PKT_SCHED]: Fix scheduler/classifier module unload race
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/sched/sch_api.c
# 2004/11/07 05:03:04+01:00 kaber@coreworks.de +4 -4
# [PKT_SCHED]: Fix scheduler/classifier module unload race
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/sched/cls_api.c
# 2004/11/07 05:03:04+01:00 kaber@coreworks.de +4 -6
# [PKT_SCHED]: Fix scheduler/classifier module unload race
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/net/sched/cls_api.c b/net/sched/cls_api.c
--- a/net/sched/cls_api.c 2004-11-07 23:32:50 +01:00
+++ b/net/sched/cls_api.c 2004-11-07 23:32:50 +01:00
@@ -60,8 +60,11 @@
if (kind) {
read_lock(&cls_mod_lock);
for (t = tcf_proto_base; t; t = t->next) {
- if (rtattr_strcmp(kind, t->kind) == 0)
+ if (rtattr_strcmp(kind, t->kind) == 0) {
+ if (!try_module_get(t->owner))
+ t = NULL;
break;
+ }
}
read_unlock(&cls_mod_lock);
}
@@ -231,11 +234,6 @@
tp->q = q;
tp->classify = tp_ops->classify;
tp->classid = parent;
- err = -EBUSY;
- if (!try_module_get(tp_ops->owner)) {
- kfree(tp);
- goto errout;
- }
if ((err = tp_ops->init(tp)) != 0) {
module_put(tp_ops->owner);
kfree(tp);
diff -Nru a/net/sched/sch_api.c b/net/sched/sch_api.c
--- a/net/sched/sch_api.c 2004-11-07 23:32:50 +01:00
+++ b/net/sched/sch_api.c 2004-11-07 23:32:50 +01:00
@@ -229,8 +229,11 @@
if (kind) {
read_lock(&qdisc_mod_lock);
for (q = qdisc_base; q; q = q->next) {
- if (rtattr_strcmp(kind, q->id) == 0)
+ if (rtattr_strcmp(kind, q->id) == 0) {
+ if (!try_module_get(q->owner))
+ q = NULL;
break;
+ }
}
read_unlock(&qdisc_mod_lock);
}
@@ -408,9 +411,6 @@
err = -EINVAL;
if (ops == NULL)
- goto err_out;
- err = -EBUSY;
- if (!try_module_get(ops->owner))
goto err_out;
/* ensure that the Qdisc and the private data are 32-byte aligned */
next reply other threads:[~2004-11-07 22:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-07 22:41 Patrick McHardy [this message]
2004-11-10 5:46 ` [PATCH 2.6 PKT_SCHED]: Fix scheduler/classifier module unload race David S. Miller
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=418EA497.10302@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netdev@oss.sgi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.