aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-07-03 18:04:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:41 -0400
commitf170168b9a0b61ea1e647b082b38f605f1d3de3e (patch)
tree4381c129ee9af108e368e6c8255df53cbe233257
parentd8537548c924db3c44afde7646b6e220c7beb79d (diff)
drivers: avoid parsing names as kthread_run() format strings
Calling kthread_run with a single name parameter causes it to be handled as a format string. Many callers are passing potentially dynamic string content, so use "%s" in those cases to avoid any potential accidents. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/block/aoe/aoecmd.c2
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c3
-rw-r--r--drivers/block/xen-blkback/xenbus.c2
-rw-r--r--drivers/hwmon/adt7470.c2
-rw-r--r--drivers/media/i2c/tvaudio.c3
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.c2
-rw-r--r--drivers/media/platform/vivi.c3
-rw-r--r--drivers/mtd/ubi/build.c2
-rw-r--r--drivers/net/wireless/airo.c3
-rw-r--r--drivers/scsi/aacraid/commctrl.c3
-rw-r--r--drivers/scsi/aacraid/commsup.c3
-rw-r--r--drivers/spi/spi.c2
-rw-r--r--drivers/staging/rtl8712/os_intfs.c2
-rw-r--r--drivers/usb/atm/usbatm.c5
-rw-r--r--fs/lockd/svc.c2
-rw-r--r--fs/nfs/callback.c5
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--kernel/rcutree.c2
-rw-r--r--net/sunrpc/svc.c2
19 files changed, 28 insertions, 22 deletions
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index fc803ecbbce4..b75c7db16559 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -1340,7 +1340,7 @@ aoe_ktstart(struct ktstate *k)
1340 struct task_struct *task; 1340 struct task_struct *task;
1341 1341
1342 init_completion(&k->rendez); 1342 init_completion(&k->rendez);
1343 task = kthread_run(kthread, k, k->name); 1343 task = kthread_run(kthread, k, "%s", k->name);
1344 if (task == NULL || IS_ERR(task)) 1344 if (task == NULL || IS_ERR(task))
1345 return -ENOMEM; 1345 return -ENOMEM;
1346 k->task = task; 1346 k->task = task;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 20dd52a2f92f..952dbfe22126 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4087,7 +4087,8 @@ skip_create_disk:
4087start_service_thread: 4087start_service_thread:
4088 sprintf(thd_name, "mtip_svc_thd_%02d", index); 4088 sprintf(thd_name, "mtip_svc_thd_%02d", index);
4089 dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread, 4089 dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread,
4090 dd, dd->numa_node, thd_name); 4090 dd, dd->numa_node, "%s",
4091 thd_name);
4091 4092
4092 if (IS_ERR(dd->mtip_svc_handler)) { 4093 if (IS_ERR(dd->mtip_svc_handler)) {
4093 dev_err(&dd->pdev->dev, "service thread failed to start\n"); 4094 dev_err(&dd->pdev->dev, "service thread failed to start\n");
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 8bfd1bcf95ec..04608a6502d7 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -93,7 +93,7 @@ static void xen_update_blkif_status(struct xen_blkif *blkif)
93 } 93 }
94 invalidate_inode_pages2(blkif->vbd.bdev->bd_inode->i_mapping); 94 invalidate_inode_pages2(blkif->vbd.bdev->bd_inode->i_mapping);
95 95
96 blkif->xenblkd = kthread_run(xen_blkif_schedule, blkif, name); 96 blkif->xenblkd = kthread_run(xen_blkif_schedule, blkif, "%s", name);
97 if (IS_ERR(blkif->xenblkd)) { 97 if (IS_ERR(blkif->xenblkd)) {
98 err = PTR_ERR(blkif->xenblkd); 98 err = PTR_ERR(blkif->xenblkd);
99 blkif->xenblkd = NULL; 99 blkif->xenblkd = NULL;
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index b83bf4bb95eb..0f34bca9f5e5 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -1285,7 +1285,7 @@ static int adt7470_probe(struct i2c_client *client,
1285 } 1285 }
1286 1286
1287 init_completion(&data->auto_update_stop); 1287 init_completion(&data->auto_update_stop);
1288 data->auto_update = kthread_run(adt7470_update_thread, client, 1288 data->auto_update = kthread_run(adt7470_update_thread, client, "%s",
1289 dev_name(data->hwmon_dev)); 1289 dev_name(data->hwmon_dev));
1290 if (IS_ERR(data->auto_update)) { 1290 if (IS_ERR(data->auto_update)) {
1291 err = PTR_ERR(data->auto_update); 1291 err = PTR_ERR(data->auto_update);
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index b72a59d3216a..e0634c8b7e0b 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -2020,7 +2020,8 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
2020 /* start async thread */ 2020 /* start async thread */
2021 chip->wt.function = chip_thread_wake; 2021 chip->wt.function = chip_thread_wake;
2022 chip->wt.data = (unsigned long)chip; 2022 chip->wt.data = (unsigned long)chip;
2023 chip->thread = kthread_run(chip_thread, chip, client->name); 2023 chip->thread = kthread_run(chip_thread, chip, "%s",
2024 client->name);
2024 if (IS_ERR(chip->thread)) { 2025 if (IS_ERR(chip->thread)) {
2025 v4l2_warn(sd, "failed to create kthread\n"); 2026 v4l2_warn(sd, "failed to create kthread\n");
2026 chip->thread = NULL; 2027 chip->thread = NULL;
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index 07b8460953b6..b809bc868a9f 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -753,7 +753,7 @@ static int ivtv_init_struct1(struct ivtv *itv)
753 753
754 init_kthread_worker(&itv->irq_worker); 754 init_kthread_worker(&itv->irq_worker);
755 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker, 755 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker,
756 itv->v4l2_dev.name); 756 "%s", itv->v4l2_dev.name);
757 if (IS_ERR(itv->irq_worker_task)) { 757 if (IS_ERR(itv->irq_worker_task)) {
758 IVTV_ERR("Could not create ivtv task\n"); 758 IVTV_ERR("Could not create ivtv task\n");
759 return -1; 759 return -1;
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 85bc314382d3..1d3f11965196 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -768,7 +768,8 @@ static int vivi_start_generating(struct vivi_dev *dev)
768 768
769 dma_q->frame = 0; 769 dma_q->frame = 0;
770 dma_q->ini_jiffies = jiffies; 770 dma_q->ini_jiffies = jiffies;
771 dma_q->kthread = kthread_run(vivi_thread, dev, dev->v4l2_dev.name); 771 dma_q->kthread = kthread_run(vivi_thread, dev, "%s",
772 dev->v4l2_dev.name);
772 773
773 if (IS_ERR(dma_q->kthread)) { 774 if (IS_ERR(dma_q->kthread)) {
774 v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n"); 775 v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n");
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index a56133585e92..0aaece9107c7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1005,7 +1005,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
1005 if (err) 1005 if (err)
1006 goto out_uif; 1006 goto out_uif;
1007 1007
1008 ubi->bgt_thread = kthread_create(ubi_thread, ubi, ubi->bgt_name); 1008 ubi->bgt_thread = kthread_create(ubi_thread, ubi, "%s", ubi->bgt_name);
1009 if (IS_ERR(ubi->bgt_thread)) { 1009 if (IS_ERR(ubi->bgt_thread)) {
1010 err = PTR_ERR(ubi->bgt_thread); 1010 err = PTR_ERR(ubi->bgt_thread);
1011 ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name, 1011 ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name,
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 6125adb520a3..d0adbaf86186 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1893,7 +1893,8 @@ static int airo_open(struct net_device *dev) {
1893 1893
1894 if (ai->wifidev != dev) { 1894 if (ai->wifidev != dev) {
1895 clear_bit(JOB_DIE, &ai->jobs); 1895 clear_bit(JOB_DIE, &ai->jobs);
1896 ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name); 1896 ai->airo_thread_task = kthread_run(airo_thread, dev, "%s",
1897 dev->name);
1897 if (IS_ERR(ai->airo_thread_task)) 1898 if (IS_ERR(ai->airo_thread_task))
1898 return (int)PTR_ERR(ai->airo_thread_task); 1899 return (int)PTR_ERR(ai->airo_thread_task);
1899 1900
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 1ef041bc60c8..d85ac1a9d2c0 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -318,7 +318,8 @@ return_fib:
318 kthread_stop(dev->thread); 318 kthread_stop(dev->thread);
319 ssleep(1); 319 ssleep(1);
320 dev->aif_thread = 0; 320 dev->aif_thread = 0;
321 dev->thread = kthread_run(aac_command_thread, dev, dev->name); 321 dev->thread = kthread_run(aac_command_thread, dev,
322 "%s", dev->name);
322 ssleep(1); 323 ssleep(1);
323 } 324 }
324 if (f.wait) { 325 if (f.wait) {
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 1be0776a80c4..cab190af6345 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1336,7 +1336,8 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced)
1336 if ((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32)))) 1336 if ((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32))))
1337 goto out; 1337 goto out;
1338 if (jafo) { 1338 if (jafo) {
1339 aac->thread = kthread_run(aac_command_thread, aac, aac->name); 1339 aac->thread = kthread_run(aac_command_thread, aac, "%s",
1340 aac->name);
1340 if (IS_ERR(aac->thread)) { 1341 if (IS_ERR(aac->thread)) {
1341 retval = PTR_ERR(aac->thread); 1342 retval = PTR_ERR(aac->thread);
1342 goto out; 1343 goto out;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 32b7bb111eb6..085db8b2f2bc 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -601,7 +601,7 @@ static int spi_init_queue(struct spi_master *master)
601 601
602 init_kthread_worker(&master->kworker); 602 init_kthread_worker(&master->kworker);
603 master->kworker_task = kthread_run(kthread_worker_fn, 603 master->kworker_task = kthread_run(kthread_worker_fn,
604 &master->kworker, 604 &master->kworker, "%s",
605 dev_name(&master->dev)); 605 dev_name(&master->dev));
606 if (IS_ERR(master->kworker_task)) { 606 if (IS_ERR(master->kworker_task)) {
607 dev_err(&master->dev, "failed to create message pump task\n"); 607 dev_err(&master->dev, "failed to create message pump task\n");
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index b65bf5e177a8..6e81ba0eaf1e 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -238,7 +238,7 @@ struct net_device *r8712_init_netdev(void)
238 238
239static u32 start_drv_threads(struct _adapter *padapter) 239static u32 start_drv_threads(struct _adapter *padapter)
240{ 240{
241 padapter->cmdThread = kthread_run(r8712_cmd_thread, padapter, 241 padapter->cmdThread = kthread_run(r8712_cmd_thread, padapter, "%s",
242 padapter->pnetdev->name); 242 padapter->pnetdev->name);
243 if (IS_ERR(padapter->cmdThread) < 0) 243 if (IS_ERR(padapter->cmdThread) < 0)
244 return _FAIL; 244 return _FAIL;
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index d3527dd8b90c..5e0d33a7da58 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -1020,7 +1020,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
1020{ 1020{
1021 struct task_struct *t; 1021 struct task_struct *t;
1022 1022
1023 t = kthread_create(usbatm_do_heavy_init, instance, 1023 t = kthread_create(usbatm_do_heavy_init, instance, "%s",
1024 instance->driver->driver_name); 1024 instance->driver->driver_name);
1025 if (IS_ERR(t)) { 1025 if (IS_ERR(t)) {
1026 usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n", 1026 usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
@@ -1076,7 +1076,8 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1076 /* public fields */ 1076 /* public fields */
1077 1077
1078 instance->driver = driver; 1078 instance->driver = driver;
1079 snprintf(instance->driver_name, sizeof(instance->driver_name), driver->driver_name); 1079 strlcpy(instance->driver_name, driver->driver_name,
1080 sizeof(instance->driver_name));
1080 1081
1081 instance->usb_dev = usb_dev; 1082 instance->usb_dev = usb_dev;
1082 instance->usb_intf = intf; 1083 instance->usb_intf = intf;
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index a2aa97d45670..10d6c41aecad 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
305 svc_sock_update_bufs(serv); 305 svc_sock_update_bufs(serv);
306 serv->sv_maxconn = nlm_max_connections; 306 serv->sv_maxconn = nlm_max_connections;
307 307
308 nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name); 308 nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
309 if (IS_ERR(nlmsvc_task)) { 309 if (IS_ERR(nlmsvc_task)) {
310 error = PTR_ERR(nlmsvc_task); 310 error = PTR_ERR(nlmsvc_task);
311 printk(KERN_WARNING 311 printk(KERN_WARNING
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index cff089a412c7..da6a43d19aa3 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
211 struct svc_rqst *rqstp; 211 struct svc_rqst *rqstp;
212 int (*callback_svc)(void *vrqstp); 212 int (*callback_svc)(void *vrqstp);
213 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; 213 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
214 char svc_name[12];
215 int ret; 214 int ret;
216 215
217 nfs_callback_bc_serv(minorversion, xprt, serv); 216 nfs_callback_bc_serv(minorversion, xprt, serv);
@@ -235,10 +234,10 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
235 234
236 svc_sock_update_bufs(serv); 235 svc_sock_update_bufs(serv);
237 236
238 sprintf(svc_name, "nfsv4.%u-svc", minorversion);
239 cb_info->serv = serv; 237 cb_info->serv = serv;
240 cb_info->rqst = rqstp; 238 cb_info->rqst = rqstp;
241 cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name); 239 cb_info->task = kthread_run(callback_svc, cb_info->rqst,
240 "nfsv4.%u-svc", minorversion);
242 if (IS_ERR(cb_info->task)) { 241 if (IS_ERR(cb_info->task)) {
243 ret = PTR_ERR(cb_info->task); 242 ret = PTR_ERR(cb_info->task);
244 svc_exit_thread(cb_info->rqst); 243 svc_exit_thread(cb_info->rqst);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index ff10b4aa534c..55418811a55a 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1194,7 +1194,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
1194 snprintf(buf, sizeof(buf), "%s-manager", 1194 snprintf(buf, sizeof(buf), "%s-manager",
1195 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); 1195 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
1196 rcu_read_unlock(); 1196 rcu_read_unlock();
1197 task = kthread_run(nfs4_run_state_manager, clp, buf); 1197 task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
1198 if (IS_ERR(task)) { 1198 if (IS_ERR(task)) {
1199 printk(KERN_ERR "%s: kthread_run: %ld\n", 1199 printk(KERN_ERR "%s: kthread_run: %ld\n",
1200 __func__, PTR_ERR(task)); 1200 __func__, PTR_ERR(task));
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index cf3adc6fe001..e08abb9461ac 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -3026,7 +3026,7 @@ static int __init rcu_spawn_gp_kthread(void)
3026 struct task_struct *t; 3026 struct task_struct *t;
3027 3027
3028 for_each_rcu_flavor(rsp) { 3028 for_each_rcu_flavor(rsp) {
3029 t = kthread_run(rcu_gp_kthread, rsp, rsp->name); 3029 t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
3030 BUG_ON(IS_ERR(t)); 3030 BUG_ON(IS_ERR(t));
3031 rnp = rcu_get_root(rsp); 3031 rnp = rcu_get_root(rsp);
3032 raw_spin_lock_irqsave(&rnp->lock, flags); 3032 raw_spin_lock_irqsave(&rnp->lock, flags);
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 89a588b4478b..b974571126fe 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
740 740
741 __module_get(serv->sv_module); 741 __module_get(serv->sv_module);
742 task = kthread_create_on_node(serv->sv_function, rqstp, 742 task = kthread_create_on_node(serv->sv_function, rqstp,
743 node, serv->sv_name); 743 node, "%s", serv->sv_name);
744 if (IS_ERR(task)) { 744 if (IS_ERR(task)) {
745 error = PTR_ERR(task); 745 error = PTR_ERR(task);
746 module_put(serv->sv_module); 746 module_put(serv->sv_module);