Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4158987rdb; Mon, 11 Dec 2023 10:24:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXzhDooNCnCHg45J3eUVeFZy1R9BQYG/GPzSrrlZbRki+geLhMpoSCtcbs6GR6XpZtaezi X-Received: by 2002:aa7:8896:0:b0:6ce:39f3:88f2 with SMTP id z22-20020aa78896000000b006ce39f388f2mr6403958pfe.23.1702319063822; Mon, 11 Dec 2023 10:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702319063; cv=none; d=google.com; s=arc-20160816; b=Vmt2LBlcauJ/wrYumPrQYOh9VH3SYPpgBQ/NYgNj3/SI7DIQVObfIPebqeeh8mggA0 3Jbwr3CV0P0a3Lq8KxLSaRdA5ptfiXIymC1iXMLgMM4tkEN17fsghnWlAk3N+XXYGSUV sWqsDUIEeVLjzS13/A509jxNZRkkBNwybaKTkUc7rRwl5uq5YW6a2P4J0J4mQ5JawuYu 5nstHZWYnxDTbEIaBTtZe3nICyzkL+NdjaNWvyn3TwRncNoXs9fQivhyqoyeuOnYogoQ lPowFSC8TjtALgMB+eZ9NamzoYEy5PByrp5RcSMRu+9vGBumXGRtLPWWf6iHl3G+2qfW Paow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=yTZUGzqXgAgDzLk+TnvpFqLchf/LU4PPH7EmQyI17uI=; fh=woQij8sSEg+Zvr2T8M8fueLjObjo4W2vXfrTNqCqTfc=; b=ZYYsoBcMKWqvu34r9ippwS2REhv/MF5Lp4amEk1kEWnKvVOocFcdyG9whx7Tz17l2O dfWLyScvO6Nw3qt8QY4KYT8iqT04+fJhNc3EmERYbpmvzCwda3GC98rK/NUDsUqylPDo PzEoV+QzsudIw/fckXWAWuUc4xVrnLmATu/ZtRoqJBUmhw10mDStNJLzxiBG/S+Lu3jx pP7xrJ4itrptOik0Hsynvcx2rBhk18BP3j4EduvWJzr/kpyvfyzpwvDAEiDZoA6l1ahw 8Lluhv8//WlU5v6cOYTV5bXj0bBY2QdzNtSZJpY4qF9upVAkvDe/k3/lMhzbB34U5MEw SJZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ejaujRnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x10-20020a056a00270a00b006cbb132d46dsi6417548pfv.244.2023.12.11.10.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:24:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ejaujRnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 43CD580A30C8; Mon, 11 Dec 2023 10:24:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344963AbjLKSYM (ORCPT + 99 others); Mon, 11 Dec 2023 13:24:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjLKSYM (ORCPT ); Mon, 11 Dec 2023 13:24:12 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3752BB4; Mon, 11 Dec 2023 10:24:18 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-77f408d123bso151098985a.0; Mon, 11 Dec 2023 10:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702319057; x=1702923857; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yTZUGzqXgAgDzLk+TnvpFqLchf/LU4PPH7EmQyI17uI=; b=ejaujRnGTm2d7WqGQiQipLhCyW1d9eNLZsXY4CJTCUU7mdPsH172Q8g5NCPKEUU27V hn5ySNYRY+4Y6QROhzkKvUhppVhgWg1VY9p91hl/7giD7sHUndh4tMsJwa1UYGg4lF3y 0rreL6dlru1W9+4ILhe5wtgyeU7wGldEeqmocCEpz9kYxYmMFNnJglNhrheH1/SAHRFO 8BdI2wTpwfEeAIHCHfBnpPO4LzNi3dkWKYcPSTfN1xE2JA4WERhQwiiYfXQxuTxyISN/ YePKuWsymbM5gXOj6UwVhDMS6Q0pCf3+dOXIpFtPKLOOJdgm12ATE2qrtQzflIgC2SEn JbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702319057; x=1702923857; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yTZUGzqXgAgDzLk+TnvpFqLchf/LU4PPH7EmQyI17uI=; b=XC/+UMv6fn1WAKxfICHZ/ZFMamU8M3XdjH9Zj+i9s8ZJ+ZAJPgbH36swnUdzNt1sgs FEVhHnnhhriv6KVxtZOZj5TBso3CgxvpXXqP+Vi+26De9mIISsTf+YZ1hP7Y55iNUzLZ xS7brQ7syrmidYLLYa2g4NZvSGUHkOqlxfAST3FerT1sKUdMMOjQCIRQzHxRE5L24AmX saoNCsfLxzTgxYq167rmeoBOJaGSweYKpCGxwhh15tpuhi/X6Oqb4cP7NDU8EbGaacEx D9NJfmW7XiUcHJXm93Lhh0nUAvA5JkXmF9ihIRAiMwKZVyCanlV2mxSzbOBEDA/06yfs WQ1Q== X-Gm-Message-State: AOJu0YxpWa8NwAGGXATGYjAleAtzHesAkm10YsrF+TqTur58HhVLHnFg dTF2awdFhe9IaYBquJcYrKorRU9Xyt3YrnzChOY= X-Received: by 2002:ad4:4528:0:b0:67a:259d:8ce0 with SMTP id l8-20020ad44528000000b0067a259d8ce0mr2984856qvu.17.1702319057240; Mon, 11 Dec 2023 10:24:17 -0800 (PST) MIME-Version: 1.0 References: <20231208172308.2876481-1-roberto.sassu@huaweicloud.com> <20231208-tauziehen-zerfetzt-026e7ee800a0@brauner> <6e05677355d6d134dddd11da56709b424b631079.camel@huaweicloud.com> In-Reply-To: From: Amir Goldstein Date: Mon, 11 Dec 2023 20:24:05 +0200 Message-ID: Subject: Re: [RFC][PATCH] overlayfs: Redirect xattr ops on security.evm to security.evm_overlayfs To: Seth Forshee Cc: Roberto Sassu , Christian Brauner , miklos@szeredi.hu, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, paul@paul-moore.com, stefanb@linux.ibm.com, jlayton@kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, Roberto Sassu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 10:24:22 -0800 (PST) On Mon, Dec 11, 2023 at 7:15=E2=80=AFPM Seth Forshee = wrote: > > On Mon, Dec 11, 2023 at 04:41:46PM +0100, Roberto Sassu wrote: > > On Mon, 2023-12-11 at 09:36 -0600, Seth Forshee wrote: > > > On Mon, Dec 11, 2023 at 03:56:06PM +0100, Roberto Sassu wrote: > > > > Ok, I will try. > > > > > > > > I explain first how EVM works in general, and then why EVM does not > > > > work with overlayfs. > > > > > > > > EVM gets called before there is a set/removexattr operation, and af= ter, > > > > if that operation is successful. Before the set/removexattr operati= on > > > > EVM calculates the HMAC on current inode metadata (i_ino, i_generat= ion, > > > > i_uid, i_gid, i_mode, POSIX ACLs, protected xattrs). Finally, it > > > > compares the calculated HMAC with the one in security.evm. > > > > > > > > If the verification and the set/removexattr operation are successfu= l, > > > > EVM calculates again the HMAC (in the post hooks) based on the upda= ted > > > > inode metadata, and sets security.evm with the new HMAC. > > > > > > > > The problem is the combination of: overlayfs inodes have different > > > > metadata than the lower/upper inodes; overlayfs calls the VFS to > > > > set/remove xattrs. > > > > > > I don't know all of the inner workings of overlayfs in detail, but is= it > > > not true that whatever metadata an overlayfs mount presents for a giv= en > > > inode is stored in the lower and/or upper filesystem inodes? If the > > > metadata for those inodes is verified with EVM, why is it also necess= ary > > > to verify the metadata at the overlayfs level? If some overlayfs > > > metadata is currently omitted from the checks on the lower/upper inod= es, > > > is there any reason EVM couldn't start including that its checksums? > > > > Currently, the metadata where there is a misalignment are: > > i_generation, s_uuid, (i_ino?). Maybe there is more? > > > > If metadata are aligned, there is no need to store two separate HMACs. > > I can only think of three possible sources for the metadata overlayfs > presents: > > 1. It comes directly from the underlying filesystems > 2. overlayfs synthesizes if from the underlying filesystem data > 3. It's purely generated at runtime > > Are there others? 3.b. purely generated and persisted in overlay private xattr but IIRC only s_uuid fits in that category > > 1 and 2 should be covered by EVM on the underlying filesystems. If 3 is > happening then it seems like hashing that data is just confirming that > overlayfs consistently generates the same values for that data, and > verifying code behavior doesn't seem in-scope for EVM. I agree. I don't think that IMA/EVM has a reason to assets overlayfs specific metadata. Thanks, Amir.