diff options
author | wzt.wzt@gmail.com <wzt.wzt@gmail.com> | 2010-04-02 02:41:14 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2010-04-02 02:41:14 -0400 |
commit | a506aedc51093544ff0f9610af6066d18cb6abbe (patch) | |
tree | 3a23d5987c02a94eb46746ae29d50d2d9e38a150 | |
parent | b2b163dd47024e445410b72d0c5df6d819c14dfd (diff) |
Block: Fix block/elevator.c elevator_get() off-by-one error
elevator_get() not check the name length, if the name length > sizeof(elv),
elv will miss the '\0'. And elv buffer will be replace "-iosched" as something
like aaaaaaaaa, then call request_module() can load an not trust module.
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/elevator.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/elevator.c b/block/elevator.c index df75676f6671..76e3702d5381 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -154,7 +154,7 @@ static struct elevator_type *elevator_get(const char *name) | |||
154 | 154 | ||
155 | spin_unlock(&elv_list_lock); | 155 | spin_unlock(&elv_list_lock); |
156 | 156 | ||
157 | sprintf(elv, "%s-iosched", name); | 157 | snprintf(elv, sizeof(elv), "%s-iosched", name); |
158 | 158 | ||
159 | request_module("%s", elv); | 159 | request_module("%s", elv); |
160 | spin_lock(&elv_list_lock); | 160 | spin_lock(&elv_list_lock); |