Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22644676rwd; Fri, 30 Jun 2023 10:33:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ779we/ga0hf3WtvDPd6MJXEh/2FoctsU4jl8aU4ggHtv4mZ+Fa0Kr0jp/sFaHq8urehB+Y X-Received: by 2002:a05:6870:7e13:b0:1b0:657f:5047 with SMTP id wx19-20020a0568707e1300b001b0657f5047mr4439822oab.46.1688146410735; Fri, 30 Jun 2023 10:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688146410; cv=none; d=google.com; s=arc-20160816; b=X/mvaPzJNG3xbZQwAxVeahmBBmvG0TdjEqVSl4s6PXKf3P3ClRYXQ9ET36GwPceiSH Hw4KmmpGWYGRtcrBhTv6HOO3RKhMcTNi4jjleIbsKs1htYPFZ6fHZq0TdDR6ZVBgttXx W24tvX3aAlkHZK9V9jvvl7q5ENLRpbzImDPpxcHY4h4ORfpVZxG5WmQNCpwi4CdcymHI ynKcdSiF836Lizie0epRS7ZViGrDfFhF7+77QsrDlC+8kz+H9/mL4HhYuRd2C1ncZRsa owuaXkq4mqnSLZhBYrJM/DZ9g+1nv65ubC/Iu6JHh3jpNFzhBawmj4BPCb4nRr8fJl8W wvoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=mEHt/JqObB3Frlc2IUEbCB2n7vlId/lkmWICPwY56hs=; fh=QOmpGW68ZHtErRflxb1fjvwC9wRiq9FCfrGTSlPpW18=; b=mN1M63okkgx6k2PLgI8+msmUGYv0MvM7JayOyjyMN0VchKtB9VhstGOFzFqL6m6xSW yf+nHQuWIPGxxP6lr2QUCgZN9CHGCozvksIDoqWKqJcVqDQMsd3EAvoklyl01txFEop9 n12Fh9UDWdu0uZdOTz6WUuTsaxr8iEfrJYhxHs0anputAChN8zkv/BeoyMgXgefaJnaU A+N6GK5XB8Uvup4DZaZ5FrwR2b9eAPZQEUaUHDGKhFEMDjnrPTC8xSlMNvPf7uwB6NVm 06mqnyRSpBJRx7yQ9kqhXVmt4vWS4rvohI+UhpkvMd7WJw9u+PfzwDZqmwUN/YuVeABZ vSpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=oZBZ564G; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a631f15000000b0054ff40830b5si12925458pgf.384.2023.06.30.10.33.16; Fri, 30 Jun 2023 10:33:30 -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=@yahoo.com header.s=s2048 header.b=oZBZ564G; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232708AbjF3RLw (ORCPT + 99 others); Fri, 30 Jun 2023 13:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232768AbjF3RLu (ORCPT ); Fri, 30 Jun 2023 13:11:50 -0400 Received: from sonic311-30.consmr.mail.ne1.yahoo.com (sonic311-30.consmr.mail.ne1.yahoo.com [66.163.188.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C567125 for ; Fri, 30 Jun 2023 10:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1688145107; bh=mEHt/JqObB3Frlc2IUEbCB2n7vlId/lkmWICPwY56hs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=oZBZ564GVvuSUmwlk6ao74tWl7pVLggMNr0TmAV2gTR0zLegBQzKYeJhlfBJPWPuoEGNRiXtlUcBURC2FTjwvavx1WXEK6gItCsa5u8btd0iZ9z4ghsYiyHZVGIHjtaKsSTITCa2qAX8paaxIZvGzmaVgqnZtnDofhGtELOcmqsg0Bqyepa7zuowb8i+efD3u29T1Pz5OenVq+OYzZHn2n8n2mXbHJhKG5a1qURiyqzDP2M/uFK55QpJt0uzUeZ75ZgU/5SSDYXGtZ6P+l0eDe61uwlRqVpOvZRBV+gOyjirKPnWL5HurkLoTJ84VuEQsyEhzyEcCO3rih8wTGSVpg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1688145107; bh=TymhNMgO4qRUs1tebafYC31Zr0VhYFIM5/yJO3p5Ptp=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=Auqcxm5V1vDuihNba6pga71GyRk/Z3r44OTzxXbVL80bWurf6lE5xPWsmgObfN0Z5VssUNSCmOZ7T7O8pnmLo4SOvH/SjHFKG8DZS6lxB1aV7RuEY4gcIaNHXJgUwlT6vcDjnLQrNF+ixxEkU8ObEk9Dhx+wGmufYt89vtKYCPflbqrkVDiUwgn+euC8yuqQS+YG1ldggkCdPTJMtc9MHDHnuNOKdv9k7t03AOXgAmSJIon+myQKJgmR+QLCrPfnYoh9V3XlK2rSKhX4U7WUd7j2Lbi9reVkAsqW+pNpwx77AxvqBF/i1nlNdHL1rziwlbexzSIDOkaJRX10nwuajg== X-YMail-OSG: hPDmIoQVM1mCBJsn4UlQZw5zqgdKKYKhq9LSGVKKPSEjypUlclKITUtzUHnntgT 3c8NIIm7A.fgTBnPPudNfmHWdT1uPzVxREiY1NXSRcOMGK9CyjUYv5PLsdtKd7Jg0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Dr6Z9SrKMPFU52m5VNbPF37fqQXVhi.QP.ttSXvUasOnAjMomTzL2Y7BWTPaQXBTOB 65maGYg79mTQRcDw- X-Sonic-MF: X-Sonic-ID: 92000793-78ab-4a46-aceb-c6ee4f47f6b4 Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Fri, 30 Jun 2023 17:11:47 +0000 Received: by hermes--production-bf1-5d96b4b9f-lngg9 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1ac61ddcb6798a32091163362680cf0e; Fri, 30 Jun 2023 17:11:45 +0000 (UTC) Message-ID: Date: Fri, 30 Jun 2023 10:11:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v12 7/11] LSM: Helpers for attribute names and filling lsm_ctx Content-Language: en-US To: Paul Moore , linux-security-module@vger.kernel.org Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, mic@digikod.net, Casey Schaufler References: <20230629195535.2590-8-casey@schaufler-ca.com> From: Casey Schaufler In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.21612 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 6/29/2023 7:14 PM, Paul Moore wrote: > On Jun 29, 2023 Casey Schaufler wrote: >> Add lsm_name_to_attr(), which translates a text string to a >> LSM_ATTR value if one is available. >> >> Add lsm_fill_user_ctx(), which fills a struct lsm_ctx, including >> the trailing attribute value. >> >> All are used in module specific components of LSM system calls. >> >> Signed-off-by: Casey Schaufler >> Reviewed-by: Serge Hallyn >> --- >> include/linux/security.h | 14 +++++++++++++ >> security/lsm_syscalls.c | 24 ++++++++++++++++++++++ >> security/security.c | 44 ++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 82 insertions(+) > .. > >> diff --git a/security/security.c b/security/security.c >> index 199db23581f1..72ad7197b2c9 100644 >> --- a/security/security.c >> +++ b/security/security.c >> @@ -770,6 +770,50 @@ static int lsm_superblock_alloc(struct super_block *sb) >> return 0; >> } >> >> +/** >> + * lsm_fill_user_ctx - Fill a user space lsm_ctx structure >> + * @ctx: an LSM context to be filled >> + * @context: the new context value >> + * @context_size: the size of the new context value >> + * @id: LSM id >> + * @flags: LSM defined flags >> + * >> + * Fill all of the fields in a user space lsm_ctx structure. >> + * Caller is assumed to have verified that @ctx has enough space >> + * for @context. >> + * >> + * The total length is padded to a multiple of 64 bits to >> + * accomodate possible alignment issues. > We should drop the sentence above now that alignment is the caller's > responsibility, but since that was largely my fault I can fix this up > during the merge assuming you're okay with that Casey. I have to fix the error in patch 8/11 anyway. I can fix this, too. > >> + * Returns 0 on success, -EFAULT on a copyout error, -ENOMEM >> + * if memory can't be allocated. >> + */ >> +int lsm_fill_user_ctx(struct lsm_ctx __user *ctx, void *context, >> + size_t context_size, u64 id, u64 flags) >> +{ >> + struct lsm_ctx *lctx; >> + size_t locallen = struct_size(lctx, ctx, context_size); >> + int rc = 0; >> + >> + lctx = kzalloc(locallen, GFP_KERNEL); >> + if (lctx == NULL) >> + return -ENOMEM; >> + >> + lctx->id = id; >> + lctx->flags = flags; >> + lctx->ctx_len = context_size; >> + lctx->len = locallen; >> + >> + memcpy(lctx->ctx, context, context_size); >> + >> + if (copy_to_user(ctx, lctx, locallen)) >> + rc = -EFAULT; >> + >> + kfree(lctx); >> + >> + return rc; >> +} >> + >> /* >> * The default value of the LSM hook is defined in linux/lsm_hook_defs.h and >> * can be accessed with: >> -- >> 2.40.1 > -- > paul-moore.com