ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook
Subsystems (3)
Sasha Levin
maintainerPATCH 1/3 ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook
From: Fredrik Strupe <[email protected]>
[ Upstream commit 3866f217aaa81bf7165c7f27362eee5d7919c496 ]
call_undef_hook() in traps.c applies the same instr_mask for both 16-bit and 32-bit thumb instructions. If instr_mask then is only 16 bits wide (0xffff as opposed to 0xffffffff), the first half-word of 32-bit thumb instructions will be masked out. This makes the function match 32-bit thumb instructions where the second half-word is equal to instr_val, regardless of the first half-word.
The result in this case is that all undefined 32-bit thumb instructions with the second half-word equal to 0xde01 (udf #1) work as breakpoints and will raise a SIGTRAP instead of a SIGILL, instead of just the one intended 16-bit instruction. An example of such an instruction is 0xeaa0de01, which is unallocated according to Arm ARM and should raise a SIGILL, but instead raises a SIGTRAP.
This patch fixes the issue by setting all the bits in instr_mask, which will still match the intended 16-bit thumb instruction (where the upper half is always 0), but not any 32-bit thumb instructions.
--- arch/arm/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/ptrace.c +2 -2
@@ -227,8 +227,8 @@ static struct undef_hook arm_break_hook = { };static struct undef_hook thumb_break_hook = { - .instr_mask =0xffff , - .instr_val =0xde01 , + .instr_mask =0xffffffff , + .instr_val =0x0000de01 , .cpsr_mask =PSR_T_BIT , .cpsr_val =PSR_T_BIT , .fn = break_trap,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 3/3 NFC: st21nfca: add missed kfree_skb() in an error path
From: Chuhong Yuan <[email protected]>
[ Upstream commit 3decabdc714ca56c944f4669b4cdec5c2c1cea23 ]
st21nfca_tm_send_atr_res() misses to call kfree_skb() in an error path. Add the missed function call to fix it.
--- drivers/nfc/st21nfca/dep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nfc/st21nfca/dep.c +3 -1
@@ -184,8 +184,10 @@ static int st21nfca_tm_send_atr_res(struct nfc_hci_dev *hdev,memcpy (atr_res->gbi, atr_req->gbi, gb_len); r =nfc_set_remote_general_bytes (hdev->ndev, atr_res->gbi, gb_len); -if (r <0 ) +if (r <0 ) { +kfree_skb (skb);return r; + } } info->dep_info.curr_nfc_dep_pni =0 ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 2/3 sched/fair: Don't NUMA balance for kthreads
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 18f855e574d9799a0e7489f8ae6fd8447d0dd74a ]
Stefano reported a crash with using SQPOLL with io_uring:
BUG: kernel NULL pointer dereference, address: 00000000000003b0 CPU: 2 PID: 1307 Comm: io_uring-sq Not tainted 5.7.0-rc7 #11 RIP: 0010:task_numa_work+0x4f/0x2c0 Call Trace: task_work_run+0x68/0xa0 io_sq_thread+0x252/0x3d0 kthread+0xf9/0x130 ret_from_fork+0x35/0x40
which is task_numa_work() oopsing on current->mm being NULL.
The task work is queued by task_tick_numa(), which checks if current->mm is NULL at the time of the call. But this state isn't necessarily persistent, if the kthread is using use_mm() to temporarily adopt the mm of a task.
Change the task_tick_numa() check to exclude kernel threads in general, as it doesn't make sense to attempt ot balance for kthreads anyway.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -2325,7 +2325,7 @@ void task_tick_numa(struct rq *rq, struct task_struct *curr)/* * We don't care about NUMA placement if we don't have memory. */ -if (!curr->mm || (curr->flags &PF_EXITING ) || work->next != work) +if ((curr->flags & (PF_EXITING |PF_KTHREAD )) || work->next != work)return ;/*
Signature · 1 line
2.25.1