Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp253622pxm; Wed, 2 Mar 2022 14:40:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWMTOxMmn8ckNqQICBxG8aAMRcNlbWe5OaVZTJG+izTeKDP5iiG7l6+F0/XI0gzpSyqYLd X-Received: by 2002:a63:e52:0:b0:374:7b9f:1467 with SMTP id 18-20020a630e52000000b003747b9f1467mr27172523pgo.178.1646260813087; Wed, 02 Mar 2022 14:40:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646260813; cv=none; d=google.com; s=arc-20160816; b=A6KmaReD2VC2L6kznhYjPqm6IoYirBRyrQtlHuho/Kb0FtxGoqtcJ1nPTYQHj/7usl fHTKc3hWSZ6XWKgCQ7ST4Dc5DbdwuTveM0ubQw/2PQysNulZ4YTSAqS4IjhV1J2ixd9e fpNba5PejiHXThJ7ixnHKTbozLg72dbTj2Tb/YlbAQZSTunuEU/eFCKi4NRx1dPu5l/k JeJw2D0Wac6j+9MCiCHDRvYgk3Qh260LgqD7vMpCoxnvYC8osxKoE6er2hAprXw5V9yn 5l0hdNiJwYtg5kxF43q59N30hFepA5yJecmoaOYpm+oq+HKKdR/AtdeVqEwpCmYS2Wdz PRQQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eA5Ji1No6cnOGtdPIg0uegaQUM+NJpPm0UWrC6nUiGw=; b=b+0Q5b1gJwc3/PBlRMDgPtS3K1esSxsTt69b1fv5i4bVTWF/nJO3CXTPjb4w4Q0d5+ tG9snLsLYaM49niXlHm5jKW2+G2/KRgtnmr8jAev59NK5VMkYE57lPpq1GfhomOXseZy fssIa1XaqL/fp0XTTzzjtVPc+PoP3K2uvgKZeoYvjq1QKvPWvYBYHug0lFr+0ppbId7o scBwnh2cqbqOC/ztVzh0EcMwQd8nWqNOMBbn8Abf2pU9h1VJP5wlKKjq1jX2dkW1KNcu SsK2kcHig6VRItnYkQ5lVBhVc4YReqyl0SSRdqsXCOjqLT2h+OOWdvfq46lbvBc/zcBJ j4JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=R2aHla9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c77-20020a624e50000000b004e10286cdb4si336990pfb.245.2022.03.02.14.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:40:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=R2aHla9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9464CFDFB0; Wed, 2 Mar 2022 14:35:59 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242678AbiCBNxA (ORCPT + 99 others); Wed, 2 Mar 2022 08:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242447AbiCBNvs (ORCPT ); Wed, 2 Mar 2022 08:51:48 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222C0C625C; Wed, 2 Mar 2022 05:50:48 -0800 (PST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 222DmSvg013154; Wed, 2 Mar 2022 13:50:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=eA5Ji1No6cnOGtdPIg0uegaQUM+NJpPm0UWrC6nUiGw=; b=R2aHla9IDulC+PX2WI+VPabRcdUqsS3pgZX2+J6wG5V2d8th5cPE1Rr0s8n+60ReGOni JTMQSbTl5s9FlLjPGSeHVe2F0P+E62rDk48844kpCnSGtU1TNrvWzMsdTPe9+hlazYYk 70fphj0cKW/pDu5ez5SM6K39Ljdw/d6ZkKlpPFVuyjJSguWK0rTjckGl9eQ4WegSxRhs +VhxIJEwPeaHLjgRe62a9CE4GoDRncXFfD71hbOV7/RDv7BKU7przpTEvT61nhv3eOwN nDxj2pnbFqYc5bT3pv/8cZeXH29Ls4BecCCRvhBdGue7Q4FWhExNJdqSJFPT9B8oYbWg CA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ej9st80pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 13:50:03 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 222Dng9J018709; Wed, 2 Mar 2022 13:50:02 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ej9st80pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 13:50:02 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 222DmTHh005317; Wed, 2 Mar 2022 13:50:01 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma01dal.us.ibm.com with ESMTP id 3efbuany3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 13:50:01 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 222Dnxac23331176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Mar 2022 13:49:59 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED6F611206B; Wed, 2 Mar 2022 13:49:58 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD298112070; Wed, 2 Mar 2022 13:49:58 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 2 Mar 2022 13:49:58 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, serge@hallyn.com, christian.brauner@ubuntu.com, containers@lists.linux.dev, dmitry.kasatkin@gmail.com, ebiederm@xmission.com, krzysztof.struczynski@huawei.com, roberto.sassu@huawei.com, mpeters@redhat.com, lhinds@redhat.com, lsturman@redhat.com, puiterwi@redhat.com, jejb@linux.ibm.com, jamjoom@us.ibm.com, linux-kernel@vger.kernel.org, paul@paul-moore.com, rgb@redhat.com, linux-security-module@vger.kernel.org, jmorris@namei.org, Stefan Berger , Christian Brauner Subject: [PATCH v11 14/27] userns: Add pointer to ima_namespace to user_namespace Date: Wed, 2 Mar 2022 08:46:49 -0500 Message-Id: <20220302134703.1273041-15-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302134703.1273041-1-stefanb@linux.ibm.com> References: <20220302134703.1273041-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5FCZasAyLPHQf385eM0whGEDd9_XNKWF X-Proofpoint-ORIG-GUID: 63jIEdGTtfNFIzymL6CxvAEHPDJgJNxk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-02_06,2022-02-26_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2203020057 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Add a pointer to ima_namespace to the user_namespace and initialize the init_user_ns with a pointer to init_ima_ns. We need a pointer from the user namespace to its associated IMA namespace since IMA namespaces are piggybacking on user namespaces. Signed-off-by: Stefan Berger Acked-by: Christian Brauner Reviewed-by: Mimi Zohar --- v11: - Added lost A-b from Christian back - Added sentence to patch description explaining why we need the pointer v9: - Deferred implementation of ima_ns_from_user_ns() to later patch --- include/linux/ima.h | 2 ++ include/linux/user_namespace.h | 4 ++++ kernel/user.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/linux/ima.h b/include/linux/ima.h index 426b1744215e..fcb60a44e05f 100644 --- a/include/linux/ima.h +++ b/include/linux/ima.h @@ -14,6 +14,8 @@ #include struct linux_binprm; +extern struct ima_namespace init_ima_ns; + #ifdef CONFIG_IMA extern enum hash_algo ima_get_current_hash_algo(void); extern int ima_bprm_check(struct linux_binprm *bprm); diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 33a4240e6a6f..019e8cf7b633 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -36,6 +36,7 @@ struct uid_gid_map { /* 64 bytes -- 1 cache line */ #define USERNS_INIT_FLAGS USERNS_SETGROUPS_ALLOWED struct ucounts; +struct ima_namespace; enum ucount_type { UCOUNT_USER_NAMESPACES, @@ -99,6 +100,9 @@ struct user_namespace { #endif struct ucounts *ucounts; long ucount_max[UCOUNT_COUNTS]; +#ifdef CONFIG_IMA_NS + struct ima_namespace *ima_ns; +#endif } __randomize_layout; struct ucounts { diff --git a/kernel/user.c b/kernel/user.c index e2cf8c22b539..e5d1f4b9b8ba 100644 --- a/kernel/user.c +++ b/kernel/user.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * userns count is 1 for root user, 1 for init_uts_ns, @@ -67,6 +68,9 @@ struct user_namespace init_user_ns = { .keyring_name_list = LIST_HEAD_INIT(init_user_ns.keyring_name_list), .keyring_sem = __RWSEM_INITIALIZER(init_user_ns.keyring_sem), #endif +#ifdef CONFIG_IMA_NS + .ima_ns = &init_ima_ns, +#endif }; EXPORT_SYMBOL_GPL(init_user_ns); -- 2.31.1