From f749fa44e552ac47f0b171f4e09a9cf1642f0c42 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 19 May 2022 09:51:42 -0400 Subject: [PATCH] Fixes for 4.14 Signed-off-by: Sasha Levin --- ...tacktrace-kasan-silence-kasan-warnin.patch | 105 ++++++++++++++ ...e-of-list-iterator-variable-after-lo.patch | 57 ++++++++ ...nds-checking-to-input_set_capability.patch | 65 +++++++++ ...-reference-leak-in-stmfts_input_open.patch | 53 +++++++ ...iq-check-the-return-value-of-kzalloc.patch | 135 ++++++++++++++++++ queue-4.14/series | 7 + ...ll_handler_t-definition-cast-fix-war.patch | 70 +++++++++ ...rove-error-handling-when-port-helper.patch | 55 +++++++ 8 files changed, 547 insertions(+) create mode 100644 queue-4.14/arm-9191-1-arm-stacktrace-kasan-silence-kasan-warnin.patch create mode 100644 queue-4.14/drbd-remove-usage-of-list-iterator-variable-after-lo.patch create mode 100644 queue-4.14/input-add-bounds-checking-to-input_set_capability.patch create mode 100644 queue-4.14/input-stmfts-fix-reference-leak-in-stmfts_input_open.patch create mode 100644 queue-4.14/mips-lantiq-check-the-return-value-of-kzalloc.patch create mode 100644 queue-4.14/um-cleanup-syscall_handler_t-definition-cast-fix-war.patch create mode 100644 queue-4.14/um-port_user-improve-error-handling-when-port-helper.patch diff --git a/queue-4.14/arm-9191-1-arm-stacktrace-kasan-silence-kasan-warnin.patch b/queue-4.14/arm-9191-1-arm-stacktrace-kasan-silence-kasan-warnin.patch new file mode 100644 index 00000000000..71801da1f4b --- /dev/null +++ b/queue-4.14/arm-9191-1-arm-stacktrace-kasan-silence-kasan-warnin.patch @@ -0,0 +1,105 @@ +From 4117c183443d56b4f7e19baf42876c8b7a63d8c7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Apr 2022 10:52:47 +0100 +Subject: ARM: 9191/1: arm/stacktrace, kasan: Silence KASAN warnings in + unwind_frame() + +From: linyujun + +[ Upstream commit 9be4c88bb7924f68f88cfd47d925c2d046f51a73 ] + +The following KASAN warning is detected by QEMU. + +================================================================== +BUG: KASAN: stack-out-of-bounds in unwind_frame+0x508/0x870 +Read of size 4 at addr c36bba90 by task cat/163 + +CPU: 1 PID: 163 Comm: cat Not tainted 5.10.0-rc1 #40 +Hardware name: ARM-Versatile Express +[] (unwind_backtrace) from [] (show_stack+0x10/0x14) +[] (show_stack) from [] (dump_stack+0x98/0xb0) +[] (dump_stack) from [] (print_address_description.constprop.0+0x58/0x4bc) +[] (print_address_description.constprop.0) from [] (kasan_report+0x154/0x170) +[] (kasan_report) from [] (unwind_frame+0x508/0x870) +[] (unwind_frame) from [] (__save_stack_trace+0x110/0x134) +[] (__save_stack_trace) from [] (stack_trace_save+0x8c/0xb4) +[] (stack_trace_save) from [] (kasan_set_track+0x38/0x60) +[] (kasan_set_track) from [] (kasan_set_free_info+0x20/0x2c) +[] (kasan_set_free_info) from [] (__kasan_slab_free+0xec/0x120) +[] (__kasan_slab_free) from [] (kmem_cache_free+0x7c/0x334) +[] (kmem_cache_free) from [] (rcu_core+0x390/0xccc) +[] (rcu_core) from [] (__do_softirq+0x180/0x518) +[] (__do_softirq) from [] (irq_exit+0x9c/0xe0) +[] (irq_exit) from [] (__handle_domain_irq+0xb0/0x110) +[] (__handle_domain_irq) from [] (gic_handle_irq+0xa0/0xb8) +[] (gic_handle_irq) from [] (__irq_svc+0x6c/0x94) +Exception stack(0xc36bb928 to 0xc36bb970) +b920: c36bb9c0 00000000 c0126919 c0101228 c36bb9c0 b76d7730 +b940: c36b8000 c36bb9a0 c3335b00 c01ce0d8 00000003 c36bba3c c36bb940 c36bb978 +b960: c010e298 c011373c 60000013 ffffffff +[] (__irq_svc) from [] (unwind_frame+0x0/0x870) +[] (unwind_frame) from [<00000000>] (0x0) + +The buggy address belongs to the page: +page:(ptrval) refcount:0 mapcount:0 mapping:00000000 index:0x0 pfn:0x636bb +flags: 0x0() +raw: 00000000 00000000 ef867764 00000000 00000000 00000000 ffffffff 00000000 +page dumped because: kasan: bad access detected + +addr c36bba90 is located in stack of task cat/163 at offset 48 in frame: + stack_trace_save+0x0/0xb4 + +this frame has 1 object: + [32, 48) 'trace' + +Memory state around the buggy address: + c36bb980: f1 f1 f1 f1 00 04 f2 f2 00 00 f3 f3 00 00 00 00 + c36bba00: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 +>c36bba80: 00 00 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 + ^ + c36bbb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + c36bbb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +================================================================== + +There is a same issue on x86 and has been resolved by the commit f7d27c35ddff +("x86/mm, kasan: Silence KASAN warnings in get_wchan()"). +The solution could be applied to arm architecture too. + +Signed-off-by: Lin Yujun +Reported-by: He Ying +Signed-off-by: Russell King (Oracle) +Signed-off-by: Sasha Levin +--- + arch/arm/kernel/stacktrace.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c +index 31af81d46aae..21c49d3559db 100644 +--- a/arch/arm/kernel/stacktrace.c ++++ b/arch/arm/kernel/stacktrace.c +@@ -51,17 +51,17 @@ int notrace unwind_frame(struct stackframe *frame) + return -EINVAL; + + frame->sp = frame->fp; +- frame->fp = *(unsigned long *)(fp); +- frame->pc = *(unsigned long *)(fp + 4); ++ frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); ++ frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 4)); + #else + /* check current frame pointer is within bounds */ + if (fp < low + 12 || fp > high - 4) + return -EINVAL; + + /* restore the registers from the stack frame */ +- frame->fp = *(unsigned long *)(fp - 12); +- frame->sp = *(unsigned long *)(fp - 8); +- frame->pc = *(unsigned long *)(fp - 4); ++ frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 12)); ++ frame->sp = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 8)); ++ frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 4)); + #endif + + return 0; +-- +2.35.1 + diff --git a/queue-4.14/drbd-remove-usage-of-list-iterator-variable-after-lo.patch b/queue-4.14/drbd-remove-usage-of-list-iterator-variable-after-lo.patch new file mode 100644 index 00000000000..e4d517d20db --- /dev/null +++ b/queue-4.14/drbd-remove-usage-of-list-iterator-variable-after-lo.patch @@ -0,0 +1,57 @@ +From 76668dc00c7c5664d9a810a5aab97aa6ada9e286 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Apr 2022 00:03:48 +0200 +Subject: drbd: remove usage of list iterator variable after loop + +From: Jakob Koschel + +[ Upstream commit 901aeda62efa21f2eae937bccb71b49ae531be06 ] + +In preparation to limit the scope of a list iterator to the list +traversal loop, use a dedicated pointer to iterate through the list [1]. + +Since that variable should not be used past the loop iteration, a +separate variable is used to 'remember the current location within the +loop'. + +To either continue iterating from that position or skip the iteration +(if the previous iteration was complete) list_prepare_entry() is used. + +Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] +Signed-off-by: Jakob Koschel +Link: https://lore.kernel.org/r/20220331220349.885126-1-jakobkoschel@gmail.com +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + drivers/block/drbd/drbd_main.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c +index b998e3abca7a..1e02cb60b65b 100644 +--- a/drivers/block/drbd/drbd_main.c ++++ b/drivers/block/drbd/drbd_main.c +@@ -195,7 +195,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr, + unsigned int set_size) + { + struct drbd_request *r; +- struct drbd_request *req = NULL; ++ struct drbd_request *req = NULL, *tmp = NULL; + int expect_epoch = 0; + int expect_size = 0; + +@@ -249,8 +249,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr, + * to catch requests being barrier-acked "unexpectedly". + * It usually should find the same req again, or some READ preceding it. */ + list_for_each_entry(req, &connection->transfer_log, tl_requests) +- if (req->epoch == expect_epoch) ++ if (req->epoch == expect_epoch) { ++ tmp = req; + break; ++ } ++ req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests); + list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) { + if (req->epoch != expect_epoch) + break; +-- +2.35.1 + diff --git a/queue-4.14/input-add-bounds-checking-to-input_set_capability.patch b/queue-4.14/input-add-bounds-checking-to-input_set_capability.patch new file mode 100644 index 00000000000..5bfea215a7b --- /dev/null +++ b/queue-4.14/input-add-bounds-checking-to-input_set_capability.patch @@ -0,0 +1,65 @@ +From 937e65f6c35ec8121bde62e8a883e33b5c4ccefd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 20 Mar 2022 21:55:27 -0700 +Subject: Input: add bounds checking to input_set_capability() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jeff LaBundy + +[ Upstream commit 409353cbe9fe48f6bc196114c442b1cff05a39bc ] + +Update input_set_capability() to prevent kernel panic in case the +event code exceeds the bitmap for the given event type. + +Suggested-by: Tomasz Moń +Signed-off-by: Jeff LaBundy +Reviewed-by: Tomasz Moń +Link: https://lore.kernel.org/r/20220320032537.545250-1-jeff@labundy.com +Signed-off-by: Dmitry Torokhov +Signed-off-by: Sasha Levin +--- + drivers/input/input.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/drivers/input/input.c b/drivers/input/input.c +index cadb368be8ef..f9f3d6261dc5 100644 +--- a/drivers/input/input.c ++++ b/drivers/input/input.c +@@ -50,6 +50,17 @@ static DEFINE_MUTEX(input_mutex); + + static const struct input_value input_value_sync = { EV_SYN, SYN_REPORT, 1 }; + ++static const unsigned int input_max_code[EV_CNT] = { ++ [EV_KEY] = KEY_MAX, ++ [EV_REL] = REL_MAX, ++ [EV_ABS] = ABS_MAX, ++ [EV_MSC] = MSC_MAX, ++ [EV_SW] = SW_MAX, ++ [EV_LED] = LED_MAX, ++ [EV_SND] = SND_MAX, ++ [EV_FF] = FF_MAX, ++}; ++ + static inline int is_event_supported(unsigned int code, + unsigned long *bm, unsigned int max) + { +@@ -1915,6 +1926,14 @@ EXPORT_SYMBOL(input_free_device); + */ + void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code) + { ++ if (type < EV_CNT && input_max_code[type] && ++ code > input_max_code[type]) { ++ pr_err("%s: invalid code %u for type %u\n", __func__, code, ++ type); ++ dump_stack(); ++ return; ++ } ++ + switch (type) { + case EV_KEY: + __set_bit(code, dev->keybit); +-- +2.35.1 + diff --git a/queue-4.14/input-stmfts-fix-reference-leak-in-stmfts_input_open.patch b/queue-4.14/input-stmfts-fix-reference-leak-in-stmfts_input_open.patch new file mode 100644 index 00000000000..5e876fe1b6b --- /dev/null +++ b/queue-4.14/input-stmfts-fix-reference-leak-in-stmfts_input_open.patch @@ -0,0 +1,53 @@ +From d4eff6a79e1eb98644514d04d643906ee535daba Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 20 Mar 2022 21:56:38 -0700 +Subject: Input: stmfts - fix reference leak in stmfts_input_open + +From: Zheng Yongjun + +[ Upstream commit 26623eea0da3476446909af96c980768df07bbd9 ] + +pm_runtime_get_sync() will increment pm usage counter even it +failed. Forgetting to call pm_runtime_put_noidle will result +in reference leak in stmfts_input_open, so we should fix it. + +Signed-off-by: Zheng Yongjun +Link: https://lore.kernel.org/r/20220317131604.53538-1-zhengyongjun3@huawei.com +Signed-off-by: Dmitry Torokhov +Signed-off-by: Sasha Levin +--- + drivers/input/touchscreen/stmfts.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c +index d9e93dabbca2..9007027a7ad9 100644 +--- a/drivers/input/touchscreen/stmfts.c ++++ b/drivers/input/touchscreen/stmfts.c +@@ -344,11 +344,11 @@ static int stmfts_input_open(struct input_dev *dev) + + err = pm_runtime_get_sync(&sdata->client->dev); + if (err < 0) +- return err; ++ goto out; + + err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON); + if (err) +- return err; ++ goto out; + + mutex_lock(&sdata->mutex); + sdata->running = true; +@@ -371,7 +371,9 @@ static int stmfts_input_open(struct input_dev *dev) + "failed to enable touchkey\n"); + } + +- return 0; ++out: ++ pm_runtime_put_noidle(&sdata->client->dev); ++ return err; + } + + static void stmfts_input_close(struct input_dev *dev) +-- +2.35.1 + diff --git a/queue-4.14/mips-lantiq-check-the-return-value-of-kzalloc.patch b/queue-4.14/mips-lantiq-check-the-return-value-of-kzalloc.patch new file mode 100644 index 00000000000..de2bac035cd --- /dev/null +++ b/queue-4.14/mips-lantiq-check-the-return-value-of-kzalloc.patch @@ -0,0 +1,135 @@ +From 1fdab3e7fc57818fd1dac0dc5aaef5b63d611485 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 25 Mar 2022 19:49:41 +0800 +Subject: MIPS: lantiq: check the return value of kzalloc() + +From: Xiaoke Wang + +[ Upstream commit 34123208bbcc8c884a0489f543a23fe9eebb5514 ] + +kzalloc() is a memory allocation function which can return NULL when +some internal memory errors happen. So it is better to check the +return value of it to prevent potential wrong memory access or +memory leak. + +Signed-off-by: Xiaoke Wang +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/lantiq/falcon/sysctrl.c | 2 ++ + arch/mips/lantiq/xway/gptu.c | 2 ++ + arch/mips/lantiq/xway/sysctrl.c | 46 ++++++++++++++++++++----------- + 3 files changed, 34 insertions(+), 16 deletions(-) + +diff --git a/arch/mips/lantiq/falcon/sysctrl.c b/arch/mips/lantiq/falcon/sysctrl.c +index 82bbd0e2e298..714d92659489 100644 +--- a/arch/mips/lantiq/falcon/sysctrl.c ++++ b/arch/mips/lantiq/falcon/sysctrl.c +@@ -169,6 +169,8 @@ static inline void clkdev_add_sys(const char *dev, unsigned int module, + { + struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); + ++ if (!clk) ++ return; + clk->cl.dev_id = dev; + clk->cl.con_id = NULL; + clk->cl.clk = clk; +diff --git a/arch/mips/lantiq/xway/gptu.c b/arch/mips/lantiq/xway/gptu.c +index e304aabd6678..7d4081d67d61 100644 +--- a/arch/mips/lantiq/xway/gptu.c ++++ b/arch/mips/lantiq/xway/gptu.c +@@ -124,6 +124,8 @@ static inline void clkdev_add_gptu(struct device *dev, const char *con, + { + struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); + ++ if (!clk) ++ return; + clk->cl.dev_id = dev_name(dev); + clk->cl.con_id = con; + clk->cl.clk = clk; +diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c +index c05bed624075..1b1142c7bb85 100644 +--- a/arch/mips/lantiq/xway/sysctrl.c ++++ b/arch/mips/lantiq/xway/sysctrl.c +@@ -313,6 +313,8 @@ static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate, + { + struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); + ++ if (!clk) ++ return; + clk->cl.dev_id = dev; + clk->cl.con_id = con; + clk->cl.clk = clk; +@@ -336,6 +338,8 @@ static void clkdev_add_cgu(const char *dev, const char *con, + { + struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); + ++ if (!clk) ++ return; + clk->cl.dev_id = dev; + clk->cl.con_id = con; + clk->cl.clk = clk; +@@ -354,24 +358,28 @@ static void clkdev_add_pci(void) + struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL); + + /* main pci clock */ +- clk->cl.dev_id = "17000000.pci"; +- clk->cl.con_id = NULL; +- clk->cl.clk = clk; +- clk->rate = CLOCK_33M; +- clk->rates = valid_pci_rates; +- clk->enable = pci_enable; +- clk->disable = pmu_disable; +- clk->module = 0; +- clk->bits = PMU_PCI; +- clkdev_add(&clk->cl); ++ if (clk) { ++ clk->cl.dev_id = "17000000.pci"; ++ clk->cl.con_id = NULL; ++ clk->cl.clk = clk; ++ clk->rate = CLOCK_33M; ++ clk->rates = valid_pci_rates; ++ clk->enable = pci_enable; ++ clk->disable = pmu_disable; ++ clk->module = 0; ++ clk->bits = PMU_PCI; ++ clkdev_add(&clk->cl); ++ } + + /* use internal/external bus clock */ +- clk_ext->cl.dev_id = "17000000.pci"; +- clk_ext->cl.con_id = "external"; +- clk_ext->cl.clk = clk_ext; +- clk_ext->enable = pci_ext_enable; +- clk_ext->disable = pci_ext_disable; +- clkdev_add(&clk_ext->cl); ++ if (clk_ext) { ++ clk_ext->cl.dev_id = "17000000.pci"; ++ clk_ext->cl.con_id = "external"; ++ clk_ext->cl.clk = clk_ext; ++ clk_ext->enable = pci_ext_enable; ++ clk_ext->disable = pci_ext_disable; ++ clkdev_add(&clk_ext->cl); ++ } + } + + /* xway socs can generate clocks on gpio pins */ +@@ -391,9 +399,15 @@ static void clkdev_add_clkout(void) + char *name; + + name = kzalloc(sizeof("clkout0"), GFP_KERNEL); ++ if (!name) ++ continue; + sprintf(name, "clkout%d", i); + + clk = kzalloc(sizeof(struct clk), GFP_KERNEL); ++ if (!clk) { ++ kfree(name); ++ continue; ++ } + clk->cl.dev_id = "1f103000.cgu"; + clk->cl.con_id = name; + clk->cl.clk = clk; +-- +2.35.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 0a3d63c4ea5..a90d95f5dcd 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -1 +1,8 @@ floppy-use-a-statically-allocated-error-counter.patch +um-cleanup-syscall_handler_t-definition-cast-fix-war.patch +um-port_user-improve-error-handling-when-port-helper.patch +input-add-bounds-checking-to-input_set_capability.patch +input-stmfts-fix-reference-leak-in-stmfts_input_open.patch +mips-lantiq-check-the-return-value-of-kzalloc.patch +drbd-remove-usage-of-list-iterator-variable-after-lo.patch +arm-9191-1-arm-stacktrace-kasan-silence-kasan-warnin.patch diff --git a/queue-4.14/um-cleanup-syscall_handler_t-definition-cast-fix-war.patch b/queue-4.14/um-cleanup-syscall_handler_t-definition-cast-fix-war.patch new file mode 100644 index 00000000000..b4a98673f15 --- /dev/null +++ b/queue-4.14/um-cleanup-syscall_handler_t-definition-cast-fix-war.patch @@ -0,0 +1,70 @@ +From 5991af8b6c34354c714f8a7b181bd4c95f2dfd63 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 10 Feb 2022 11:43:53 +0800 +Subject: um: Cleanup syscall_handler_t definition/cast, fix warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: David Gow + +[ Upstream commit f4f03f299a56ce4d73c5431e0327b3b6cb55ebb9 ] + +The syscall_handler_t type for x86_64 was defined as 'long (*)(void)', +but always cast to 'long (*)(long, long, long, long, long, long)' before +use. This now triggers a warning (see below). + +Define syscall_handler_t as the latter instead, and remove the cast. +This simplifies the code, and fixes the warning. + +Warning: +In file included from ../arch/um/include/asm/processor-generic.h:13 + from ../arch/x86/um/asm/processor.h:41 + from ../include/linux/rcupdate.h:30 + from ../include/linux/rculist.h:11 + from ../include/linux/pid.h:5 + from ../include/linux/sched.h:14 + from ../include/linux/ptrace.h:6 + from ../arch/um/kernel/skas/syscall.c:7: +../arch/um/kernel/skas/syscall.c: In function ‘handle_syscall’: +../arch/x86/um/shared/sysdep/syscalls_64.h:18:11: warning: cast between incompatible function types from ‘long int (*)(void)’ to ‘long int (*)(long int, long int, long int, long int, long int, long int)’ [ +-Wcast-function-type] + 18 | (((long (*)(long, long, long, long, long, long)) \ + | ^ +../arch/x86/um/asm/ptrace.h:36:62: note: in definition of macro ‘PT_REGS_SET_SYSCALL_RETURN’ + 36 | #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res)) + | ^~~ +../arch/um/kernel/skas/syscall.c:46:33: note: in expansion of macro ‘EXECUTE_SYSCALL’ + 46 | EXECUTE_SYSCALL(syscall, regs)); + | ^~~~~~~~~~~~~~~ + +Signed-off-by: David Gow +Signed-off-by: Richard Weinberger +Signed-off-by: Sasha Levin +--- + arch/x86/um/shared/sysdep/syscalls_64.h | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/arch/x86/um/shared/sysdep/syscalls_64.h b/arch/x86/um/shared/sysdep/syscalls_64.h +index 8a7d5e1da98e..1e6875b4ffd8 100644 +--- a/arch/x86/um/shared/sysdep/syscalls_64.h ++++ b/arch/x86/um/shared/sysdep/syscalls_64.h +@@ -10,13 +10,12 @@ + #include + #include + +-typedef long syscall_handler_t(void); ++typedef long syscall_handler_t(long, long, long, long, long, long); + + extern syscall_handler_t *sys_call_table[]; + + #define EXECUTE_SYSCALL(syscall, regs) \ +- (((long (*)(long, long, long, long, long, long)) \ +- (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \ ++ (((*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \ + UPT_SYSCALL_ARG2(®s->regs), \ + UPT_SYSCALL_ARG3(®s->regs), \ + UPT_SYSCALL_ARG4(®s->regs), \ +-- +2.35.1 + diff --git a/queue-4.14/um-port_user-improve-error-handling-when-port-helper.patch b/queue-4.14/um-port_user-improve-error-handling-when-port-helper.patch new file mode 100644 index 00000000000..1fc58ef348e --- /dev/null +++ b/queue-4.14/um-port_user-improve-error-handling-when-port-helper.patch @@ -0,0 +1,55 @@ +From 533d4814678807a038ae74fdbdcab780f5af538b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 3 Mar 2022 01:53:32 -0600 +Subject: um: port_user: Improve error handling when port-helper is not found + +From: Glenn Washburn + +[ Upstream commit 3cb5a7f167c620a8b0e38b0446df2e024d2243dc ] + +Check if port-helper exists and is executable. If not, write an error +message to the kernel log with information to help the user diagnose the +issue and exit with an error. If UML_PORT_HELPER was not set, write a +message suggesting that the user set it. This makes it easier to understand +why telneting to the UML instance is failing and what can be done to fix it. + +Signed-off-by: Glenn Washburn +Signed-off-by: Richard Weinberger +Signed-off-by: Sasha Levin +--- + arch/um/drivers/port_user.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c +index 9a8e1b64c22e..d3cf5db1350a 100644 +--- a/arch/um/drivers/port_user.c ++++ b/arch/um/drivers/port_user.c +@@ -5,6 +5,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -175,6 +176,17 @@ int port_connection(int fd, int *socket, int *pid_out) + if (new < 0) + return -errno; + ++ err = os_access(argv[2], X_OK); ++ if (err < 0) { ++ printk(UM_KERN_ERR "port_connection : error accessing port-helper " ++ "executable at %s: %s\n", argv[2], strerror(-err)); ++ if (env == NULL) ++ printk(UM_KERN_ERR "Set UML_PORT_HELPER environment " ++ "variable to path to uml-utilities port-helper " ++ "binary\n"); ++ goto out_close; ++ } ++ + err = os_pipe(socket, 0, 0); + if (err < 0) + goto out_close; +-- +2.35.1 + -- 2.47.3