[PATCH v3 net] ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()

2024-11-23 Thread Jinghao Jia
leaves the function without a terminator. Zero the on-stack buffer to avoid this possible UB. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402100205.pwxiz1zk-...@intel.com/ Co-developed-by: Ruowen Qin Signed-off-by

Re: [PATCH v2 net] ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()

2024-11-22 Thread Jinghao Jia
Hi Julian, On 11/22/24 5:43 AM, Julian Anastasov wrote: > > Hello, > > On Thu, 21 Nov 2024, Jinghao Jia wrote: > >> Under certain kernel configurations when building with Clang/LLVM, the >> compiler does not generate a return or jump as the te

[PATCH v2 net] ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()

2024-11-21 Thread Jinghao Jia
et tree rather than net-next * Add a "Fixes" tag for the initial git commit Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402100205.pwxiz1zk-...@intel.com/ Co-developed-by: Ruowen Qin Signed-off-by:

Re: [PATCH] ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()

2024-11-18 Thread Jinghao Jia
Hi Julian, Thanks for getting back to us! On 11/18/24 6:41 AM, Julian Anastasov wrote: > > Hello, > > On Mon, 11 Nov 2024, Jinghao Jia wrote: > >> Under certain kernel configurations when building with Clang/LLVM, the >> compiler does not generate a retur

[PATCH] ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()

2024-11-10 Thread Jinghao Jia
leaves the function without a terminator. Zero the on-stack buffer to avoid this possible UB. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402100205.pwxiz1zk-...@intel.com/ Co-developed-by: Ruowen Qin Signed-off-by: Ruowen Qin Signed-off-by: Jinghao Jia --- ne

Re: [PATCH v2] kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address

2024-03-17 Thread Jinghao Jia
On 3/16/24 08:46, Masami Hiramatsu (Google) wrote: > On Thu, 14 Mar 2024 18:56:35 -0500 > Jinghao Jia wrote: > >> On 3/14/24 10:17, Masami Hiramatsu (Google) wrote: >>> From: Masami Hiramatsu (Google) >>> >>> Read from an unsafe

Re: [PATCH v2] kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address

2024-03-14 Thread Jinghao Jia
On 3/14/24 10:17, Masami Hiramatsu (Google) wrote: > From: Masami Hiramatsu (Google) > > Read from an unsafe address with copy_from_kernel_nofault() in > arch_adjust_kprobe_addr() because this function is used before checking > the address is in text or not. Syzcaller bot found a bug and reported

Re: [PATCH v2 3/3] x86/kprobes: Boost more instructions from grp2/3/4/5

2024-02-04 Thread Jinghao Jia
On 2/4/24 06:09, Masami Hiramatsu (Google) wrote: > On Sat, 3 Feb 2024 21:13:00 -0600 > Jinghao Jia wrote: > >> With the instruction decoder, we are now able to decode and recognize >> instructions with opcode extensions. There are more instructions in >> these

[PATCH v2 2/3] x86/kprobes: Prohibit kprobing on INT and UD

2024-02-03 Thread Jinghao Jia
ring buffer, since the exception is triggered in the copy buffer rather than the original location. Check for INT and UD in can_probe and reject any kprobes trying to attach to these instructions. Suggested-by: Masami Hiramatsu (Google) Signed-off-by: Jinghao Jia --- arch/x86/kernel/kprobes

[PATCH v2 3/3] x86/kprobes: Boost more instructions from grp2/3/4/5

2024-02-03 Thread Jinghao Jia
like RIP, let's boost them so that we get the performance benefit. Signed-off-by: Jinghao Jia --- arch/x86/kernel/kprobes/core.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c

[PATCH v2 1/3] x86/kprobes: Refactor can_{probe,boost} return type to bool

2024-02-03 Thread Jinghao Jia
Both can_probe and can_boost have int return type but are using int as boolean in their context. Refactor both functions to make them actually return boolean. Signed-off-by: Jinghao Jia --- arch/x86/kernel/kprobes/common.h | 2 +- arch/x86/kernel/kprobes/core.c | 33

[PATCH v2 0/3] x86/kprobes: add exception opcode detector and boost more opcodes

2024-02-03 Thread Jinghao Jia
scussion. - Improve code comments in general. Jinghao Jia (3): x86/kprobes: Refactor can_{probe,boost} return type to bool x86/kprobes: Prohibit kprobing on INT and UD x86/kprobes: Boost more instructions from grp2/3/4/5 arch/x86/kernel/kprobes/common.h | 2 +- arch/x86/kernel/kprobes/core.

Re: [RFC PATCH 1/2] x86/kprobes: Prohibit kprobing on INT and UD

2024-01-29 Thread Jinghao Jia
On 1/29/24 19:44, Masami Hiramatsu (Google) wrote: > On Sun, 28 Jan 2024 15:25:59 -0600 > Jinghao Jia wrote: > >>>> /* Check if paddr is at an instruction boundary */ >>>> static int can_probe(unsigned long paddr) >>>> { >>>> @@ -

Re: [RFC PATCH 2/2] x86/kprobes: boost more instructions from grp2/3/4/5

2024-01-28 Thread Jinghao Jia
On 1/27/24 20:22, Masami Hiramatsu (Google) wrote: > On Fri, 26 Jan 2024 22:41:24 -0600 > Jinghao Jia wrote: > >> With the instruction decoder, we are now able to decode and recognize >> instructions with opcode extensions. There are more instructions in >> these

Re: [RFC PATCH 1/2] x86/kprobes: Prohibit kprobing on INT and UD

2024-01-28 Thread Jinghao Jia
On 1/27/24 19:19, Masami Hiramatsu (Google) wrote: > On Fri, 26 Jan 2024 22:41:23 -0600 > Jinghao Jia wrote: > >> Both INTs (INT n, INT1, INT3, INTO) and UDs (UD0, UD1, UD2) serve >> special purposes in the kernel, e.g., INT3 is used by KGDB and UD2 is >> involved i

Re: [RFC PATCH 1/2] x86/kprobes: Prohibit kprobing on INT and UD

2024-01-28 Thread Jinghao Jia
On 1/27/24 13:47, Xin Li wrote: > On 1/26/2024 8:41 PM, Jinghao Jia wrote: >> Both INTs (INT n, INT1, INT3, INTO) and UDs (UD0, UD1, UD2) serve >> special purposes in the kernel, e.g., INT3 is used by KGDB and UD2 is >> involved in LLVM-KCFI instrumentation. At the

[RFC PATCH 0/2] x86/kprobes: add exception opcode detector and boost more opcodes

2024-01-26 Thread Jinghao Jia
instructions were not boosted previously because they use opcode extensions that are not handled by the kernel. But now with the instruction decoder they can be easily handled. Boosting (and further jump optimizing) these instructions leads to a 10x performance gain for a single probe on QEMU. Jinghao

[RFC PATCH 2/2] x86/kprobes: boost more instructions from grp2/3/4/5

2024-01-26 Thread Jinghao Jia
like RIP, let's boost them so that we get the performance benefit. Signed-off-by: Jinghao Jia --- arch/x86/kernel/kprobes/core.c | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c

[RFC PATCH 1/2] x86/kprobes: Prohibit kprobing on INT and UD

2024-01-26 Thread Jinghao Jia
kernel ring buffer, since the exception is triggered in the copy buffer rather than the original location. Check for INTs and UDs in can_probe and reject any kprobes trying to attach to these instructions. Suggested-by: Masami Hiramatsu (Google) Signed-off-by: Jinghao Jia --- arch/x86/kernel

[PATCH] x86/kprobes: fix incorrect return address calculation in kprobe_emulate_call_indirect

2024-01-02 Thread Jinghao Jia
lation directly in kprobe_emulate_call_indirect. At this point we can obtain the instruction size from p->ainsn.size so that we can calculate the correct return address. Fixes: 6256e668b7af ("x86/kprobes: Use int3 instead of debug trap for single-step") Signed-off-by: Jinghao Jia --- arch/x86/k