Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1986848rwl; Thu, 30 Mar 2023 04:33:44 -0700 (PDT) X-Google-Smtp-Source: AK7set993QfSpzGc2ht7jiYi29wgeZ77arxfA9DKb+vEbwvOb+hDH2H3wtL1jOdZuMxLds2k/GK/ X-Received: by 2002:a05:6a20:5499:b0:db:7789:237e with SMTP id i25-20020a056a20549900b000db7789237emr26564816pzk.4.1680176024480; Thu, 30 Mar 2023 04:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680176024; cv=none; d=google.com; s=arc-20160816; b=Gr1Bq1plHPPI8WqYj/mCIvanx4JJE4VE+VVvihTtzsNas7D6tGVj4N6BjHckHyhx2c faNGi/Dh2Ap3x6B+M6fSrTkz0RDaEKTM1SdMf89ucl6BDJQmEyPXYrex6ET3HnOhyo1l QBFTtPZTx9CHDPgZDJmZI12BzJ6m9YU7oINz70aH3OzzPldX7c39mVRJT1d/PhuUDEyF c5Aj8Kw6i6/luKRDmSwJB/UgJaMUrxu55wTinD+8sftYo+0gzEBKVmlhxX+FL22RMW+H KgmrC0163BApiHP8DvuUZ6cpF3DbIoBH0mtP/ECmc2bk8sn5DTlnd7V3eeH/coCwzpvF AGYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:subject :user-agent:references:in-reply-to:message-id:date:cc:to:from :dkim-signature; bh=fdKipMhEB4vdHlMiUNkGlf7Pph62xlLHFGj7LA3sLc4=; b=DzxUbz7uUIoirIe1DmOnwZCpByBvPA5L0EWTOWUDwN6TU3ILXYei9kVLh4N8oO6Nt/ HTQiRHmYXEE55Yo9Pf8Q0AdqRM0EJNcHPQ62bO1IBuqn8lfHVPr/rjKY6lsu8AD8sg8+ b/e0gVsv/c1kRulMVKgP5fOhnC7sDuw7Z/S5PeggZvaOTB0cEDnnRyHS6edxppFCFk/W W8ihab+4cOaiJhlGD3wyywae9QIonVPsMzVHwBJVPdcBOjrZ3el67j18rPS36macpDoQ SqsLcgQfBj+JmKDvK6GllfmcUdpCHX7rQAQFSUhkGraQJKRtPyatTfMYqnmNmf769/kU 2Wtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=GhqPwpwm; 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 k69-20020a628448000000b0062a28cd7c1bsi8643694pfd.264.2023.03.30.04.33.31; Thu, 30 Mar 2023 04:33:44 -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=GhqPwpwm; 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 S231625AbjC3LYh (ORCPT + 99 others); Thu, 30 Mar 2023 07:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbjC3LYd (ORCPT ); Thu, 30 Mar 2023 07:24:33 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BFFDA265 for ; Thu, 30 Mar 2023 04:24:21 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id t13so13790704qvn.2 for ; Thu, 30 Mar 2023 04:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1680175461; h=content-transfer-encoding:mime-version:subject:user-agent :references:in-reply-to:message-id:date:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=fdKipMhEB4vdHlMiUNkGlf7Pph62xlLHFGj7LA3sLc4=; b=GhqPwpwm5+aLWZSGZL6KHY5T3Ky+2petggxGW82jJbcYqQ+weEcb2ErZbOnLTPrize CLPG2oWR5Nc5kmNfj4GpSPLJez/OcRkgPdBAicUHTzYD3kOqrDDYrPLD7JDj/HvaeYtK kicvzLF9Y3Bb2n4SQbyxFYlo5vV2K2otGONB/PPXBlJ/PqBVwM6pFOalEYNaVZ8N1DYj qYMxEa1HNTKRkgu75YjuRkDwSeBtllf0mbDI++YFOh2gBaoVTB1XW6KCYDsWm1QXTZBF CwkCfv3U6QJ2iEeTDMnyyLcZuFWnWJTp+4RM8S7g0hbJx8tik9HQK5AJ9F70Xbca6LMt Rqow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680175461; h=content-transfer-encoding:mime-version:subject:user-agent :references:in-reply-to:message-id:date:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fdKipMhEB4vdHlMiUNkGlf7Pph62xlLHFGj7LA3sLc4=; b=z2wSEGed5SmJ0jJ8obpzHD9MN8ts0h0tOgfyjSBmTeQHa9wdLgU6B5qvWueIOChP37 fsbrY1QeTxGh+Alzo3Q1vRvoFTdWVgX13tA1K2JrdPxpPwTS3of2bJA6rDw7p9/pVhoB 2Ohl062Fo4yo8sCNy1VrHQoeTxHRiiCtEmG8lrer6dG1DsVqXpscXaiP/qe/xRGKMOr0 vs+d0C7+o+qsgeS1+/cuvjMk/nX/88nJhjJ3RPjnEsK4jdIFURvSPxa0F87rkK/AHrtY sj2SaqPOziXvARqOATveQ/L30Pd5QXlbmwVvnC6Fzd0sXkFV6A1VSsWoy/X6o7apDE1Q uTow== X-Gm-Message-State: AAQBX9eW7wwLr7Ini2Y064dX0LnX/sgv1qMU8FxCsNQqaFarCnQzqO2Z mK0ZjRSpF0Ntu8arxDd+9bFX X-Received: by 2002:a05:6214:27e8:b0:5bc:7989:ea31 with SMTP id jt8-20020a05621427e800b005bc7989ea31mr33839189qvb.38.1680175460900; Thu, 30 Mar 2023 04:24:20 -0700 (PDT) Received: from [192.168.7.217] (pool-108-26-161-203.bstnma.fios.verizon.net. [108.26.161.203]) by smtp.gmail.com with ESMTPSA id z6-20020a0cfec6000000b005dd8b9345a0sm5385498qvs.56.2023.03.30.04.24.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Mar 2023 04:24:20 -0700 (PDT) From: Paul Moore To: Casey Schaufler CC: , , , , , , , , Date: Thu, 30 Mar 2023 07:24:19 -0400 Message-ID: <1873242bbd8.28e3.85c95baa4474aabc7814e68940a78392@paul-moore.com> In-Reply-To: References: <20230315224704.2672-1-casey@schaufler-ca.com> <20230315224704.2672-5-casey@schaufler-ca.com> User-Agent: AquaMail/1.43.0 (build: 104300275) Subject: Re: [PATCH v7 04/11] LSM: syscalls for current process attributes MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8" Content-Transfer-Encoding: 8bit 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 March 29, 2023 9:12:19 PM Paul Moore wrote: > On Wed, Mar 15, 2023 at 6:48 PM Casey Schaufler wrote: ... > >> +/** >> + * security_setselfattr - Set an LSM attribute on the current process. >> + * @attr: which attribute to set >> + * @ctx: the user-space source for the information >> + * @size: the size of the data >> + * @flags: reserved for future use, must be 0 >> + * >> + * Set an LSM attribute for the current process. The LSM, attribute >> + * and new value are included in @ctx. >> + * >> + * Returns 0 on success, an LSM specific value on failure. >> + */ >> +int security_setselfattr(unsigned int __user attr, struct lsm_ctx __user *ctx, >> + size_t __user size, u32 __user flags) >> +{ >> + struct security_hook_list *hp; >> + struct lsm_ctx lctx; > > Shouldn't we check @attr for valid values and return -EINVAL if bogus? > >> + if (flags != 0) >> + return -EINVAL; >> + if (size < sizeof(*ctx)) >> + return -EINVAL; > > If we're only going to support on 'lsm_ctx' entry in this function we > should verify that the 'len' and 'ctx_len' fields are sane. Although > more on this below ... > >> + if (copy_from_user(&lctx, ctx, sizeof(*ctx))) >> + return -EFAULT; >> + >> + hlist_for_each_entry(hp, &security_hook_heads.setselfattr, list) >> + if ((hp->lsmid->id) == lctx.id) >> + return hp->hook.setselfattr(attr, ctx, size, flags); > > Can anyone think of any good reason why we shouldn't support setting > multiple LSMs in one call, similar to what we do with > security_getselfattr()? It seems like it might be a nice thing to > have ... Scratch that, I just reminded myself why attempting to set an attribute on multiple LSMs in one operation would be a nightmare. Sorry about the confusion. -- paul-moore.com