aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-11-30 15:43:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-30 15:43:17 -0500
commitb6839ef26e549de68c10359d45163b0cfb031183 (patch)
treeb4cd7b04c0af7acbd7a3be8149410520075a3ad7
parentd7aca8a78c8bc5d3707691aab13cb4f7f6de696f (diff)
parent6484a677294aa5d08c0210f2f387ebb9be646115 (diff)
Merge tag 'char-misc-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc fixes from Greg KH: "Here are a few small char/misc driver fixes for 4.20-rc5 that resolve a number of reported issues. The "largest" here is the thunderbolt patch, which resolves an issue with NVM upgrade, the smallest being some fsi driver fixes. There's also a hyperv bugfix, and the usual binder bugfixes. All of these have been in linux-next with no reported issues" * tag 'char-misc-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: misc: mic/scif: fix copy-paste error in scif_create_remote_lookup thunderbolt: Prevent root port runtime suspend during NVM upgrade Drivers: hv: vmbus: check the creation_status in vmbus_establish_gpadl() binder: fix race that allows malicious free of live buffer fsi: fsi-scom.c: Remove duplicate header fsi: master-ast-cf: select GENERIC_ALLOCATOR
-rw-r--r--drivers/android/binder.c21
-rw-r--r--drivers/android/binder_alloc.c16
-rw-r--r--drivers/android/binder_alloc.h3
-rw-r--r--drivers/fsi/Kconfig1
-rw-r--r--drivers/fsi/fsi-scom.c1
-rw-r--r--drivers/hv/channel.c8
-rw-r--r--drivers/misc/mic/scif/scif_rma.c2
-rw-r--r--drivers/thunderbolt/switch.c40
8 files changed, 67 insertions, 25 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index cb30a524d16d..9f1000d2a40c 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2974,7 +2974,6 @@ static void binder_transaction(struct binder_proc *proc,
2974 t->buffer = NULL; 2974 t->buffer = NULL;
2975 goto err_binder_alloc_buf_failed; 2975 goto err_binder_alloc_buf_failed;
2976 } 2976 }
2977 t->buffer->allow_user_free = 0;
2978 t->buffer->debug_id = t->debug_id; 2977 t->buffer->debug_id = t->debug_id;
2979 t->buffer->transaction = t; 2978 t->buffer->transaction = t;
2980 t->buffer->target_node = target_node; 2979 t->buffer->target_node = target_node;
@@ -3510,14 +3509,18 @@ static int binder_thread_write(struct binder_proc *proc,
3510 3509
3511 buffer = binder_alloc_prepare_to_free(&proc->alloc, 3510 buffer = binder_alloc_prepare_to_free(&proc->alloc,
3512 data_ptr); 3511 data_ptr);
3513 if (buffer == NULL) { 3512 if (IS_ERR_OR_NULL(buffer)) {
3514 binder_user_error("%d:%d BC_FREE_BUFFER u%016llx no match\n", 3513 if (PTR_ERR(buffer) == -EPERM) {
3515 proc->pid, thread->pid, (u64)data_ptr); 3514 binder_user_error(
3516 break; 3515 "%d:%d BC_FREE_BUFFER u%016llx matched unreturned or currently freeing buffer\n",
3517 } 3516 proc->pid, thread->pid,
3518 if (!buffer->allow_user_free) { 3517 (u64)data_ptr);
3519 binder_user_error("%d:%d BC_FREE_BUFFER u%016llx matched unreturned buffer\n", 3518 } else {
3520 proc->pid, thread->pid, (u64)data_ptr); 3519 binder_user_error(
3520 "%d:%d BC_FREE_BUFFER u%016llx no match\n",
3521 proc->pid, thread->pid,
3522 (u64)data_ptr);
3523 }
3521 break; 3524 break;
3522 } 3525 }
3523 binder_debug(BINDER_DEBUG_FREE_BUFFER, 3526 binder_debug(BINDER_DEBUG_FREE_BUFFER,
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 64fd96eada31..030c98f35cca 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -151,16 +151,12 @@ static struct binder_buffer *binder_alloc_prepare_to_free_locked(
151 else { 151 else {
152 /* 152 /*
153 * Guard against user threads attempting to 153 * Guard against user threads attempting to
154 * free the buffer twice 154 * free the buffer when in use by kernel or
155 * after it's already been freed.
155 */ 156 */
156 if (buffer->free_in_progress) { 157 if (!buffer->allow_user_free)
157 binder_alloc_debug(BINDER_DEBUG_USER_ERROR, 158 return ERR_PTR(-EPERM);
158 "%d:%d FREE_BUFFER u%016llx user freed buffer twice\n", 159 buffer->allow_user_free = 0;
159 alloc->pid, current->pid,
160 (u64)user_ptr);
161 return NULL;
162 }
163 buffer->free_in_progress = 1;
164 return buffer; 160 return buffer;
165 } 161 }
166 } 162 }
@@ -500,7 +496,7 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
500 496
501 rb_erase(best_fit, &alloc->free_buffers); 497 rb_erase(best_fit, &alloc->free_buffers);
502 buffer->free = 0; 498 buffer->free = 0;
503 buffer->free_in_progress = 0; 499 buffer->allow_user_free = 0;
504 binder_insert_allocated_buffer_locked(alloc, buffer); 500 binder_insert_allocated_buffer_locked(alloc, buffer);
505 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, 501 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
506 "%d: binder_alloc_buf size %zd got %pK\n", 502 "%d: binder_alloc_buf size %zd got %pK\n",
diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
index 9ef64e563856..fb3238c74c8a 100644
--- a/drivers/android/binder_alloc.h
+++ b/drivers/android/binder_alloc.h
@@ -50,8 +50,7 @@ struct binder_buffer {
50 unsigned free:1; 50 unsigned free:1;
51 unsigned allow_user_free:1; 51 unsigned allow_user_free:1;
52 unsigned async_transaction:1; 52 unsigned async_transaction:1;
53 unsigned free_in_progress:1; 53 unsigned debug_id:29;
54 unsigned debug_id:28;
55 54
56 struct binder_transaction *transaction; 55 struct binder_transaction *transaction;
57 56
diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig
index af3a20dd5aa4..99c99a5d57fe 100644
--- a/drivers/fsi/Kconfig
+++ b/drivers/fsi/Kconfig
@@ -46,6 +46,7 @@ config FSI_MASTER_AST_CF
46 tristate "FSI master based on Aspeed ColdFire coprocessor" 46 tristate "FSI master based on Aspeed ColdFire coprocessor"
47 depends on GPIOLIB 47 depends on GPIOLIB
48 depends on GPIO_ASPEED 48 depends on GPIO_ASPEED
49 select GENERIC_ALLOCATOR
49 ---help--- 50 ---help---
50 This option enables a FSI master using the AST2400 and AST2500 GPIO 51 This option enables a FSI master using the AST2400 and AST2500 GPIO
51 lines driven by the internal ColdFire coprocessor. This requires 52 lines driven by the internal ColdFire coprocessor. This requires
diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c
index df94021dd9d1..81dc01ac2351 100644
--- a/drivers/fsi/fsi-scom.c
+++ b/drivers/fsi/fsi-scom.c
@@ -20,7 +20,6 @@
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/cdev.h>
24#include <linux/list.h> 23#include <linux/list.h>
25 24
26#include <uapi/linux/fsi.h> 25#include <uapi/linux/fsi.h>
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index de8193f3b838..fe00b12e4417 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -516,6 +516,14 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
516 } 516 }
517 wait_for_completion(&msginfo->waitevent); 517 wait_for_completion(&msginfo->waitevent);
518 518
519 if (msginfo->response.gpadl_created.creation_status != 0) {
520 pr_err("Failed to establish GPADL: err = 0x%x\n",
521 msginfo->response.gpadl_created.creation_status);
522
523 ret = -EDQUOT;
524 goto cleanup;
525 }
526
519 if (channel->rescind) { 527 if (channel->rescind) {
520 ret = -ENODEV; 528 ret = -ENODEV;
521 goto cleanup; 529 goto cleanup;
diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c
index c824329f7012..0e4193cb08cf 100644
--- a/drivers/misc/mic/scif/scif_rma.c
+++ b/drivers/misc/mic/scif/scif_rma.c
@@ -416,7 +416,7 @@ static int scif_create_remote_lookup(struct scif_dev *remote_dev,
416 if (err) 416 if (err)
417 goto error_window; 417 goto error_window;
418 err = scif_map_page(&window->num_pages_lookup.lookup[j], 418 err = scif_map_page(&window->num_pages_lookup.lookup[j],
419 vmalloc_dma_phys ? 419 vmalloc_num_pages ?
420 vmalloc_to_page(&window->num_pages[i]) : 420 vmalloc_to_page(&window->num_pages[i]) :
421 virt_to_page(&window->num_pages[i]), 421 virt_to_page(&window->num_pages[i]),
422 remote_dev); 422 remote_dev);
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 52ff854f0d6c..cd96994dc094 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -863,6 +863,30 @@ static ssize_t key_store(struct device *dev, struct device_attribute *attr,
863} 863}
864static DEVICE_ATTR(key, 0600, key_show, key_store); 864static DEVICE_ATTR(key, 0600, key_show, key_store);
865 865
866static void nvm_authenticate_start(struct tb_switch *sw)
867{
868 struct pci_dev *root_port;
869
870 /*
871 * During host router NVM upgrade we should not allow root port to
872 * go into D3cold because some root ports cannot trigger PME
873 * itself. To be on the safe side keep the root port in D0 during
874 * the whole upgrade process.
875 */
876 root_port = pci_find_pcie_root_port(sw->tb->nhi->pdev);
877 if (root_port)
878 pm_runtime_get_noresume(&root_port->dev);
879}
880
881static void nvm_authenticate_complete(struct tb_switch *sw)
882{
883 struct pci_dev *root_port;
884
885 root_port = pci_find_pcie_root_port(sw->tb->nhi->pdev);
886 if (root_port)
887 pm_runtime_put(&root_port->dev);
888}
889
866static ssize_t nvm_authenticate_show(struct device *dev, 890static ssize_t nvm_authenticate_show(struct device *dev,
867 struct device_attribute *attr, char *buf) 891 struct device_attribute *attr, char *buf)
868{ 892{
@@ -912,10 +936,18 @@ static ssize_t nvm_authenticate_store(struct device *dev,
912 936
913 sw->nvm->authenticating = true; 937 sw->nvm->authenticating = true;
914 938
915 if (!tb_route(sw)) 939 if (!tb_route(sw)) {
940 /*
941 * Keep root port from suspending as long as the
942 * NVM upgrade process is running.
943 */
944 nvm_authenticate_start(sw);
916 ret = nvm_authenticate_host(sw); 945 ret = nvm_authenticate_host(sw);
917 else 946 if (ret)
947 nvm_authenticate_complete(sw);
948 } else {
918 ret = nvm_authenticate_device(sw); 949 ret = nvm_authenticate_device(sw);
950 }
919 pm_runtime_mark_last_busy(&sw->dev); 951 pm_runtime_mark_last_busy(&sw->dev);
920 pm_runtime_put_autosuspend(&sw->dev); 952 pm_runtime_put_autosuspend(&sw->dev);
921 } 953 }
@@ -1334,6 +1366,10 @@ static int tb_switch_add_dma_port(struct tb_switch *sw)
1334 if (ret <= 0) 1366 if (ret <= 0)
1335 return ret; 1367 return ret;
1336 1368
1369 /* Now we can allow root port to suspend again */
1370 if (!tb_route(sw))
1371 nvm_authenticate_complete(sw);
1372
1337 if (status) { 1373 if (status) {
1338 tb_sw_info(sw, "switch flash authentication failed\n"); 1374 tb_sw_info(sw, "switch flash authentication failed\n");
1339 tb_switch_set_uuid(sw); 1375 tb_switch_set_uuid(sw);