Message ID | 20250129203932.22165-1-wufan@kernel.org (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 3BD5FC0218D for <linux-mm@archiver.kernel.org>; Wed, 29 Jan 2025 20:40:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AD2B6B030A; Wed, 29 Jan 2025 15:40:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 368A76B030D; Wed, 29 Jan 2025 15:40:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 230806B030E; Wed, 29 Jan 2025 15:40:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 058C96B030A for <linux-mm@kvack.org>; Wed, 29 Jan 2025 15:40:42 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 76D1DAF260 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 20:40:42 +0000 (UTC) X-FDA: 83061657924.28.47B0152 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf24.hostedemail.com (Postfix) with ESMTP id CF1EB180004 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 20:40:40 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Xd41c4UU; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of wufan@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=wufan@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738183240; a=rsa-sha256; cv=none; b=lKjzNoz16h2kNqj76kY4L53yV/0b09AS1ZacH129vSTEbg67zmgNtkUSd7I6SEhjsRNjIR XScWpAzyZ4aV/lkVE8H5HoxGlkJRhGhlmI6Ljxi9/oj85q4F2Q6fEy+Xr7Jug4BgQJWRmQ N63RjRXcAEq4W4E+L3sJEpkyo2dxSwg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Xd41c4UU; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of wufan@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=wufan@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738183240; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=vu1/ZZcNT8Rw3Gxn2hQ5iyZNRX3swSU4IRLWn2NHk0c=; b=yVgcwN4iwGm6CRBlAeSBNXArO5202IzDhvPEEfsZI9GMN0XyEmMZhm85IjE9QGI5HFTXog ICCEeA2u9kTQvw2LIcqtrnTpSurcowiTytJDhRv8xtnvmikESiXRBehQJLe40+h26IkPr2 G1j07jeyFwxCCm0t38wpfPpLpuMrMi8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id EB315A41C11; Wed, 29 Jan 2025 20:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ED86C4CEED; Wed, 29 Jan 2025 20:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738183239; bh=TvUphb/vlGuqwwWD+ZxDY8HH0Mf2NGUG6U/J+wtc9zA=; h=From:To:Cc:Subject:Date:From; b=Xd41c4UU4fyEfrNAqf6xoW7OKWID7moCyhMfXJfDPcaESFSvKp+E9+0KkfY7Eo3lc ffz3Umx7wqSHwOzwftAS8vBX+xj8D7LUlJBTb2Hf1gQSUNYpE9PlAFXIzhRHN/4A0F okVjeWVu6UdwrkqWwTZ21wRxZgn9u5mNAskzF6prH8HNTwUGK00cPE0hTH3RQDZcF/ 6L7hMPSI65PyxHiq93BHe33XjP2ANtvtn6z0FQuXiyjlOqO16ST/I/cxRQwYyuWMso jWftYOlkUfnWdfA3dgwvrbv5I3/uzSzIsAyVPI9Wtba6uj9TliyiyNr5SSsq0aLnIU kTPFgH7LyEeDA== From: wufan@kernel.org To: corbet@lwn.net, jmorris@namei.org, paul@paul-moore.com, serge@hallyn.com, akpm@linux-foundation.org Cc: linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Fan Wu <wufan@kernel.org> Subject: [RFC PATCH v2 0/2] ipe support for anonymous memory and memfd Date: Wed, 29 Jan 2025 20:39:30 +0000 Message-Id: <20250129203932.22165-1-wufan@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CF1EB180004 X-Stat-Signature: 55wd1yywra8jpcj57hdqfmqhnzs931sy X-Rspam-User: X-HE-Tag: 1738183240-195352 X-HE-Meta: U2FsdGVkX1/rtuno0NrTGtnUXQhWgo3ONXGpurTve6A89R3KIiW2y/uDWowIXZTrTLC4mO/51YycvGrbzbYRyFVXNjsOM5Y4ePiiXcSiTf5UwkXoeIq4IzilQDUPrBimaNIR77pe447bms4lLll3hVUVkN/oad+xSS+ShzvFbfAlU5++FJZtX3vtABIsiepxGDzcZFfOL0RjnUpYrHeuszZRYDU4oqjFcWymH/TSl3AbQUGlq52rnZVIWL1qSpV5nNIweTwaNF5LXzECoajRPomjOAvu3vcT98e9q+lwn4TVVc7t+FJFASYQgUqG7bFbepj/0F96CkgxxNPhyeTkULGwOoGnN3hnpM/mT2pNUDb50/MqZhJCX220D4xRRla/184mfowN8/3eyhUlk7hmLD/c+1XJ6CxPMrcp1W8UANOHKzftO4NfRV/WVkc5hnlEWpGGrcfYAFAAhJlwycad+fM1/xmPF4BNfJY08VHIU+m9//J9dhhUKdGguLNWGPBmUjNofIljnEF4ontCZ7HJEWS7vlL5cDLe98PZLzZP3uJLJ9CQyFO28MZpjqQPDrjW1l4XFnhZY9ImigSra2Wa+PIWj0mGQhnqGGq7lbFyU30zh8EEzWIQ6kWGO1Ond7EE76QwsiaHdLZDnku/k2xSLRBfUpOzeBJtVULSflU3WkdReLeZpOmpPYErr3VKqyhFsczp1vaaZGvrb3qpSGCvaCxVgweF4HNaQ1ZbbSs21s8znJBEKlOGBMxzOjjrJJ8a84jC2l4p6IU2na2KUDpD4m7jCAZHVPsCWr1VruDEl63Nt59Yiu9y6XAs00SCVvl5D5cGVaV5TMkGJSNCNuH9pFYQT90JY21PTLLfjbRdDER65Jl+lCA8pWEthlu3ry+k5fBimjWJA16CoLP4fRFZEnOSheR3489eFKdLy2oy55bz1lSMMJQjvId1t70iCw0v18yZ2hGEXwXfSMiRAbP B/DVLudf LuQ4rJFcrTXbbCIWvZqiK2nR6j6Sw1iKt/NC9sBU2XbEZ78udqF0qPzGEBnM5+Cd7W9Jxe2RDNmMulkFpsv6q4EAdqcQCQH2OoJiIXhJCpYw9ZDTJI+WMk1agzDGAjaiBX7AdMWA/TQ9J8304axiP4Q/KM2Azf4a6qZkVo0fE+G+kJ6vuTsgQqbw7X4i9W3Du1VWpYZC37azuw6jxmna6NjyNElIR2HEGtmoegzFdsVFDxOO0VrIpFnWh6tsFnTu2AYj4EPQHXwmYymdsbgKpZSqnQ/VUO+4F2z7C+UcdVgjO6VFkJbQF4npbkUrCIgydFkX/xiy+2KTgI1uOXV1Wf1g3oA== 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
ipe support for anonymous memory and memfd
|
expand
|
From: Fan Wu <wufan@kernel.org> This patchset adds support for anonymous memory and memfd to the IPE LSM. Currently, the IPE policy language can only allow or deny a physical file from an integrity-verified source. However, for events triggered by anonymous memory, either created via mmap() with MAP_ANONYMOUS or via memfd_create(), IPE provides no mechanism to explicitly allow or deny these events. Execution from anonymous memory is a common use case in modern applications. For example, JIT compilers store generated code in such regions. This patchset introduces a new IPE property, anonymous_memory, to let administrators explicitly allow or deny events triggered by anonymous memory. For example, the following policy: policy_name=example_policy policy_version=0.0.0 DEFAULT action=DENY op=EXECUTE dmverity_signature=TRUE action=ALLOW op=EXECUTE anonymous_memory=TRUE action=ALLOW will allow execution of files from a signed dm-verity volume and also execution from anonymous memory. In the current design, the anonymous_memory property covers both memory regions created by mmap() with MAP_ANONYMOUS and those allocated by memfd_create(), as both share the same semantics [1]. However, because regular files on tmpfs, shmemfs, or hugetlbfs are also backed by anonymous memory, the policy language might not be entirely clear to users. An alternative approach would be to define two separate properties, one covering MAP_ANONYMOUS and another covering memfd_create(). Nonetheless, allowing execution from anonymous memory does increase the attack surface. Future work will add additional properties to the IPE policy language to provide more fine-grained control. For instance, one possibility is to permit only processes with certain security attributes, such as specific SELinux labels, to execute code from anonymous memory. The ipe test suite has been updated to include anonymous memory tests: https://github.com/microsoft/ipe/tree/test-suite [1] https://man7.org/linux/man-pages/man2/memfd_create.2.html Previous Postings ----------------- v1: https://lore.kernel.org/all/66922c42-c3a2-4634-a8f0-4c8c2b4c051a@kernel.org/T/ Changelog --------- V2: * Update test suite to include anonymous memory tests * Fix property implementation and add memfd support Fan Wu (2): memfd,lsm: add a security hook to memfd_create() ipe: add 'anonymous_memory' property for policy decisions Documentation/admin-guide/LSM/ipe.rst | 12 ++++++++++ Documentation/security/ipe.rst | 9 +++---- include/linux/lsm_hook_defs.h | 3 +++ include/linux/security.h | 8 +++++++ mm/memfd.c | 2 ++ security/ipe/Kconfig | 10 ++++++++ security/ipe/audit.c | 2 ++ security/ipe/eval.c | 34 +++++++++++++++++++++++---- security/ipe/eval.h | 13 ++++++---- security/ipe/hooks.c | 12 ++++++++++ security/ipe/hooks.h | 4 ++++ security/ipe/ipe.c | 7 ++++-- security/ipe/policy.h | 2 ++ security/ipe/policy_parser.c | 4 ++++ security/security.c | 11 +++++++++ 15 files changed, 119 insertions(+), 14 deletions(-)