lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SY4P282MB351877A70A0333C790FE85A5C09C9@SY4P282MB3518.AUSP282.PROD.OUTLOOK.COM>
Date:   Mon, 17 Apr 2023 11:17:55 +0800
From:   Hengqi Chen <chenhengqi@...look.com>
To:     Tiezhu Yang <yangtiezhu@...ngson.cn>,
        Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>
Cc:     loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
        loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH v2 0/4] Add uprobes support for LoongArch

Hi Tiezhu:

On 2023/4/14 17:32, Tiezhu Yang wrote:
> v2:
>   -- Move the functions to inst.c in patch #1
>   -- Pass around union for insns_not_supported(),
>      insns_need_simulation() and arch_simulate_insn()
> 
> v1:
>   -- Split the RFC patch #2 into two patches
>   -- Use larch_insn_gen_break() to generate break insns
>      for kprobes and uprobes
>   -- Pass around instruction word instead of union for
>      insns_not_supported(), insns_need_simulation() and
>      arch_simulate_insn() to avoid type conversion for callers
>   -- Add a simple test case for uprobes in the commit message
> 
> Tiezhu Yang (4):
>   LoongArch: Move three functions from kprobes.c to inst.c
>   LoongArch: Add larch_insn_gen_break() to generate break insns
>   LoongArch: Use larch_insn_gen_break() for kprobes
>   LoongArch: Add uprobes support
> 
>  arch/loongarch/Kconfig               |   3 +
>  arch/loongarch/include/asm/inst.h    |  16 ++++
>  arch/loongarch/include/asm/kprobes.h |   2 +-
>  arch/loongarch/include/asm/uprobes.h |  36 +++++++++
>  arch/loongarch/kernel/Makefile       |   1 +
>  arch/loongarch/kernel/inst.c         |  48 ++++++++++++
>  arch/loongarch/kernel/kprobes.c      |  75 ++++--------------
>  arch/loongarch/kernel/traps.c        |   9 +--
>  arch/loongarch/kernel/uprobes.c      | 142 +++++++++++++++++++++++++++++++++++
>  9 files changed, 265 insertions(+), 67 deletions(-)
>  create mode 100644 arch/loongarch/include/asm/uprobes.h
>  create mode 100644 arch/loongarch/kernel/uprobes.c
> 

I've test this series and found one corner case:

#include <pthread.h>
#include <stdio.h>
#include <thread>

static pthread_spinlock_t lock;
static int count = 0;
static const int n = 10000;

int main()
{
	int ret;

	ret = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
	if (ret)
		return -1;

	auto t1 = std::thread([&](){
		for (auto i = 0; i < n; i++) {
			pthread_spin_lock(&lock);
			count++;
			pthread_spin_unlock(&lock);
		}
	});

	auto t2 = std::thread([&](){
		for (auto i = 0; i < n; i++) {
			pthread_spin_lock(&lock);
			count++;
			pthread_spin_unlock(&lock);
		}
	});

	auto t3 = std::thread([&](){
		for (auto i = 0; i < n; i++) {
			pthread_spin_lock(&lock);
			count++;
			pthread_spin_unlock(&lock);
		}
	});

	t1.join();
	t2.join();
	t3.join();

	pthread_spin_destroy(&lock);

	printf("%d\n", count);
	return 0;
}

When I try to uprobe the pthread_spin_lock calls, the application core dumped.
On X86, this will return -EINVAL instead of crashing the userspace application.
Probably, we should add more opcode to insns_not_supported().

Cheers,
---
Hengqi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ