From patchwork Tue May 2 17:17:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?G=C3=BCnther_Noack?= X-Patchwork-Id: 13229197 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CEBDC7EE22 for ; Tue, 2 May 2023 17:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234316AbjEBRSM (ORCPT ); Tue, 2 May 2023 13:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234305AbjEBRSL (ORCPT ); Tue, 2 May 2023 13:18:11 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E238410FE for ; Tue, 2 May 2023 10:18:00 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f19a80a330so25439775e9.2 for ; Tue, 02 May 2023 10:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683047879; x=1685639879; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qki2g9Mb14rbBQdzJX6RPgJ2mA3yqsPZYHsNI+UG2NY=; b=LRgNgyt5is5EO7/FU758SAALBPFDXtM6DpEey8ZScImQECFzOrv+8TjtS0a5micguI aK6HE0jA2Sk4fqfV5FDlYX3J5T4QcEaMzyAudviADfo1/Ro++vbfs9TJ1tD2dxKckVR7 uz3Oq1OVALtjeH6iv54uQZDlq3qtKQ0OEOzY7J2ckz5iNRipJYrOWr76IwtgQUlfuRGX WB0K161po13pzvwlJzTQva7AfsZ2vOE0K1/xEWpJKRkioB6BvyIyTvBHFtiGOLQruAlS Sqm9dvJO9mInc0RyuqKll8rLNY0tbeb0cfmcL2zUSAHmOjmcELVh2M2jxWzQ46XxVbWP K7aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683047879; x=1685639879; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qki2g9Mb14rbBQdzJX6RPgJ2mA3yqsPZYHsNI+UG2NY=; b=L4eRYbFsrviUME1wF7TvgxYXfJCO8nno6sTpUd5VIGwzCcHE5NODNmczMw/4GNK/ye 7mia7zFY91kOyVkOWAq9Ntzkyj0kSQHoHwErX4CAFWgKrUbvGPnGYxhJN0sLh1KYse6m NqiEJiPkWMCicJNuFwcTPIYaG3UygOZuig0vEBWdqsqJpS9UqRMNfv8K4uS/0YqQXqRs YxEo6LeB6x7kABt/2FgqbdPUSwOoqVLFp3JGS00Ixp4iX1IknJmw9FYXYkyU6kUgOBsK gR3fpfeOA3+LtIdJ5q77apDgb/ygedIkb9txCodDRd5Xz1Iox8WNWDxmxcTAg/0rXVMF joAg== X-Gm-Message-State: AC+VfDzl1UJM0/AXrkBbF8N2ACea05UdHwokilZiWCa6Yyi6KvCcAetr v6f1qbK0hEO+dvwW6veNvM+Sp1DEfD0= X-Google-Smtp-Source: ACHHUZ5r1nuDZzaL07DhNo9MNj8elE9fRGvSEjlrB9NzIh04yXRQhKIfrmcxgKgooXZDt0KBiALYNA== X-Received: by 2002:a7b:cd18:0:b0:3f1:6fe2:c4b2 with SMTP id f24-20020a7bcd18000000b003f16fe2c4b2mr12865625wmj.23.1683047879122; Tue, 02 May 2023 10:17:59 -0700 (PDT) Received: from localhost ([2a02:168:633b:1:9d6a:15a4:c7d1:a0f0]) by smtp.gmail.com with ESMTPSA id s12-20020a7bc38c000000b003f1739a0116sm35916956wmj.33.2023.05.02.10.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 10:17:58 -0700 (PDT) From: =?utf-8?q?G=C3=BCnther_Noack?= To: linux-security-module@vger.kernel.org, =?utf-8?q?Micka=C3=ABl_Sala=C3=BC?= =?utf-8?q?n?= Cc: =?utf-8?q?G=C3=BCnther_Noack?= , Paul Moore , Konstantin Meskhidze Subject: [RFC 0/4] Landlock: ioctl support Date: Tue, 2 May 2023 19:17:51 +0200 Message-Id: <20230502171755.9788-1-gnoack3000@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: Hello! These patches add ioctl support to Landlock. It's an early version - it potentially needs more tests and documentation. I'd like to circulate the patches early to discuss whether this approach is feasible. Objective ~~~~~~~~~ Make ioctl(2) requests restrictable with Landlock, in a way that is useful for real-world applications. Proposed approach ~~~~~~~~~~~~~~~~~ Introduce the LANDLOCK_ACCESS_FS_IOCTL right, which restricts the use of ioctl(2) on file descriptors. We attach the LANDLOCK_ACCESS_FS_IOCTL right to opened file descriptors, as we already do for LANDLOCK_ACCESS_FS_TRUNCATE. I believe that this approach works for the majority of use cases, and offers a good trade-off between Landlock API and implementation complexity and flexibility when the feature is used. Notable implications of this approach ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Existing inherited file descriptors stay unaffected when a program enables Landlock. This means in particular that in common scenarios, the terminal's ioctls (ioctl_tty(2)) continue to work. * ioctl(2) continues to be available for file descriptors acquired through means other than open(2). Example: Network sockets. Examples ~~~~~~~~ Starting a sandboxed shell from $HOME with samples/landlock/sandboxer: LL_FS_RO=/ LL_FS_RW=. ./sandboxer /bin/bash The LANDLOCK_ACCESS_FS_IOCTL right is part of the "read-write" rights here, so we expect that newly opened files outside of $HOME don't work with ioctl(2). * "stty" works: It probes terminal properties * "stty