From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 0F91031F990 for ; Fri, 31 Jul 2026 02:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785464484; cv=none; b=m/EvYd606p1jM6Kp+F81ZFpqZ/t7mGkUYnPeKwvjCdXW2aVxizQIwjtFCDiKhXefz315K4XGSzaSR1DcUdZTnh1ctKkcMg0fRN/jlLQPiwviZlLruvM7qoWhyetzIYX+ckfIYhkAmKX7yhWunK6CbJrm6WxTDdurW4aVtrGCPXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785464484; c=relaxed/simple; bh=My+S/AoHnM0sWQ2xfzHcL0mjHYwtuqRDL/YoeC794wY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O20bkx2ZmqH8ltVBSneuMRvjA7cLNAGhgeOnjGENxWO1BeA87w6qO1dlaQWLd8H1UzKBtVGHxfe/QYlrRQD7ADcadNFV6iWNzpKOFZ3yfAD8a4Sj2Emg4q4+vDOlqOjCeU5pbKAG/gfWs7UntCz1r18dux0lVbCYLievAA23aQA= 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=a1DwJtRu; arc=none smtp.client-ip=209.85.128.172 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="a1DwJtRu" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-8114a4542b2so7917507b3.1 for ; Thu, 30 Jul 2026 19:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785464478; x=1786069278; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XvJusACK6JVx1ShSYZD+EOjxsALcCJEGMTDUzMzDD3c=; b=a1DwJtRuTrfBqJIpT7wp4bSk7RCtJIXYYrQVMamrOzMYTTbcdNX4Pz/iB/L0505v/I xf2+zjVBY1gVRicrjaVJNGTolZiHTS3gSpp3ASRd77GUSYpAVcvmTKDrtBR2ND8pEAAj dNiJhesd1Wi5oMiYNsYCDJDzy8mhvswtiyKr0cqrFG1zBtkfMPSxq5r4FsymOZQEVArJ +WqStX3G74jsfik01Uv8IfbeT0Mv7diKahbvxNmHwjK89ztXWL8gq3536RaS9A4iVfm8 Ln4g0m1U8yWAQRhl401SCnyuRSzMNOWYJiR7gBlWRB4cTzzOBkOLtWVcJKP/q4RB67LU Q9jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785464478; x=1786069278; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XvJusACK6JVx1ShSYZD+EOjxsALcCJEGMTDUzMzDD3c=; b=cH/gFCsMBWXg/vPhwzugEV6ruw7ETrGpG7DBiJNLZb0S3ziYI1ikXJAGuuFLyFdj9i yd2X1a9KRaPOi/RmYa7+yAyVkKi2Q0wMoIHAwUurm+KmfglPmbu9wbwo0lFZ+1xMAtY3 VRdx3OfcWoL+Fi3P4/DVQU+s1KdNhWKhS71oL8lWXSFAsUkl0OLF6k5SLrQwZzQwqiFY v0NQeAutOBNA59hAbaP5slW0i3CnylogmTCzteJA6oabxHat4fF6jxIEAZNsatddkuaz BvQg2pGsSwb+qTLRtXCeb1W3pNmx3uYIQ957VJ+RkcbyDCsckgr0Eh5lVMGbPqyUPNr4 YBmA== X-Forwarded-Encrypted: i=1; AHgh+RoUEYsE39ybpDClHJYv6Hg2J80ODkPqZGKXa1PER5GpFNZ3rywFiBuXEOfA8k3E8RMeZoQqf5I6V9v7Th4=@vger.kernel.org X-Gm-Message-State: AOJu0YxFOM0porr53LF8C1sGCo6nj+o+KbI4PVpElmInIyQFNovPb4xO TMvS8l2SmBHHN+g66TaUxdaGlPU2rT2/Gh2dtRSd4mVnbnJuj47jhfxt X-Gm-Gg: AR+sD10S1luH8uwhbFt0NumfwLirKrbIlFvRTB+26pi/Y+akdEkupffBznl4BePmMyX gdoFL8KEEt/zqav5IoGip8vgaczdQpw8d89Wq1rwwSanMSTenWtEjW4RiTLm4effYbAhePhL9fB M4P/UH8oAbbhUMF2HYTTnGuxwVyahYep9wXsoH+M/YdlWh4azefwsfFhY+4iu4+9YtvWQrJXoQB ASRG4UAkR6TsBaj5tvba7lDZKmGz1KyDm4T0LYvIk/K4r4HALbreMv4GqgaLncqRPZBBbR54Cpu X9ZA3NeTJ1zygtF26oEst6iGSnohmXp52mQyQomS0TtLuqD6MJqIdmZvBNhaUKQ6fF3LDD8gqpL kT6t+UZ9YaX4Tki/cFwQRrDyychP4vtC2aIIsZkOvNdogytBUFPHV+pL9edPQGocR8ueprtkWCZ Xtx09ausRxpTONVNXTny1rdQp5CaauhiAffb6FHdLi6xchsSEQoNBhVIbObdnHePwA9hi8EAaGf Qn5ZTF6P2US3pQtv2lg1Q== X-Received: by 2002:a05:690c:e3ce:b0:81e:6c2e:f113 with SMTP id 00721157ae682-81fcbb0187dmr690287b3.36.1785464477862; Thu, 30 Jul 2026 19:21:17 -0700 (PDT) Received: from zenbox ([2600:1700:18fb:6011:e94:8a83:feea:6720]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fb8b26e8bsm20519047b3.47.2026.07.30.19.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 19:21:17 -0700 (PDT) From: Justin Suess To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, paul@paul-moore.com, mic@digikod.net, viro@zeniv.linux.org.uk, brauner@kernel.org, kees@kernel.org Cc: gnoack@google.com, jack@suse.cz, song@kernel.org, yonghong.song@linux.dev, martin.lau@linux.dev, m@maowtm.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Justin Suess Subject: [PATCH bpf-next 04/13] landlock: Expose the ruleset fd lookup to the rest of Landlock Date: Thu, 30 Jul 2026 22:20:37 -0400 Message-ID: <20260731022047.189137-5-utilityemal77@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260731022047.189137-1-utilityemal77@gmail.com> References: <20260731022047.189137-1-utilityemal77@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename get_ruleset_from_fd() to landlock_get_ruleset_from_fd() and give it external linkage within Landlock, declared in ruleset.h next to the other ruleset lifetime helpers. A following commit implements the LSM kfunc policy hooks, which need to translate a ruleset fd into a landlock_ruleset reference from outside syscalls.c. No behavioral change. Cc: Mickaël Salaün Signed-off-by: Justin Suess --- security/landlock/ruleset.h | 3 +++ security/landlock/syscalls.c | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h index 0437adf17428..b65d1c07e192 100644 --- a/security/landlock/ruleset.h +++ b/security/landlock/ruleset.h @@ -225,6 +225,9 @@ struct landlock_ruleset * landlock_merge_ruleset(struct landlock_ruleset *const parent, struct landlock_ruleset *const ruleset); +struct landlock_ruleset *landlock_get_ruleset_from_fd(const int fd, + const fmode_t mode); + const struct landlock_rule * landlock_find_rule(const struct landlock_ruleset *const ruleset, const struct landlock_id id); diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c index 36b02892c62f..9af2407274b2 100644 --- a/security/landlock/syscalls.c +++ b/security/landlock/syscalls.c @@ -293,8 +293,8 @@ SYSCALL_DEFINE3(landlock_create_ruleset, * Returns an owned ruleset from a FD. It is thus needed to call * landlock_put_ruleset() on the return value. */ -static struct landlock_ruleset *get_ruleset_from_fd(const int fd, - const fmode_t mode) +struct landlock_ruleset *landlock_get_ruleset_from_fd(const int fd, + const fmode_t mode) { CLASS(fd, ruleset_f)(fd); struct landlock_ruleset *ruleset; @@ -476,7 +476,7 @@ SYSCALL_DEFINE4(landlock_add_rule, const int, ruleset_fd, return -EINVAL; /* Gets and checks the ruleset. */ - ruleset = get_ruleset_from_fd(ruleset_fd, FMODE_CAN_WRITE); + ruleset = landlock_get_ruleset_from_fd(ruleset_fd, FMODE_CAN_WRITE); if (IS_ERR(ruleset)) return PTR_ERR(ruleset); @@ -564,7 +564,8 @@ SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32, (flags & ~LANDLOCK_RESTRICT_SELF_TSYNC) == LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF)) { /* Gets and checks the ruleset. */ - ruleset = get_ruleset_from_fd(ruleset_fd, FMODE_CAN_READ); + ruleset = landlock_get_ruleset_from_fd(ruleset_fd, + FMODE_CAN_READ); if (IS_ERR(ruleset)) return PTR_ERR(ruleset); } -- 2.54.0