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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD9BCC54E58 for ; Mon, 18 Mar 2024 13:24:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0CFC8E0002; Mon, 18 Mar 2024 09:24:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 997208D0001; Mon, 18 Mar 2024 09:24:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 727648E0002; Mon, 18 Mar 2024 09:24:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 585818D0001 for ; Mon, 18 Mar 2024 09:24:28 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F3FD5A12C8 for ; Mon, 18 Mar 2024 13:24:27 +0000 (UTC) X-FDA: 81910229016.13.2EF7BFB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 56D0640009 for ; Mon, 18 Mar 2024 13:24:26 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q2mHGKNt; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710768266; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LsoRq2dWNeJJxQ2mXxh1/DE4RKMlx5veypMQf3iYOfE=; b=uFKcxojrIvcojpIevsHW5N820ds0Rz/IU8rJQn8YgFXZyOPQVtW1sNOCOi0zT7bZYFejmD DFCU21YK+pI8SM3mvAij77NMOGsWaa9nKalN9WulCOrsir8OHYknYrA8iV+mdN9R7LSa7o 5GcIHJhqVN4KoVtNnaoLA7Q1LjlCJ34= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q2mHGKNt; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710768266; a=rsa-sha256; cv=none; b=IghSGhDa8zivVQYe/gqBw2LTEwAqeCd8prW0oHdXi/sgRLsj4FvSkeqtxgEl5rKM7nii2c Xo4ei3D7ePV8/fSvhMfhOwwVKNgJXWGDS9IJBhSbClmqLsNRQhRi/10Ms3oYh3y9gvwoxB p7aZg57L2C4p3y+LydtpTiGaU3mBtlM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 32F4960C42; Mon, 18 Mar 2024 13:24:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2675DC43394; Mon, 18 Mar 2024 13:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710768265; bh=twSoeLbz1uUYCDjFLEbD4Hw80Ek0KP0899uymbExspE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q2mHGKNt/EOyoZSOaA7XN5EETdDtuRfGnr/KWyUFAcK+Ws8T1gO/u4j4euwl9D+I7 JUIngsuY0PD0ZD+HV0+//87a0dUxX/aeFBr5wCfP5ujk/DIjjsJoLXCpdoQuPn7fqL wzLk9wV3RwDZCiLAV2JjZIBkBlsw4zVzxEBiCkBE3E71atEAQOYIyufQt6mO6ngZ65 Rs/CXwBClpJkDsVoAvX0HdyDkDvRpZ2uo7EJ4yyao1gvHq1bmHu4x8PukLzVDcjcsX TncGN/jAIH5wxQcjGni8yEDKvgOCAS5sfzokFNDpQlN8/cEQIuC3lCrG4apAKx0UQP tbk3XvjgV3C/Q== Date: Mon, 18 Mar 2024 14:24:18 +0100 From: Christian Brauner To: Matt Bobrowski Cc: Alexei Starovoitov , bpf , Alexei Starovoitov , Andrii Nakryiko , KP Singh , Jann Horn , Jiri Olsa , Daniel Borkmann , Linus Torvalds , Linux-Fsdevel , Andrew Morton , linux-mm , LSM List Subject: Re: [PATCH v2 bpf-next 0/9] add new acquire/release BPF kfuncs Message-ID: <20240318-freifahrt-perfide-e99eb9c1f4ec@brauner> References: <20240306-flach-tragbar-b2b3c531bf0d@brauner> <20240306-sandgrube-flora-a61409c2f10c@brauner> <20240307-phosphor-entnahmen-8ef28b782abf@brauner> <20240308-kleben-eindecken-73c993fb3ebd@brauner> <20240311-geglaubt-kursverfall-500a27578cca@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 56D0640009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wmrs8h3jwdszt1m8r7jpic4xrmsccncd X-HE-Tag: 1710768266-559810 X-HE-Meta: U2FsdGVkX18CgOvWiIRjGLqUUzpYoDDB1CdAXiqgC6sRUeQVLczwXWMPf4ZRphZ/dbwURrC0nGjH166AXkYghCZX3oYgR+3PuZY8kss656Z1vi4Sh8oZxyIgKBHIioCWgKKE6WUYmxrHW7mKFHMCgpKqkeSEbIfXChizKORz8zfAhq+gtqxrCm2gu+vjcPSxzsF5DmsySS6/62xTYLe8+/kQs1rn40aUTmKP+rrRvY40Whv+x6XGvIaU4S7ZhUZSQVbwFZUy6noCVfBeEG4HAG4qb3LHsknxdgJPQXcF8IPJoOxiAVBxrUgPeOUpD0CdUFwT5Qh+wtgdlL32wG5SknNhnXluUlfMmuN/if19cKG0+8tjSTc21hxjfsB42N1OFcYaGvrXprmpUdM+iK7qc4nDnZLGGwDVKIJGESW6CqLxuRMmldaxqKQsPqqGJiig07ctNcxCtniyVGRZRdqShNrO0MVZQ/FYfw98SFeNmql0zMl5K6ZDHrWOor9ipmMuK+nJ7rzWWbDXfpf09+Py4XEJfP6D7Ev7nbfNYAywmCdsN+uC7eQNN+B9h1+JA4NijvZ8RNHOTPJhs9sbaVlQi8+s4gS3PO9xYJIgRSYgD08YzxFCv0MwE5a5C+eSM1Ixn57CLSG5AXHk3g1GYEVOs0VbB4oGOei9pR9pr6fxTgp9xHCB+9tYuqzXKwVVRZt+WUo88l9UnW/PP58umnznbhXZwIouLCPNnwM1yobu0axqAbA5EhXDfAJ6YGvag/EX1Uo6q4LfkUl6dHeYt5k2l8OlsZB2yezfkfjVNrrml2QocAZgqlXJLhAYkeZlGnLsD3Idsdw6H+Z6/qwT9YZXrtJHNVu2O7Djkf+KdG8qblISe8FKDOOcrSGMV9puuSutYAstLQAjzgsHVAAtgQB5cvgTESqq//JqU73CU3Wra0+pei1Cq3Vak8jgRut7k53Y4VtEuxSFG8OErbKDyhN sQg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Mar 12, 2024 at 05:06:36PM +0000, Matt Bobrowski wrote: > Hey Christian, > > On Mon, Mar 11, 2024 at 01:00:56PM +0100, Christian Brauner wrote: > > On Fri, Mar 08, 2024 at 05:23:30PM -0800, Alexei Starovoitov wrote: > > > On Fri, Mar 8, 2024 at 2:36 AM Christian Brauner wrote: > > > > > > > > > > > > These exports are specifically for an out-of-tree BPF LSM program that > > > > is not accessible to the public. The question in the other mail stands. > > > > > > The question was already answered. You just don't like the answer. > > > bpf progs are not equivalent to kernel modules. > > > They have completely different safety and visibility properties. > > > The safety part I already talked about. > > > Sounds like the visibility has to be explained. > > > Kernel modules are opaque binary blobs. > > > bpf programs are fully transparent. The intent is known > > > to the verifier and to anyone with understanding > > > of bpf assembly. > > > Those that cannot read bpf asm can read C source code that is > > > embedded in the bpf program in kernel memory. > > > It's not the same as "llvm-dwarfdump module.ko" on disk. > > > The bpf prog source code is loaded into the kernel > > > at program verification time for debugging and visibility reasons. > > > If there is a verifier bug and bpf manages to crash the kernel > > > vmcore will have relevant lines of program C source code right there. > > > > > > Hence out-of-tree or in-tree bpf makes no practical difference. > > > The program cannot hide its meaning and doesn't hamper debugging. > > > > > > Hence adding EXPORT_SYMBOL == Brace for impact! > > > Expect crashes, api misuse and what not. > > > > > > While adding bpf_kfunc is a nop for kernel development. > > > If kfunc is in the way of code refactoring it can be removed > > > (as we demonstrated several times). > > > A kfunc won't cause headaches for the kernel code it is > > > calling (assuming no verifier bugs). > > > If there is a bug it's on us to fix it as we demonstrated in the past. > > > For example: bpf_probe_read_kernel(). > > > It's a wrapper of copy_from_kernel_nofault() and over the years > > > bpf users hit various bugs in copy_from_kernel_nofault(), > > > reported them, and _bpf developers_ fixed them. > > > Though copy_from_kernel_nofault() is as generic as it can get > > > and the same bugs could have been reproduced without bpf > > > we took care of fixing these parts of the kernel. > > > > > > Look at path_put(). > > > It's EXPORT_SYMBOL and any kernel module can easily screw up > > > reference counting, so that sooner or later distro folks > > > will experience debug pains due to out-of-tree drivers. > > > > > > kfunc that calls path_put() won't have such consequences. > > > The verifier will prevent path_put() on a pointer that wasn't > > > acquired by the same bpf program. No support pains. > > > It's a nop for vfs folks. > > > > > > > > First of all, there is no such thing as get_task_fs_pwd/root > > > > > in the kernel. > > > > > > > > Yeah, we'd need specific helpers for a never seen before out-of-tree BPF > > > > LSM. I don't see how that's different from an out-of-tree kernel module. > > > > > > Sorry, but you don't seem to understand what bpf can and cannot do, > > > hence they look similar. > > > > Maybe. On the other hand you seem to ignore what I'm saying. You > > currently don't have a clear set of rules for when it's ok for someone > > to send patches and request access to bpf kfuncs to implement a new BPF > > program. This patchset very much illustrates this point. The safety > > properties of bpf don't matter for this. And again, your safety > > properties very much didn't protect you from your bpf_d_path() mess. > > > > We're not even clearly told where and how these helper are supposed to be > > used. That's not ok and will never be ok. As long as there are no clear > > criteria to operate under this is highly problematic. This may be fine > > from a bpf perspective and one can even understand why because that's > > apparently your model or promise to your users. But there's no reason to > > expect the same level of laxness from any of the subsystems you're > > requesting kfuncs from. > > You raise a completely fair point, and I truly do apologies for the > lack of context and in depth explanations around the specific > situations that the proposed BPF kfuncs are intended to be used > from. Admittedly, that's a failure on my part, and I can completely > understand why from a maintainers point of view there would be > reservations around acknowledging requests for adding such invisible > dependencies. Thanks for providing more background. > Now, I'm in a little bit of a tough situation as I'm unable to point > you to an open-source BPF LSM implementation that intends to make use > of such newly proposed BPF kfuncs. That's just an unfortunate > constraint and circumstance that I'm having to deal with, so I'm just > going to have to provide heavily redacted and incomplete example to > illustrate how these BPF kfuncs intend to be used from BPF LSM > programs that I personally work on here at Google. Notably though, the > contexts that I do share here may obviously be a nonholistic view on > how these newly introduced BPF kfuncs end up getting used in practice > by some other completely arbitrary open-source BPF LSM programs. I have to say that this to me is wild. Essentially we're supposed to allow access to our internal APIs based on internal use-cases that aren't public and likely never will be. If that's acceptable then I want bpf to document this in their kernel Documentation and submit this for review to the wider community.