From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 70A35367287 for ; Thu, 21 May 2026 16:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779379616; cv=none; b=oWWRFppn1Ep4bbJIjuDPwZwu4WK3swMNrfCE4byTW+MnRr5v8v6Ccz56578qKcftTRILFlZmQFI8xkuaBMmCbQ7Dv2me/UVDk3VqpD9SzVIdxuPfSQhV58OZwCaQqVjni92AdDYNAB+ePaD4QRI8g9NXj1vsFAmrGBvIVA0Rogs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779379616; c=relaxed/simple; bh=khWmooEg087b7SmVBAd+sEhZEHodzQNRIpH+OOn4wi8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BkAvl9zPmAE2JkYCUADeY952KPj061SALMNEkKBDSUZl3JMykimO8GAd2+C88wLbpx358Avn0BHMdzB7jZiidjCuyRXZpednni2v3t58CvgXt40xavZnHIxv9dOQjIem5HvjA3/A7mshKveJCWaPpmx5Oxe74ZbnEycDR1iCti8= 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=Z199oCef; arc=none smtp.client-ip=209.85.128.181 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="Z199oCef" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-7b4ee3a88e1so59853067b3.1 for ; Thu, 21 May 2026 09:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779379614; x=1779984414; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=q7i3h7yC1z4islTPU/5JKiDY3m5Oj5w6V5X1AGvkDkc=; b=Z199oCefb5k9DUTNnMtvcw7fATP/DfV9PEo1B0FLf1Wnc9iWCOI/PdYytY3hIZUlKj IJ6Spo/+a490H26uHwPGWyr4bFUIbnRkLXEW//GZ04364NtuqIPMs3JaSbw5tGKyXHnm Y7vGEPCI6Wd/eFUkRgsExKNBp7VE7dUna471aYAEEVPV9fikX9uujWBI5pGwJHVg/1TU m51jMWWXh1gs2gu/Rwml4C/NaQg0Zl58hdqquwvlEZiM4zdrYqf0GTh1jbBMJlT2MfqE 7nTavZpQ4kINe+MOnZeYpiIVJ/Zt6waD/060AbDrBCqr7SZMvYuakev8rp9/JbIJ3Gis DJMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779379614; x=1779984414; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=q7i3h7yC1z4islTPU/5JKiDY3m5Oj5w6V5X1AGvkDkc=; b=nqCcP9hM7gZUdj8dc8HSuKDEx8B61mfdRfYwXo/edPi7nEVV3tqPA8NnyksONaPAWC xjE/9NBdpqM6oSb8C/lIerxEuGwbEUk0wvdA8z7KzaHcA4g2e/3fnCdJxAk3SOy7DnmM HMTz3a3nDYGGBHp5JFJMtzhudyAuLeMbIrikQmci5XzEuv6S7l5eLaD5Ykl+7Rt23h7b nP2yuFIe9GuZV+n/tEUQYe3rkSIl5FcpdNh/tTQy2YY5aBndcNjTltcmGmLjZyRvpWHP 1OGA/ky6/njjJO7OtMasicocD3fBu+saUJShlh/3GwoPO4EAamxwp3Uoiw0TToHqPbZn a8hA== X-Gm-Message-State: AOJu0Ywkl1+y7uIgBKE7uhMnt/C1haJkfaSqv1mzWbQmPeXLrPcTqzMx trrpRf2koet6rtCMwEFZvLDpQ6E66xLUdISiOeWgExNz1Km6ufr5q3LGFt3MVpUt X-Gm-Gg: Acq92OEildmjzioGQvzrhW9a02wwZ7RRcaiWQpAMUOrX4YW/6/vY8LMg0EoRdAIdGOQ srUGWR+LzGsDEEabgj3xgx5YQatg+D1NBECGVTtimOCEzy2gQeh4tWgNOe6QuHDyJbV3nJFD2El Lfpfn/Cef0VJOQWQhWwMDuqCI7O1t3MdxsfTORGwnIYvQRVuw+Arj69RdHBLHIcjNsmQ+TGC2C2 BShmaxlTSfe2c6Q8sfKo7v6tmv4wFgnAiwuKEEEvlAwEANxoMv/LVTvV0E7FSjCzRDZL5EJAiCW PRyeStq0EEqunu0t9sSu+Yi0oCgCJ8l9scYLMMumma1ZaNXLVPADPNqn4bBxQQItUxeuCt2plLS PP4tFtmog3/ew5412JepyCQyXyluDFt/M6CLXtflGFhOhvONVp6bNI53EGJjHcJQZx960hzIBEY 0V8+uEKCaKEtiOrUYxTzC49F8DhqICOyC0qLknjQEVhSdz73NiBLlCrZWv9vIb8Kzrjd8B/kQ= X-Received: by 2002:a05:690c:4b83:b0:7d0:4824:6413 with SMTP id 00721157ae682-7d20d60aabfmr36799447b3.39.1779379614432; Thu, 21 May 2026 09:06:54 -0700 (PDT) Received: from zenbox.prizrak.me ([2600:1700:18fb:6011:c2cf:2e92:9a48:97a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7d2c7abad87sm4657587b3.2.2026.05.21.09.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 09:06:53 -0700 (PDT) From: Justin Suess To: gnoack3000@gmail.com, mic@digikod.net Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Justin Suess Subject: [PATCH 0/6] landlock: Add scoped access bit for SysV message queues Date: Thu, 21 May 2026 12:06:34 -0400 Message-ID: <20260521160640.1716746-1-utilityemal77@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series extends Landlock with a new scoped access right, LANDLOCK_SCOPE_SYSV_MSG_QUEUE, allowing a sandboxed process to be restricted from interacting with SysV message queues created outside of its Landlock domain (or a nested domain). While use of SysV message queues is less common than other IPC types, they are commonly used in older applications which may be vulnerable to exploitation, so they are a meaningful attack surface to restrict. Background ========== SysV message queues differ from the IPC mechanisms Landlock already scopes (UNIX sockets and signals): they have no FD or process-local handle. A msqid is valid IPC-namespace-wide and can be obtained without calling msgget(), so simply hooking msgget() is insufficient. Domain provenance has to be tracked on the queue itself and checked on every operation against it. Approach ======== A new credential blob is attached to each kern_ipc_perm at creation time, recording the creating task's Landlock domain and a @kind tag identifying the IPC object type. The @kind tag is required because the LSM core allocates an IPC blob for every kern_ipc_perm regardless of kind, and the generic ipc_permission hook fires for semaphores and shared memory as well as message queues. The enum also leaves room to extend scoping to sem/shm later without changing the blob layout. Enforcement is done from security_ipc_permission(), which is the single choke point for msgget() on an existing queue, msgsnd(), msgrcv(), and the msgctl() variants that go through ipcperms() (IPC_STAT, MSG_STAT, MSG_STAT_ANY). msgctl_down() (IPC_RMID and IPC_SET) bypasses ipcperms(), so the per-call msg_queue_msgctl hook is kept for those cases. msg_queue_msgctl also covers the IPC_INFO / MSG_INFO case where no specific queue exists. Quirks ====== - Denials surface as -EACCES rather than -EPERM because the generic ipcperms() path maps every LSM denial to -EACCES before returning to userspace. This is documented and the selftests check for -EACCES accordingly. - Because there is no persistent handle, a msqid already obtained by a process before it enforces this scope can become unusable once the restriction is in place; this is intentional and documented. Patch layout ============ 1. Add the kern_ipc_perm credential blob and @kind enum. 2. Implement LANDLOCK_SCOPE_SYSV_MSG_QUEUE, the ipc_permission hook, and msg_queue_msgctl coverage for IPC_RMID/IPC_SET and IPC_INFO/MSG_INFO. 3. Bump the Landlock ABI. 4. Selftests covering msgget plus a separate fixture for msgsnd, msgrcv, and msgctl using a pre-created msqid. 5. sandboxer sample support for the new scope. 6. Documentation updates covering the new scope, the -EACCES return code, and the implications of non-persistent handles. Test coverage ============= Selftests exercise denial and allow paths for msgget, msgsnd, msgrcv, and msgctl(IPC_STAT) across domain boundaries, including nested-domain inheritance. All existing and added tests are passing. Kind Regards, Justin Suess Justin Suess (6): landlock: Add kern_ipc_perm credential blob structs landlock: Add LANDLOCK_SCOPE_SYSV_MSG_QUEUE landlock: Bump ABI for LANDLOCK_SCOPE_SYSV_MSG_QUEUE selftests/landlock: Test LANDLOCK_SCOPE_SYSV_MSG_QUEUE samples/landlock: Support LANDLOCK_SCOPE_SYSV_MSG_QUEUE in sandboxer landlock: Document LANDLOCK_SCOPE_SYSV_MESSAGE_QUEUE Documentation/admin-guide/LSM/landlock.rst | 1 + Documentation/userspace-api/landlock.rst | 30 +- include/uapi/linux/landlock.h | 3 + samples/landlock/sandboxer.c | 20 +- security/landlock/audit.c | 4 + security/landlock/audit.h | 1 + security/landlock/limits.h | 2 +- security/landlock/setup.c | 1 + security/landlock/syscalls.c | 2 +- security/landlock/task.c | 137 ++++++++++ security/landlock/task.h | 50 ++++ tools/testing/selftests/landlock/base_test.c | 4 +- .../landlock/scoped_sysv_msg_queue_test.c | 256 ++++++++++++++++++ .../testing/selftests/landlock/scoped_test.c | 2 +- 14 files changed, 503 insertions(+), 10 deletions(-) create mode 100644 tools/testing/selftests/landlock/scoped_sysv_msg_queue_test.c base-commit: 9c5b83756e7b7eab35335da0d5c02a8854bbf416 -- 2.53.0