From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F20CF14E2F2 for ; Sat, 18 Apr 2026 21:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776549014; cv=none; b=P2bm1WNjeEW6k5LP31pemoYV+L/KwXNdPTjf0f8dV3ihnshLFHPs/GyTLuAQ/WJjuUh7r+kdTNyYfpxr3mvZaWRHmsD5Qb2rQD9FmWrP1z5ytNTuTu8p+ZkDlIf7d5GpCsvjzwMpY8W8Cen9DUBerADFK4+yXERkRWkoDTxnPJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776549014; c=relaxed/simple; bh=3t3O3sUz87huz0M+miAOXIZUv7RqPxu3nH6k1jR28j0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XtudoxV4h8heYPEXR0YafVQAFHI/K8sKLlU20DWNfQQHr+1uj2Yd4x/Y7G++sfQKGrd8BGBPMIyGLzt5ZhXpX4oiPgcI+ehZAsKSN3D9yXWKJ2qQ5cgP3fhxvDrpdUUywkG1pER6B4n27qH5j6bAUeZJgXITakpagXwFOfS7LXQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fEIRqRep; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fEIRqRep" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-79a60975dc5so18665407b3.0 for ; Sat, 18 Apr 2026 14:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776549012; x=1777153812; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=36X19zjYQyKBdMHD9gCjle7K5J8JMLJfZmqliCGv0kA=; b=fEIRqRepCGZHHwDeYcQPuGgeVTaflRQq5+lBchI27/BfrZgSyaafzb8AOwkwE1Stfb Nin0EPW+Vw8I4M2su6BmCfrShrHJZgdSiO5qpdSzJSEI5sc5mSYWTHaSK2UQXvv3+RJN SpD8WvbvafSjgZRK22N7msCzhjEc3r+iXKTvNPAfE22tEYgPqmha2EGmh78/Lh+MFiUk zoTxpDvuxUu22vKYSm5sJxB0VlVWXAVmIQ+OKxPYzvQHACZRohRJO21zROlY/CV0GiZf wWq+ZAxjBKTrMT8dO6AEbG6Abo4p2q9k5Uyy7lQ/VkwwzaV+FE1s9pPc5bd0EaVToJWc 48Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776549012; x=1777153812; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=36X19zjYQyKBdMHD9gCjle7K5J8JMLJfZmqliCGv0kA=; b=IZ49+hCLlvXgFNQlN2sorvQvXr/M6nK0ikylpul7twJa+12tt3Isd4V6c8CYMfBX0c X0oAcfKvKTfik7vhLtnUWds4SqG/VM+M8uLPIll/hvLvRRrRx6dMevnsYi3fNptETRyc ACgXagNBHOIXDL9/YjjSTqI1LKDyYbEdMCXOsHT2wuJHzNA0byBWusnHErPGIoFlsSDD qgQqRNYbJN7bSkvm+QoJJR2sxr77Emx0cTxg/zLE2D6L5nmXVHOaSGSfJ0bxjt3kpDrD WMKVVK/Pummi1AgQAZtp64X7k2ET00cTgq8WFHSkRICO/TSzPIRQHCJoXWrpYb/2H0DQ vXnA== X-Forwarded-Encrypted: i=1; AFNElJ/IZD5spP+K4iyZXH5rH6vCHzXrBw6D0k6WyDWdZIkJefHpaufPneda54g18QYOKla7A46ulSID3f3hzDMi@vger.kernel.org X-Gm-Message-State: AOJu0YzucFqwOMppZFWXhCWqHIw6yrxDoNXIe+5LeqKfD67XF90IKPMe xAEdveKz9JJbjUeWNCdO6YgC/4RLopsGNIT3WwxAzoygFb5WYq48U7x3 X-Gm-Gg: AeBDievU44/qNwkwvSLsauFVE34nOV0JDcb7JKHWQmw4vGFQEOJ9VA7+K02+RynlQnM xwyJWzeibPhNAJBVPrGQpkGu4bANP2D9RkYXiK3PfWORytxS6I9zcynp1WHrbKdxrjWRUemnJ8t YkscnLJOHcrpeD3N8+hUnbwgknfbpPd39DU83JW9Axr3XUc+xgyubSV5aWE43DiPK/UtMZ1LaBi ziUFv2bRGeQAhliUeTLr2RmLlCPhmd6TW9wPWmoxl1b7ojyCJK+6JsPfzsX9EFYin+KlMp1LBNi JGEUsQ6pZbyvWfubRS7eW5iYpQIjqhfmH9d0cvSOkEKrgwURqXNA63NPuuwTwu/23qVXhs4zWPa 3+i25QC//W1d/QeBOQHQeFLYCnC/r6xhkiAJ9PHc6dEkmRo4NE7WWTI/k+mECUYGHl+FPb/EwQe iAZzTKueIFObuwNIiZe4KKtkQ7mi6+dSZSYIeZlB51P6PQGiaZjM/c/XKyMX0w9bOF4f632uxJh mY= X-Received: by 2002:a05:690c:1b:b0:7ac:ff2:4603 with SMTP id 00721157ae682-7b9ecf0fee4mr87792467b3.20.1776549012081; Sat, 18 Apr 2026 14:50:12 -0700 (PDT) Received: from suesslenovo ([2600:1700:18fb:6011:3699:d8a1:7856:daf4]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7b9ee9ce88dsm24935397b3.48.2026.04.18.14.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 14:50:11 -0700 (PDT) Date: Sat, 18 Apr 2026 17:50:09 -0400 From: Justin Suess To: Song Liu Cc: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, paul@paul-moore.com, viro@zeniv.linux.org.uk, brauner@kernel.org, kees@kernel.org, gnoack@google.com, jack@suse.cz, jmorris@namei.org, serge@hallyn.com, yonghong.song@linux.dev, martin.lau@linux.dev, m@maowtm.org, eddyz87@gmail.com, john.fastabend@gmail.com, sdf@fomichev.me, skhan@linuxfoundation.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH 08/20] bpf: Add Landlock ruleset map type Message-ID: References: <20260407200157.3874806-9-utilityemal77@gmail.com> <20260417.ohgoh0Eecome@digikod.net> <20260417.aPh1ooQu8esh@digikod.net> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Apr 17, 2026 at 01:42:02PM -0700, Song Liu wrote: > On Fri, Apr 17, 2026 at 1:33 PM Justin Suess wrote: > [...] > > > > > to the caller) and pass them as file descriptor? > > > > This "pass them as a file descriptor" is the tricky part. It would be > > > > very convenient if we could send the fd to bpf from userspace and have > > > > it be implicitly converted (like in the BPF_MAP_TYPE_LANDLOCK_RULESET > > > > implementation) in one step, but I just don't see a way to do that with > > > > the bpf_landlock_get_ruleset_from_fd kfunc approach. > > > > > > Song's idea to have a generic FD map looks promising. > > > > > > > I agree the generic FD map sounds like a good fit. > > Well, I am not 100% sure a generic FD map adds enough value > on top of current __kptr solutions. This will be more tricky if we > have to touch file_operations. > > > So this would be three parts like: > > > > 1. The new point-of-no-return flags for NNP and staging domain to > > execution time in Landlock. Selftests and doc updates. > > 2. The generic FD map implementation for bpf. Selftests and doc updates. > > 3. The BPF kfunc implementations for Landlock using the same point-of-no > > return staging. Selftests and doc updates. > > > > The scope of which is probably too big for one series. > > > > Luckily part 1 is pretty close to being done as part of my work for v2 > > of this series, and can standalone as a preparatory series for Landlock, > > since it adds flags and features that have utility outside of BPF. > > > > Open for ideas on how to split this up (or even better, for some help in > > implementation or prior works). > > > > I'd like to get some feedback and figue out what this generic fd map > > should look like and get some more eyes on that idea to avoid wasting > > reviewer time on an unsuitable implementation. > > I will think more about 2. If it indeed adds good value, the upcoming > LSF/MM/BPF is a good opportunity to move this forward. > > In the meanwhile, we still need kfuncs to access landlock ruleset. > Therefore, any work on that front should be useful. > Instead of a new map type, could the same usecase be fulfilled as a flag for bpf_map__update_elem? (BPF_FROM_FD?) int bpf_map__update_elem( map, &key, sizeof(key), &fd, sizeof(fd), BPF_FROM_FD); We could register an operation at the BTF type level to acquire a reference to an underlying kernel object from a struct file* to a specific BTF type, like how destructors are registered. Something like void* bpf_kptr_acquire_from_file_t(struct file*) (adding it to btf_field_kptr). Then this would get a reference on the kernel object for the underlying file and insert it as a kptr into the map if the file indeed points to the correct type. This would be valid only for a map holding a supported __kptr type implementing the bpf_kptr_acquire_from_file operation. This flag would allow inserting __kptr from userspace (previously impossible) with a file descriptor. This wouldn't need any new file_operations changes nor any new map types. This could be implemented for specific kernel object backed FDs as appropriate. > Thanks, > Song