From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB6FEC282D7 for ; Sat, 2 Feb 2019 18:36:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 910242082C for ; Sat, 2 Feb 2019 18:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbfBBSgX (ORCPT ); Sat, 2 Feb 2019 13:36:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50878 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbfBBSgX (ORCPT ); Sat, 2 Feb 2019 13:36:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77B6B41DB0; Sat, 2 Feb 2019 18:36:22 +0000 (UTC) Received: from krava (ovpn-204-38.brq.redhat.com [10.40.204.38]) by smtp.corp.redhat.com (Postfix) with SMTP id F280F8589B; Sat, 2 Feb 2019 18:31:07 +0000 (UTC) Date: Sat, 2 Feb 2019 19:30:45 +0100 From: Jiri Olsa To: Dmitry Vyukov Cc: Ingo Molnar , Peter Zijlstra , LKML , Arnaldo Carvalho de Melo , Alexander Shishkin , Namhyung Kim , luca abeni , Thomas Gleixner , Oleg Nesterov , syzkaller Subject: Re: perf_event_open+clone = unkillable process Message-ID: <20190202183013.GA10522@krava> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 02 Feb 2019 18:36:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 01, 2019 at 06:06:03PM +0100, Dmitry Vyukov wrote: > On Fri, Feb 1, 2019 at 5:48 PM Dmitry Vyukov wrote: > > > > Hello, > > > > The following program creates an unkillable process that eats CPU. > > /proc/pid/stack is empty, I am not sure what other info I can provide. > > > > Tested is on upstream commit 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a. > > Config is attached. > > Looking through other reproducers that create unkillable processes, I > think I found a much simpler reproducer (below). It's single threaded > and just setups SIGBUS handler and does timer_create+timer_settime to > send repeated SIGBUS. The resulting process can't be killed with > SIGKILL. > +Thomas for timers. nice, I managed to kill it by strace ;-) [jolsa@krava perf]$ strace -p 10725 strace: Process 10725 attached --- stopped by SIGBUS --- --- stopped by SIGBUS --- --- stopped by SIGBUS --- --- stopped by SIGBUS --- +++ killed by SIGINT +++ +Oleg jirka > > > // autogenerated by syzkaller (https://github.com/google/syzkaller) > > #define _GNU_SOURCE > > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > > static __thread int skip_segv; > static __thread jmp_buf segv_env; > > static void segv_handler(int sig, siginfo_t* info, void* ctx) > { > uintptr_t addr = (uintptr_t)info->si_addr; > const uintptr_t prog_start = 1 << 20; > const uintptr_t prog_end = 100 << 20; > if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && > (addr < prog_start || addr > prog_end)) { > _longjmp(segv_env, 1); > } > exit(sig); > } > > static void install_segv_handler(void) > { > struct sigaction sa; > memset(&sa, 0, sizeof(sa)); > sa.sa_handler = SIG_IGN; > syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); > syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); > memset(&sa, 0, sizeof(sa)); > sa.sa_sigaction = segv_handler; > sa.sa_flags = SA_NODEFER | SA_SIGINFO; > sigaction(SIGSEGV, &sa, NULL); > sigaction(SIGBUS, &sa, NULL); > } > > int main(void) > { > syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); > install_segv_handler(); > int tid = syscall(__NR_gettid); > *(uint64_t*)0x20000000 = 0; > *(uint32_t*)0x20000008 = 7; > *(uint32_t*)0x2000000c = 4; > *(uint32_t*)0x20000010 = tid; > syscall(__NR_timer_create, 0, 0x20000000, 0x20000080); > *(uint64_t*)0x2004a000 = 0; > *(uint64_t*)0x2004a008 = 1; > *(uint64_t*)0x2004a010 = 7; > *(uint64_t*)0x2004a018 = 0xe4c; > syscall(__NR_timer_settime, 0, 3, 0x2004a000, 0); > return 0; > }