Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7372772rwb; Mon, 12 Dec 2022 13:52:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Kv+ayiIX8n5+052GJWABni1wn4Jj9mNjLGjVGDHbd77QcfZk+L7hLe1aNd2g0xkmGV+Nl X-Received: by 2002:a05:6402:1f87:b0:461:2396:fc5a with SMTP id c7-20020a0564021f8700b004612396fc5amr8436466edc.35.1670881936569; Mon, 12 Dec 2022 13:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670881936; cv=none; d=google.com; s=arc-20160816; b=fhUAKixef5tFth9iYzCfBMsVyi7CKYJ46AvelmuHgfAeYy17xauoZf0seZyTuf8DYN aYJRU7UQZBinFkoRINKJak2KJJEx880uIlqHw61jBcau5v6rje5WGmK7ChR75vnIrPJi 62gSrM0ZTttiRyUvbltV7pjg5rsf0LM+kb4+Iv5+AKhrLkrkts5VEEhW7Xx2zYJVfr0T Ge544WB8EHl1WUxsM9MhgJ1uhhLuKnY6QYtp8KvnfOh8qxnSDsb/WmKh3qrJPclhpkmR N2t3lwuOy4hFJ5iUTbhu+Ch6+tFVYIkp6lmwlmn49M1Y28QUY614ItbZYJzVvd0TUeAi chMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PD74x5HXlpXeWZ4XMDwD2V08ggJnlX+zpSazzzMuCLI=; b=Zc52EiNHb+PGgTCf9msWO81nLJbbUy4SE1yzHx0NPtAuy4jz5s3GLJaGPoCLXdYHe2 yhYhBUngjBwLwvMHFsde7L+kUFG0n8gSbFqZ+34lwq7YOjDGHXqrO/qALUN4bf1/BlkM 2PBmIXPaAbxtrhCuBF1xNyc/7dI4POC96BjM06GWu7eo+/ES+nlBq4pXdGSkkUXBmqfu HvI9GCS+FO7xNwTAX4Z6WWxwP3J20t3yqGkQU+NCy1uxvX295pgwIwmsakyYJLifNLdw V+PKUmjqb6iu4zY6uCOzTuwGUo37kZbO8hR0680U9h98bMwb5WY0VUp6oyx06/TfcbRL tLBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PEz+9eJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a056402401000b00467bbc3d62asi6926938eda.547.2022.12.12.13.51.57; Mon, 12 Dec 2022 13:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PEz+9eJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233296AbiLLVjj (ORCPT + 75 others); Mon, 12 Dec 2022 16:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiLLVjh (ORCPT ); Mon, 12 Dec 2022 16:39:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7BB252 for ; Mon, 12 Dec 2022 13:39:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B216BB80E72 for ; Mon, 12 Dec 2022 21:39:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D04FC433A4 for ; Mon, 12 Dec 2022 21:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670881173; bh=B9gTkTNlu/xQ+gB/j1rIPXB65DL5r+u8wRXwz/iJixY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PEz+9eJqQCOZMmvPrfo3VEo9OqHglPy+y4STHULwpRMn7eY1bpiLC9nr9TdZSfRcj g3zSayKgK1kQ7eZiorebU8CpCUmamAKhW7nGigXPpQS0v/JkFWiA3ZqwEhPVCGe/ZZ uNwlC5Qo5oopzMicYd3nQVkn4ctKWkXehrdJERS+/FZxYa7fcCweX3q8xnZseL1RZR hEKRGmzehkoahb6XH4lPq57Ww8liyVrQfB6+Jdr5b7IYQxv9dETPHq+EpaD4HIbVSp FtU6Fx3tqDHiVR6mc4Wg+JJ3jpCVL9ko5ccIJr2Ah0VDxTfoENLHfL1tvR4B7x59sz Jvt7Wh5aPUQnQ== Received: by mail-ej1-f50.google.com with SMTP id t17so31698069eju.1 for ; Mon, 12 Dec 2022 13:39:33 -0800 (PST) X-Gm-Message-State: ANoB5pk3/rtvdlAGYqRh2OAC994tMZzP6Ctopr0djB1Zt+z7PSp0ZMmJ xOjdrt90fF3SOANwlGjbjM6ylAAZkPzVW5IjNgWP8w== X-Received: by 2002:a17:906:48d6:b0:7c1:b67:6a28 with SMTP id d22-20020a17090648d600b007c10b676a28mr9538124ejt.2.1670881171311; Mon, 12 Dec 2022 13:39:31 -0800 (PST) MIME-Version: 1.0 References: <167019256481.3792653.4369637751468386073.stgit@devnote3> <20221204223001.6wea7cgkofjsiy2z@macbook-pro-6.dhcp.thefacebook.com> <20221205075921.02edfe6b54abc5c2f9831875@kernel.org> <20221206021700.oryt26otos7vpxjh@macbook-pro-6.dhcp.thefacebook.com> <20221206162035.97ae19674d6d17108bed1910@kernel.org> <20221207040146.zhm3kyduqp7kosqa@macbook-pro-6.dhcp.thefacebook.com> <20221206233947.4c27cc9d@gandalf.local.home> <20221207074806.6f869be2@gandalf.local.home> <20221208043628.el5yykpjr4j45zqx@macbook-pro-6.dhcp.thefacebook.com> <20221211115218.2e6e289bb85f8cf53c11aa97@kernel.org> <20221212001431.ac84a6320cff8d5fa8aa943e@kernel.org> In-Reply-To: <20221212001431.ac84a6320cff8d5fa8aa943e@kernel.org> From: KP Singh Date: Mon, 12 Dec 2022 22:39:20 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] panic: Taint kernel if fault injection has been used To: Masami Hiramatsu Cc: Alexei Starovoitov , Steven Rostedt , LKML , bpf , Borislav Petkov , Linus Torvalds , Andrew Morton , Peter Zijlstra , Kees Cook , Josh Poimboeuf , Mark Rutland , Florent Revest , Greg Kroah-Hartman , Christoph Hellwig , Chris Mason Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 11, 2022 at 4:14 PM Masami Hiramatsu wrote: > > On Sun, 11 Dec 2022 08:49:01 +0100 > KP Singh wrote: > > > On Sun, Dec 11, 2022 at 3:52 AM Masami Hiramatsu wrote: > > > > > > Hi Alexei, > > > > > > On Wed, 7 Dec 2022 20:36:28 -0800 > > > Alexei Starovoitov wrote: > > > > > > > Yet for 2 days this 'taint' arguing is preventing people from looking at the bug. > > > > And that happens all the time on lkml. Somebody reports a bug and kernel devs > > > > jump on the poor person: > > > > "Can you repro without taint?", > > > > "Can you repro with upstream kernel?" > > > > This is discouraging. > > > > The 'taint' concept makes it easier for kernel devs to ignore bug reports > > > > and push back on the reporter. > > > > Do it few times and people stop reporting bugs. > > > > > > That seems off topic for me. You seems complained against the taint flag > > > itself. > > > > The series is about adding a taint for, so discussing the user > > experience, when someone reports a "tainted crash" seems reasonable to > > me and not off topic. > > > > > > > > > Say, this particular bug in rethook was found by one of our BPF CI developers. > > > > They're not very familiar with the kernel, but they can see plenty of 'rethook' > > > > references in the stack trace, lookup MAINTAINER file and ping Massami, > > > > but to the question "can you repro without taint?" they can only say NO, > > > > because this is how our CI works. So they will keep silence and the bug will be lost. > > > > > > BTW, this sounds like the BPF CI system design issue. If user is NOT easily > > > identifying what test caused the issue (e.g. what tests ran on the system > > > until the bug was found), the CI system is totally useless, because after > > > finding a problem, it must be investigated to solve the problem. > > > > > > Without investigation, how would you usually fix the bug?? > > > > Masami, this seems accusational and counter productive, it was never > > said that issues can be solved without investigation. > > Let me apologies about my misunderstanding. e-mail is hard, I am glad this is already progressing constructively and we are making things better. > > > > > The BPF CI does find issues, the BPF reviewers and maintainers > > regularly fix bugs using it. Alexei's point here is that a taint does > > not help in solving the problem, rather deter some people from even > > looking at it. (not BPF people, but other maintainers [distro, kernel] > > who would ask for a reproduction without a taint). > > Hmm, that is a problem. Some taint flag should be useful hints > for finding the error patterns. the boolean information contained in taints is not helpful, stuff like audit logs / crash dumps / bpftool reports are much more helpful. > > > Let's take a step back and focus on solving debuggability and > > introspection as we clearly have some perception issues about taints > > in the community. (distro maintainers, users) before we go and add > > more taints. > > Agreed. > > > > > That's not the only reason why I'm against generalizing 'taint'. > > > > Tainting because HW is misbehaving makes sense, but tainting because > > > > of OoO module or because of live-patching does not. > > > > It becomes an excuse that people abuse. > > > > > > yeah, it is possible to be abused. but that is the problem who > > > abuse it. > > > > I am sorry, but it's our responsibility as developers to design > > features so that users don't face arduous pushbacks. > > Sorry if I confuse you. I meant that taint flag abusing. :( Again no worries, but we need to make sure that the taint flag is not abused, and if it is being abused, limit the damage somewhere. > > > > > > > Right now syzbot is finding all sorts of bugs. Most of the time syzbot > > > > turns error injection on to find those allocation issues. > > > > If syzbot reports will start coming as tainted there will be even less > > > > attention to them. That will not be good. > > > > > > Hmm, what kind of error injection does syzbot do? I would like to know > > > how it is used. For example, does that use only a specify set of > > > injection points, or use all existing points? > > > > > > If the latter, I feel safer because syzbot ensures the current all > > > ALLOW_ERROR_INJECTION() functions will work with error injection. If not, > > > we need to consider removing the ALLOW_ERROR_INJECTION() from the > > > function which is not tested well (or add this taint flag.) > > > > > > Documentation/fault-injection/fault-injection.rst has no explanation > > > about ALLOW_ERROR_INJECTION(), but obviously the ALLOW_ERROR_INJECTION() > > > marked functions and its caller MUST be designed safely against the > > > error injection. e.g. > > > > > > - It must return an error code. (so EI_ETYPE_NONE must be removed) > > > > This is already the case with BPF, the modify return trampolines > > further limits the error injection to functions that return errors. > > OK, so I also should remove it from FEI. > > > > > > - Caller must check the return value always. > > > (but I thought this was the reason why we need this test framework...) > > > - It should not run any 'effective' code before checking an error. > > > For example, increment counter, call other functions etc. > > > (this means it can return without any side-effect) > > > > This is the case with modify_return trampolines in BPF which avoid > > side effects and limit the attachment surface further and avoiding > > side effects is a design goal. If we missed anything, let's fix that. > > > > https://lwn.net/Articles/813724/ > > Yeah, if BPF tests already tested all ALLOW_ERROR_INJECTION() functions, > it may be checked already. I think we just need adding the above > explanation on the document, so that the people who will add additional > ALLOW_ERROR_INJECTION() on a function, can understand the limitation. > > > > > > > > > Anything else? > > > > > > [...] > > > > All these years we've been working on improving bpf introspection and > > > > debuggability. Today crash dumps look like this: > > > > bpf_trace_printk+0xd3/0x170 kernel/trace/bpf_trace.c:377 > > > > bpf_prog_cf2ac6d483d8499b_trace_bpf_trace_printk+0x2b/0x37 > > > > bpf_dispatcher_nop_func include/linux/bpf.h:1082 [inline] > > > > __bpf_prog_run include/linux/filter.h:600 [inline] > > > > bpf_prog_run include/linux/filter.h:607 [inline] > > > > > > > > The 2nd from the top is a bpf prog. The rest are kernel functions. > > > > bpf_prog_cf2ac6d483d8499b_trace_bpf_trace_printk > > > > ^^ is a prog tag ^^ name of bpf prog > > > > > > > > If you do 'bpftool prog show' you can see both tag and name. > > > > 'bpftool prog dump jited' > > > > dumps x86 code mixed with source line text. > > > > Often enough +0x2b offset will have some C code right next to it. > > > > > > This is good, but this only works when the vmcore is dumped and > > > on the stack. My concern about the function error injection is > > > that makes some side effects, which can cause a problem afterwards > > > (this means after unloading the bpf prog) > > > > I think careful choices need to be made on when error injection is > > allowed so that these situations don't occur. (as you mentioned in > > your comment). [1]. If a BPF program is unloaded, there is no error > > injection any more, let's ensure that we design the error injection > > allow list and the BPF logic to ensure this cannot happen. > > OK. Actually, I trust the BPF logic itself will be handle this > correctly. I just concerned that some people who don't know much > (because it is not carefully documented) might add ALLOW_ERROR_INJECTION() > to a function which is not injectable by design. Thus I thought the > taint flag can help. We should definitely carefully review any new ALLOW_ERROR_INJECTION functions, that's the real value add. > But if those are always Cc'd to bpf@vger and it will be tested by BPF > CI, I'm OK for that. > > > > > One can monitor all prog load/unload via perf or via audit. > > > > I would like us to focus on debuggability as it helps both the > > maintainers and the user. And I see a few things that need to be done: > > > > 1. Revisit what is allowed for error injection in the kernel and if > > they can cause any subtle issues. My initial take is that functions > > that are directly called from syscall path should generally be okay. > > But let's check them for the patterns you mentioned. > > Yeah, I agree that syscall entries should be safe. > > > 2. If it helps, add the list of BPF modify return programs to stack > > traces. Although this is really needed if we don't do [1] properly. > > Would you mean a list of enabled BPF programs in Oops code? If so, > I also want to add enabled FEI list on it. > > > 3. Check if anything needs to be improved in the verification logic > > for modify return trampolines. > > I think BPF logic itself is safe. But the targeted function itself > or the caller may not be designed for such error injection. > I think this is my fault that I have not documented about > ALLOW_ERROR_INJECTION() well. Sorry about that. We aim to be blameless and constructive :) Thanks again for sending the patches! Cheers, - KP > > Thank you, > > > -- > Masami Hiramatsu (Google)