Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3A4FC4332F for ; Thu, 18 Nov 2021 00:37:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84B8661B30 for ; Thu, 18 Nov 2021 00:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242005AbhKRAkf (ORCPT ); Wed, 17 Nov 2021 19:40:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232441AbhKRAkd (ORCPT ); Wed, 17 Nov 2021 19:40:33 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA3FC061766 for ; Wed, 17 Nov 2021 16:37:34 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id g14so19001313edz.2 for ; Wed, 17 Nov 2021 16:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CHmkZszPR6EELtxyc0tZ5ImEP6GCMXNuKUoNO1WLl4A=; b=G+Az4leoYHWjXC176OT/xR8EoiNodE3UlIl9ddIYba1/nV7CORra7HBL4DptBg3QUq NQlFUVejndDpvLty7d7Y4RcDcpHvTbW1v7DnxyzRovMW+0YIbEspfZSRLWm2omOMY9qc HAF2aebOm9RxOWip8Q0KjhFqmJLXYB5d8//Asua/4C7ZC5vLsCLyryEoleJlsMlZ7dRz ylVcglAE2EsGVjRPzcSKPmtJOh9HcKD6S4gdoW18AFzzikJhLefle9XYW7rHu7NQuLER ZVGAW8frokLTzFAA6CclBHmM9iz9n0+9unpWLnA0WBwsH0w9XP8gaZKsQoR6NI5w6ecr TjJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CHmkZszPR6EELtxyc0tZ5ImEP6GCMXNuKUoNO1WLl4A=; b=7f1K0K3apoRlfD1zBJHMTqhzz6w1x/2OyLzuGeQw28BX5jaskG9LVCj7aGnaXhH82Z 17NcP0+U0xsPiurNj/jutJrS41OI5J5HWorZYTC1+R1IaGStS1e6s6O/ygTT2rjlI9iI 7K81wqN9eVc0KUTvQK1OVpWaCOQVsXWgqZ1/JtV9bJF0ZYaBIl64vp1Rg0I3NwadF2MZ UOYGh6OVVgdb6aMSuhwqHAnaNuQGu5F/4gdEkCRe8eq2ewldsIyJ9BTGBOktP/TIDSea l+hrOM9XlyIlYG97utVbh/nZPU9KARuV1OcJ9THkbW+Xkb04cegmNR8Hgh/mUtD1BbHx 8bJg== X-Gm-Message-State: AOAM531I3zbUEGtp6p+caBMrJu0SH5wUypqW6rphRvoN5ZBabhqUN+/K cLbAOPKay1dCRGGxuDwJAzf6rIw9ESrdwZp0GB8tPA== X-Google-Smtp-Source: ABdhPJxYJytp1pKphdFW2jBHyU5wMlXwFvI1+mIFO9dA4MYHB84eYMqVfc/KNHGNV9du6PqVFrN9mH2uwzEDhLGEmA8= X-Received: by 2002:a17:906:8699:: with SMTP id g25mr27232161ejx.271.1637195852821; Wed, 17 Nov 2021 16:37:32 -0800 (PST) MIME-Version: 1.0 References: <202111171049.3F9C5F1@keescook> <87k0h6334w.fsf@email.froward.int.ebiederm.org> <202111171341.41053845C3@keescook> In-Reply-To: From: Kyle Huey Date: Wed, 17 Nov 2021 16:37:21 -0800 Message-ID: Subject: Re: [REGRESSION] 5.16rc1: SA_IMMUTABLE breaks debuggers To: Linus Torvalds Cc: Kees Cook , "Eric W. Biederman" , Andrea Righi , Shuah Khan , Alexei Starovoitov , Andy Lutomirski , Will Drewry , "open list:KERNEL SELFTEST FRAMEWORK" , bpf , open list , linux-hardening@vger.kernel.org, "Robert O'Callahan" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 17, 2021 at 3:24 PM Linus Torvalds wrote: > > On Wed, Nov 17, 2021 at 1:54 PM Kees Cook wrote: > > > > The SA_IMMUTABLE change was to deal with failures seen in the seccomp > > test suite after the recent fatal signal refactoring. Mainly that a > > process that should have effectively performed do_exit() was suddenly > > visible to the tracer. > > I think this basically shows that the conversion from do_exit() to > fatal_signal() was just wrong. The "do_exit()" wasn't really a signal, > and can't be treated as such. > > That said, instead of reverting, maybe we can just mark the cases > where it really is about sending a synchronous signal, vs sending an > explicitly fatal signal. > > It's basically the "true" condition to force_sig_info_to_task(), so > the fix might be just > > @@ -1323,7 +1323,8 @@ force_sig_info_to_task(struct kernel_siginfo > *info, struct task_struct *t, bool > blocked = sigismember(&t->blocked, sig); > if (blocked || ignored || sigdfl) { > action->sa.sa_handler = SIG_DFL; > - action->sa.sa_flags |= SA_IMMUTABLE; > + if (sigdfl) > + action->sa.sa_flags |= SA_IMMUTABLE; > if (blocked) { > sigdelset(&t->blocked, sig); > recalc_sigpending_and_wake(t); > > Kyle, does that fix your test-case? And Kees - yours? This fixes most of the issues with rr, but it still changes the ptrace behavior for the double-SIGSEGV case (yes, we have a test for that too). The second SIGSEGV isn't reported to the ptracer and the program just skips straight to the PTRACE_EVENT_EXIT. This is visible in gdb as well (only the first SIGSEGV is caught). - Kyle