Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4927746rwl; Tue, 28 Mar 2023 13:23:21 -0700 (PDT) X-Google-Smtp-Source: AKy350ZLxKQ1xj+kV5f7kgdY0LnDop6U7LtXd2hBOMcA1Qws5u8pZCQZU0EQfebjQs/OSllK5csi X-Received: by 2002:a17:907:7646:b0:92f:d1ec:a7d7 with SMTP id kj6-20020a170907764600b0092fd1eca7d7mr15341988ejc.15.1680035001109; Tue, 28 Mar 2023 13:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680035001; cv=none; d=google.com; s=arc-20160816; b=DYzat63+Cg1EqUDKBKnTNX43OlA/zx5lvy8rOx/ipC5xTc7d+lXpO4u/I8HeVl9XRa uUX/2vivby4Ga6moeqj+AocH+QCvZdmKAQCXttnth9Ob2GVC1WZpVYTXQ7xsMw+FRuMJ llLaGto9hFSsMLyy4jGkdMKpsMv0KKge8sH6fG1ekFS8IYynFUNWX1RyagcW4BV/IyFf nSdW0gSJQNwsYGgi8Bcue3+9/P+ABld8x3QbsmSTLDAuo78p3rfyzsdR30G80VxoZCuN 3TUgpgdloZ/Ix5Bi1uWqNIqpuC6pSMLDqeTtg+ryWa5UwZdJiYA8yFwiewwfHsZBC+PD Urbw== 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=YTUjsnH0pjAMPCdWUs8KgtrmbEQ7uRQfh39xHtc1mOI=; b=sYd6CzMUUX7zwfQ9vsKoq2JZl57uP8ztuhO8vgl9WDJtAeo617QzyjdZE6DsYDoLP4 diUqO1oMht9hVMRxFa3lP4xS5nOG3VPTOUhsUKMRrxptaih19ndbskIgdTIO1xe7neu5 gX39ZjfkFEV43t7cYCoaNYWJtPgR6cJdbgKzCBENTxPrhwTpmRvXRym+5LQTOc4iNI3p Qhq/PiblC2MmSYPynj6tFsJi+0M6G5OCdRuyrTpcHKn6rEWkR0xECotdLCNZsWb5rzq2 oFpJCONKGuR6gogMF8KTT/h70+SeVjeau33VzJmK7cME3FK0VIVsiOOWKvl4yK9J6GJt TJKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=ZISzzUBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020a170906049700b0092a9c23d2dasi28747871eja.383.2023.03.28.13.22.56; Tue, 28 Mar 2023 13:23:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=ZISzzUBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjC1UUL (ORCPT + 99 others); Tue, 28 Mar 2023 16:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjC1UUJ (ORCPT ); Tue, 28 Mar 2023 16:20:09 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC6040EF for ; Tue, 28 Mar 2023 13:20:07 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id b18so16751467ybp.1 for ; Tue, 28 Mar 2023 13:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1680034806; 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=YTUjsnH0pjAMPCdWUs8KgtrmbEQ7uRQfh39xHtc1mOI=; b=ZISzzUBAp2B86WTvie3LaaTm+XXMV1NsBYT+ss9Ay2P2TZV18c736vvSEzIoAMgiAD yyMfrBITnvGzSe0zitTngdlv9FE5B7kqtcVHa5dUfi5qBhCuM018z5BcpYSoI7bEVt2z ZC3kowL2cQRNQzFOhwJRwPeyH2MQqrp8NURsIr5JDzQpyL3WseVUnD7mAC626z6TQglg UoOeDKCOiKNAkc7HGHrpOlFtTEimlh5Dg4uX3bQo4lcrs02hnNHTYJq/Kw3dPuYr2VQI hXkP49aeyOtDyuAYueE49r0lldY98MycnxQ5Y1KBuHU/CwgwrBTDgx/qGu38MPY3mDw7 CiGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680034806; 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=YTUjsnH0pjAMPCdWUs8KgtrmbEQ7uRQfh39xHtc1mOI=; b=DO7FMQE2CzTVHJflFrH53n1SFwa+/OS8uHLLaDweDkMteumDwlpn2dDOVfBPRyYrpN wC5A1mGIlG+x+nsnkfygRZxBTLPaSMhCNlxxVHALXYsDUJR9AmLNR6TxqvSYryhHlo9M ChH5vmlzU6H6cHXC4e7QTtdCINR3wFbX5GLVd0LcC6QHSH7m+V70/GFFux4vigUY7vFn MDey5IXPOu7aHKXMNeovv0EWE9WPcwQt2zf/JgNJhjeAhLd2ewVEA4aEX3dpadQi/+lo vggk9L6RfV/BnYqlOt2DSFf6hhOsoV42P+OVygb/yG8XW5PkmD5hB+ftSUwVHFtAxz6A xwiA== X-Gm-Message-State: AAQBX9f0af9qK9eNMqA010sf9/AvvUulqo1YM/QWThF6X6a0ybiihIiI vCjd2FYULFIkoPD4cFh+c+rIIBl1jvWeCaXZOPJT X-Received: by 2002:a05:6902:102a:b0:b71:f49f:8d22 with SMTP id x10-20020a056902102a00b00b71f49f8d22mr8605060ybt.3.1680034806304; Tue, 28 Mar 2023 13:20:06 -0700 (PDT) MIME-Version: 1.0 References: <20230314081720.4158676-1-roberto.sassu@huaweicloud.com> <20230314081720.4158676-5-roberto.sassu@huaweicloud.com> <939e6c88662ad90b963993c4cc1b702083e74a7a.camel@huaweicloud.com> <8b63d00d8ac3f686e51889ea4fc8d83f8ecb300d.camel@huaweicloud.com> <1e08006f9011efa48deaf656c358ca3d438b9768.camel@huaweicloud.com> In-Reply-To: <1e08006f9011efa48deaf656c358ca3d438b9768.camel@huaweicloud.com> From: Paul Moore Date: Tue, 28 Mar 2023 16:19:55 -0400 Message-ID: Subject: Re: [PATCH v8 4/6] security: Allow all LSMs to provide xattrs for inode_init_security hook To: Roberto Sassu Cc: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com, ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, keescook@chromium.org, nicolas.bouchinet@clip-os.org, Roberto Sassu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Tue, Mar 28, 2023 at 3:47=E2=80=AFAM Roberto Sassu wrote: > > On Mon, 2023-03-27 at 17:02 -0400, Paul Moore wrote: > > On Mon, Mar 27, 2023 at 3:30=E2=80=AFAM Roberto Sassu > > wrote: > > > On Fri, 2023-03-24 at 17:39 -0400, Paul Moore wrote: > > > > On Fri, Mar 24, 2023 at 9:26=E2=80=AFAM Roberto Sassu > > > > wrote: > > > > > On Fri, 2023-03-24 at 11:18 +0100, Roberto Sassu wrote: > > > > > > On Thu, 2023-03-23 at 20:09 -0400, Paul Moore wrote: > > > > > > > On Tue, Mar 14, 2023 at 4:19=E2=80=AFAM Roberto Sassu > > > > > > > wrote: > > > > > > > > From: Roberto Sassu ... > > Okay, that's fair, but we could still pass the full xattrs array and a > > reference to the current count which could be both read and updated by > > the individual LSMs, right? > > Yes, we could do. > > > The issue is that the separate compaction stage is not something we > > want to have to do if we can avoid it. Maybe we're stuck with it, but > > I'm not yet convinced that we can't make some minor changes to the > > LSMs to avoid the compaction step. > > I liked more the idea that LSMs do what they are most familiar with, > get an offset in a security blob or, in this case, a starting slot in > the new_xattrs array, and write there. > > v3 had the lsm_find_xattr_slot() helper, to get the starting slot, but > somehow I find it less intuitive. > > Ok, if you prefer to avoid the compaction stage, I will rewrite this > patch. My concern is having to look through the xattr array after each LSM has been run and in at least one case having to then do a memcpy() to keep the array packed. There are some cases where there is no way to avoid all that extra work, but here I think we have the LSMs do the Right Thing with respect to packing the xattr array without overly burdening the individual LSMs. Does that make sense? It basically comes down to being smart about our abstractions and both selectively, and carefully, breaking them when there is a reasonable performance gain to be had. --=20 paul-moore.com