All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Block: Fix block/elevator.c elevator_get() off-by-one error
@ 2010-03-30  9:21 wzt.wzt
  2010-04-02  6:40 ` Jens Axboe
  2010-04-02  7:14 ` Xiaotian Feng
  0 siblings, 2 replies; 3+ messages in thread
From: wzt.wzt @ 2010-03-30  9:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe

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>

---
 block/elevator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/elevator.c b/block/elevator.c
index df75676..76e3702 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -154,7 +154,7 @@ static struct elevator_type *elevator_get(const char *name)
 
 		spin_unlock(&elv_list_lock);
 
-		sprintf(elv, "%s-iosched", name);
+		snprintf(elv, sizeof(elv), "%s-iosched", name);
 
 		request_module("%s", elv);
 		spin_lock(&elv_list_lock);
-- 
1.6.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-02  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30  9:21 [PATCH] Block: Fix block/elevator.c elevator_get() off-by-one error wzt.wzt
2010-04-02  6:40 ` Jens Axboe
2010-04-02  7:14 ` Xiaotian Feng

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.