]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drivers: avoid format strings in names passed to alloc_workqueue()
authorKees Cook <keescook@chromium.org>
Wed, 3 Jul 2013 22:04:57 +0000 (15:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Jul 2013 23:07:41 +0000 (16:07 -0700)
For the workqueue creation interfaces that do not expect format strings,
make sure they cannot accidently be parsed that way.  Additionally, clean
up calls made with a single parameter that would 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>
13 files changed:
crypto/pcrypt.c
drivers/media/pci/cx18/cx18-driver.c
drivers/message/i2o/driver.c
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rtlwifi/base.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/shpchp_core.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi_transport_fc.c
include/linux/workqueue.h
net/bluetooth/hci_core.c
net/mac80211/main.c

index b2c99dc1c5e2f244bab9cf8fafcedb0860df67f6..f8c920cafe639c8451349e15b3f1e22e19da80e4 100644 (file)
@@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
 
        get_online_cpus();
 
-       pcrypt->wq = alloc_workqueue(name,
-                                    WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
+       pcrypt->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE,
+                                    1, name);
        if (!pcrypt->wq)
                goto err;
 
index 67b61cf3e03a32fdf6e8e61fc4c3152d5a84c634..004d8ace5019a7921e1ff7e0cc189e4c260beffa 100644 (file)
@@ -695,7 +695,7 @@ static int cx18_create_in_workq(struct cx18 *cx)
 {
        snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
                 cx->v4l2_dev.name);
-       cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0);
+       cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name);
        if (cx->in_work_queue == NULL) {
                CX18_ERR("Unable to create incoming mailbox handler thread\n");
                return -ENOMEM;
index 8a5b2d8f4daf8b0996102abcf6dcdf2452815e9f..813eaa33fa1431af96a2c2f3ac40b1000dd9ed7b 100644 (file)
@@ -84,8 +84,8 @@ int i2o_driver_register(struct i2o_driver *drv)
        osm_debug("Register driver %s\n", drv->name);
 
        if (drv->event) {
-               drv->event_queue = alloc_workqueue(drv->name,
-                                                  WQ_MEM_RECLAIM, 1);
+               drv->event_queue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1,
+                                                  drv->name);
                if (!drv->event_queue) {
                        osm_err("Could not initialize event queue for driver "
                                "%s\n", drv->name);
index 90dc14336980c2bcc344a4c5e97d8e4033fa9d95..c8b9ef0c21f826bd0247d0e145424ac3722d6470 100644 (file)
@@ -1321,7 +1321,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
         * Initialize work.
         */
        rt2x00dev->workqueue =
-           alloc_ordered_workqueue(wiphy_name(rt2x00dev->hw->wiphy), 0);
+           alloc_ordered_workqueue("%s", 0, wiphy_name(rt2x00dev->hw->wiphy));
        if (!rt2x00dev->workqueue) {
                retval = -ENOMEM;
                goto exit;
index af59dd5718e1b90eab623b8b04bf94b0332fce45..a5f223145b0f707b92923f107c45cfcb732468a9 100644 (file)
@@ -380,7 +380,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
 
        /* <2> work queue */
        rtlpriv->works.hw = hw;
-       rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0);
+       rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
        INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
                          (void *)rtl_watchdog_wq_callback);
        INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
index 5127f3f418211496ddf44b335ccc5ab44fbac856..b2255736ac81fa819e651f40deb17a6102c4240a 100644 (file)
@@ -773,14 +773,12 @@ static void pcie_shutdown_notification(struct controller *ctrl)
 static int pcie_init_slot(struct controller *ctrl)
 {
        struct slot *slot;
-       char name[32];
 
        slot = kzalloc(sizeof(*slot), GFP_KERNEL);
        if (!slot)
                return -ENOMEM;
 
-       snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
-       slot->wq = alloc_workqueue(name, 0, 0);
+       slot->wq = alloc_workqueue("pciehp-%u", 0, 0, PSN(ctrl));
        if (!slot->wq)
                goto abort;
 
index 3100c52c837cfceccc7314646898f30846c96b39..d3f757df691c9c6bf46cbb26caca51ff59fb51e6 100644 (file)
@@ -128,8 +128,7 @@ static int init_slots(struct controller *ctrl)
                slot->hpc_ops = ctrl->hpc_ops;
                slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
 
-               snprintf(name, sizeof(name), "shpchp-%d", slot->number);
-               slot->wq = alloc_workqueue(name, 0, 0);
+               slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number);
                if (!slot->wq) {
                        retval = -ENOMEM;
                        goto error_info;
index d24a2867bc21cb885506f9d35d0fbe397e27400a..a1f5ac7a9806dffb6c7905f15771283ae2766c33 100644 (file)
@@ -4996,7 +4996,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 
        snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq",
                 phba->shost->host_no);
-       phba->wq = alloc_workqueue(phba->wq_name, WQ_MEM_RECLAIM, 1);
+       phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, phba->wq_name);
        if (!phba->wq) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                            "BM_%d : beiscsi_dev_probe-"
index 4d231c12463eb38ad29d5b3c4ca25f4af24d99fa..b246b3c26912a89f88c5738c31c296c3a67c32f9 100644 (file)
@@ -7060,8 +7060,8 @@ skip_retry_init:
        }
        INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
 
-       sprintf(buf, "qla4xxx_%lu_task", ha->host_no);
-       ha->task_wq = alloc_workqueue(buf, WQ_MEM_RECLAIM, 1);
+       ha->task_wq = alloc_workqueue("qla4xxx_%lu_task", WQ_MEM_RECLAIM, 1,
+                                     ha->host_no);
        if (!ha->task_wq) {
                ql4_printk(KERN_WARNING, ha, "Unable to start task thread!\n");
                ret = -ENODEV;
index e106c276aa00275ce1564ed5cccba739e62d6804..4628fd5e068859c4cec9cead369cb9a67a9409c8 100644 (file)
@@ -435,7 +435,7 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
 
        snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
                 "fc_wq_%d", shost->host_no);
-       fc_host->work_q = alloc_workqueue(fc_host->work_q_name, 0, 0);
+       fc_host->work_q = alloc_workqueue("%s", 0, 0, fc_host->work_q_name);
        if (!fc_host->work_q)
                return -ENOMEM;
 
@@ -443,8 +443,8 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
        snprintf(fc_host->devloss_work_q_name,
                 sizeof(fc_host->devloss_work_q_name),
                 "fc_dl_%d", shost->host_no);
-       fc_host->devloss_work_q =
-                       alloc_workqueue(fc_host->devloss_work_q_name, 0, 0);
+       fc_host->devloss_work_q = alloc_workqueue("%s", 0, 0,
+                                       fc_host->devloss_work_q_name);
        if (!fc_host->devloss_work_q) {
                destroy_workqueue(fc_host->work_q);
                fc_host->work_q = NULL;
index a9f4119c7e2e3daa4ee63e56dee36475647c57d8..a0ed78ab54d74b3f60450745fd98c5bf1491e12c 100644 (file)
@@ -445,11 +445,12 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
        alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
 
 #define create_workqueue(name)                                         \
-       alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
+       alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, (name))
 #define create_freezable_workqueue(name)                               \
-       alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
+       alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
+                       1, (name))
 #define create_singlethread_workqueue(name)                            \
-       alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
+       alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
index ace5e55fe5a32ed01fd8ca3c0c63c802632ac547..db7de80b88a2758ea25a630c3209f87d08faff7c 100644 (file)
@@ -2211,16 +2211,15 @@ int hci_register_dev(struct hci_dev *hdev)
        list_add(&hdev->list, &hci_dev_list);
        write_unlock(&hci_dev_list_lock);
 
-       hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
-                                         WQ_MEM_RECLAIM, 1);
+       hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
+                                         WQ_MEM_RECLAIM, 1, hdev->name);
        if (!hdev->workqueue) {
                error = -ENOMEM;
                goto err;
        }
 
-       hdev->req_workqueue = alloc_workqueue(hdev->name,
-                                             WQ_HIGHPRI | WQ_UNBOUND |
-                                             WQ_MEM_RECLAIM, 1);
+       hdev->req_workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
+                                             WQ_MEM_RECLAIM, 1, hdev->name);
        if (!hdev->req_workqueue) {
                destroy_workqueue(hdev->workqueue);
                error = -ENOMEM;
index 8a7bfc47d5778fd7bbc3f561ecf483996c2041e1..8eae74ac4e1ecab21b8b8e7372c18e6a5299eaf1 100644 (file)
@@ -921,7 +921,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
                hw->queues = IEEE80211_MAX_QUEUES;
 
        local->workqueue =
-               alloc_ordered_workqueue(wiphy_name(local->hw.wiphy), 0);
+               alloc_ordered_workqueue("%s", 0, wiphy_name(local->hw.wiphy));
        if (!local->workqueue) {
                result = -ENOMEM;
                goto fail_workqueue;