diff options
author | Kees Cook <keescook@chromium.org> | 2013-09-11 00:37:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-17 10:39:27 -0400 |
commit | 9edf0f670bdc8fa8b6676893b0a3bd2bf30a2362 (patch) | |
tree | 297d5285d81537314dd43126f8fc216383be2dd1 | |
parent | 1ea12fef83c3269eb7ba04f1d20db00c581515b2 (diff) |
staging: lustre: clean up format string usages
This fixes up the usage of snprintf, strncpy, and format strings in the
call to kthread_run to avoid ever accidentally allowing a format string
into the thread name.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 files changed, 14 insertions, 14 deletions
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 086ca3d7241b..26b49a24b3df 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | |||
@@ -1802,7 +1802,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, | |||
1802 | int | 1802 | int |
1803 | kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name) | 1803 | kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name) |
1804 | { | 1804 | { |
1805 | struct task_struct *task = kthread_run(fn, arg, name); | 1805 | struct task_struct *task = kthread_run(fn, arg, "%s", name); |
1806 | 1806 | ||
1807 | if (IS_ERR(task)) | 1807 | if (IS_ERR(task)) |
1808 | return PTR_ERR(task); | 1808 | return PTR_ERR(task); |
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 2c581b7fa8ad..68a4f52ec998 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | |||
@@ -1005,7 +1005,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) | |||
1005 | int | 1005 | int |
1006 | ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name) | 1006 | ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name) |
1007 | { | 1007 | { |
1008 | struct task_struct *task = kthread_run(fn, arg, name); | 1008 | struct task_struct *task = kthread_run(fn, arg, "%s", name); |
1009 | 1009 | ||
1010 | if (IS_ERR(task)) | 1010 | if (IS_ERR(task)) |
1011 | return PTR_ERR(task); | 1011 | return PTR_ERR(task); |
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 3916bda3004c..a100a0b96381 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | |||
@@ -800,9 +800,9 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) | |||
800 | 800 | ||
801 | init_completion(&bltd.bltd_comp); | 801 | init_completion(&bltd.bltd_comp); |
802 | bltd.bltd_num = atomic_read(&blp->blp_num_threads); | 802 | bltd.bltd_num = atomic_read(&blp->blp_num_threads); |
803 | snprintf(bltd.bltd_name, sizeof(bltd.bltd_name) - 1, | 803 | snprintf(bltd.bltd_name, sizeof(bltd.bltd_name), |
804 | "ldlm_bl_%02d", bltd.bltd_num); | 804 | "ldlm_bl_%02d", bltd.bltd_num); |
805 | task = kthread_run(ldlm_bl_thread_main, &bltd, bltd.bltd_name); | 805 | task = kthread_run(ldlm_bl_thread_main, &bltd, "%s", bltd.bltd_name); |
806 | if (IS_ERR(task)) { | 806 | if (IS_ERR(task)) { |
807 | CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %ld\n", | 807 | CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %ld\n", |
808 | atomic_read(&blp->blp_num_threads), PTR_ERR(task)); | 808 | atomic_read(&blp->blp_num_threads), PTR_ERR(task)); |
diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index 462172d1a756..1a55c81892e0 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c | |||
@@ -397,7 +397,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, | |||
397 | sched->ws_name, sched->ws_nthreads); | 397 | sched->ws_name, sched->ws_nthreads); |
398 | } | 398 | } |
399 | 399 | ||
400 | task = kthread_run(cfs_wi_scheduler, sched, name); | 400 | task = kthread_run(cfs_wi_scheduler, sched, "%s", name); |
401 | if (!IS_ERR(task)) { | 401 | if (!IS_ERR(task)) { |
402 | nthrs--; | 402 | nthrs--; |
403 | continue; | 403 | continue; |
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 227a0ae9593b..5dec771d70ee 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c | |||
@@ -383,8 +383,8 @@ int ptlrpc_start_pinger(void) | |||
383 | 383 | ||
384 | /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we | 384 | /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we |
385 | * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */ | 385 | * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */ |
386 | rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, | 386 | rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread, |
387 | &pinger_thread, pinger_thread.t_name)); | 387 | "%s", pinger_thread.t_name)); |
388 | if (IS_ERR_VALUE(rc)) { | 388 | if (IS_ERR_VALUE(rc)) { |
389 | CERROR("cannot start thread: %d\n", rc); | 389 | CERROR("cannot start thread: %d\n", rc); |
390 | return rc; | 390 | return rc; |
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index fbdeff65d059..89c9be96f454 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | |||
@@ -615,7 +615,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) | |||
615 | init_completion(&pc->pc_starting); | 615 | init_completion(&pc->pc_starting); |
616 | init_completion(&pc->pc_finishing); | 616 | init_completion(&pc->pc_finishing); |
617 | spin_lock_init(&pc->pc_lock); | 617 | spin_lock_init(&pc->pc_lock); |
618 | strncpy(pc->pc_name, name, sizeof(pc->pc_name) - 1); | 618 | strlcpy(pc->pc_name, name, sizeof(pc->pc_name)); |
619 | pc->pc_set = ptlrpc_prep_set(); | 619 | pc->pc_set = ptlrpc_prep_set(); |
620 | if (pc->pc_set == NULL) | 620 | if (pc->pc_set == NULL) |
621 | GOTO(out, rc = -ENOMEM); | 621 | GOTO(out, rc = -ENOMEM); |
@@ -638,7 +638,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) | |||
638 | GOTO(out, rc); | 638 | GOTO(out, rc); |
639 | } | 639 | } |
640 | 640 | ||
641 | task = kthread_run(ptlrpcd, pc, pc->pc_name); | 641 | task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name); |
642 | if (IS_ERR(task)) | 642 | if (IS_ERR(task)) |
643 | GOTO(out, rc = PTR_ERR(task)); | 643 | GOTO(out, rc = PTR_ERR(task)); |
644 | 644 | ||
@@ -745,7 +745,7 @@ static int ptlrpcd_init(void) | |||
745 | if (ptlrpcds == NULL) | 745 | if (ptlrpcds == NULL) |
746 | GOTO(out, rc = -ENOMEM); | 746 | GOTO(out, rc = -ENOMEM); |
747 | 747 | ||
748 | snprintf(name, 15, "ptlrpcd_rcv"); | 748 | snprintf(name, sizeof(name), "ptlrpcd_rcv"); |
749 | set_bit(LIOD_RECOVERY, &ptlrpcds->pd_thread_rcv.pc_flags); | 749 | set_bit(LIOD_RECOVERY, &ptlrpcds->pd_thread_rcv.pc_flags); |
750 | rc = ptlrpcd_start(-1, nthreads, name, &ptlrpcds->pd_thread_rcv); | 750 | rc = ptlrpcd_start(-1, nthreads, name, &ptlrpcds->pd_thread_rcv); |
751 | if (rc < 0) | 751 | if (rc < 0) |
@@ -764,7 +764,7 @@ static int ptlrpcd_init(void) | |||
764 | * unnecessary dependency. But how to distribute async RPCs load | 764 | * unnecessary dependency. But how to distribute async RPCs load |
765 | * among all the ptlrpc daemons becomes another trouble. */ | 765 | * among all the ptlrpc daemons becomes another trouble. */ |
766 | for (i = 0; i < nthreads; i++) { | 766 | for (i = 0; i < nthreads; i++) { |
767 | snprintf(name, 15, "ptlrpcd_%d", i); | 767 | snprintf(name, sizeof(name), "ptlrpcd_%d", i); |
768 | rc = ptlrpcd_start(i, nthreads, name, &ptlrpcds->pd_threads[i]); | 768 | rc = ptlrpcd_start(i, nthreads, name, &ptlrpcds->pd_threads[i]); |
769 | if (rc < 0) | 769 | if (rc < 0) |
770 | GOTO(out, rc); | 770 | GOTO(out, rc); |
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index ac8b5fd2300b..acf75f3873d1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c | |||
@@ -2718,15 +2718,15 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) | |||
2718 | spin_unlock(&svcpt->scp_lock); | 2718 | spin_unlock(&svcpt->scp_lock); |
2719 | 2719 | ||
2720 | if (svcpt->scp_cpt >= 0) { | 2720 | if (svcpt->scp_cpt >= 0) { |
2721 | snprintf(thread->t_name, PTLRPC_THR_NAME_LEN, "%s%02d_%03d", | 2721 | snprintf(thread->t_name, sizeof(thread->t_name), "%s%02d_%03d", |
2722 | svc->srv_thread_name, svcpt->scp_cpt, thread->t_id); | 2722 | svc->srv_thread_name, svcpt->scp_cpt, thread->t_id); |
2723 | } else { | 2723 | } else { |
2724 | snprintf(thread->t_name, PTLRPC_THR_NAME_LEN, "%s_%04d", | 2724 | snprintf(thread->t_name, sizeof(thread->t_name), "%s_%04d", |
2725 | svc->srv_thread_name, thread->t_id); | 2725 | svc->srv_thread_name, thread->t_id); |
2726 | } | 2726 | } |
2727 | 2727 | ||
2728 | CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); | 2728 | CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); |
2729 | rc = PTR_ERR(kthread_run(ptlrpc_main, thread, thread->t_name)); | 2729 | rc = PTR_ERR(kthread_run(ptlrpc_main, thread, "%s", thread->t_name)); |
2730 | if (IS_ERR_VALUE(rc)) { | 2730 | if (IS_ERR_VALUE(rc)) { |
2731 | CERROR("cannot start thread '%s': rc %d\n", | 2731 | CERROR("cannot start thread '%s': rc %d\n", |
2732 | thread->t_name, rc); | 2732 | thread->t_name, rc); |