[PATCH 3/3] kprobes: Cleanup collect_one_slot() and __disable_kprobe()

2024-08-13 Thread Jinjie Ruan
If kip->nused is not zero, collect_one_slot() return false, otherwise do a lot of linked list operations, reverse the processing order to make the code if nesting more concise. __disable_kprobe() is the same as well. Signed-off-by: Jinjie Ruan --- kernel/kprobes.c |

[PATCH 2/3] kprobes: Cleanup the config comment

2024-08-13 Thread Jinjie Ruan
The CONFIG_KPROBES_ON_FTRACE #if/#else/#endif section is small and doesn't nest additional #ifdefs so the comment is useless and should be removed, but the __ARCH_WANT_KPROBES_INSN_SLOT and CONFIG_OPTPROBES() nest is long, it is better to add comment for reading. Signed-off-by: Jinjie

[PATCH 1/3] kprobes: Annotate structs with __counted_by()

2024-08-13 Thread Jinjie Ruan
Add the __counted_by compiler attribute to the flexible array member stripes to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Signed-off-by: Jinjie Ruan --- kernel/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kprobes.c

[PATCH 0/3] kprobes: Annotate structs with __counted_by()

2024-08-13 Thread Jinjie Ruan
Annotate structs with __counted_by() for kprobe and do some cleanup. Jinjie Ruan (3): kprobes: Annotate structs with __counted_by() kprobes: Cleanup the config comment kprobes: Cleanup collect_one_slot() and __disable_kprobe() kernel/kprobes.c | 87

Re: [PATCH v2] loongarch: Support RANDOMIZE_KSTACK_OFFSET

2024-07-19 Thread Jinjie Ruan
On 2024/7/20 0:01, Kees Cook wrote: > On Fri, Jul 19, 2024 at 11:14:27AM +0800, Jinjie Ruan wrote: >> Add support of kernel stack offset randomization while handling syscall, >> the offset is defaultly limited by KSTACK_OFFSET_MAX(). >> >> In order to avoid tri

[PATCH v2] loongarch: Support RANDOMIZE_KSTACK_OFFSET

2024-07-18 Thread Jinjie Ruan
do_syscall() at function level. With this patch, the REPORT_STACK test show that: `loongarch64 bits of stack entropy: 7` Signed-off-by: Jinjie Ruan Suggested-by: Huacai Chen --- v2: - get_random_u16() -> drdtime(). - Add Suggested-by. --- arch/loongarch/Kconfig | 1 + a

Re: [PATCH] loongarch: Support RANDOMIZE_KSTACK_OFFSET

2024-07-18 Thread Jinjie Ruan
ight. "DRDTIME" can access independent stable counter of the processor core according to "Loongson Processor 3C5000L Register Instruction Manual", which is similar to "RDTSC" in x86. I'll update it in next version. > > Huacai > > On Thu, Jul 18, 2

[PATCH] loongarch: Support RANDOMIZE_KSTACK_OFFSET

2024-07-18 Thread Jinjie Ruan
do_syscall() at function level. With this patch, the REPORT_STACK test show that: `loongarch64 bits of stack entropy: 7` Signed-off-by: Jinjie Ruan --- arch/loongarch/Kconfig | 1 + arch/loongarch/kernel/syscall.c | 16 +++- 2 files changed, 16 insertions(+), 1