Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3341606pxb; Fri, 4 Feb 2022 06:39:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxK6cwxtzzWaKNfGXkXv9mmn6x9Rzl0qoI53Wz2jIGKz5kgLOjfFRjjCnc6P9IaL75MDVNa X-Received: by 2002:a17:906:1e14:: with SMTP id g20mr2690216ejj.251.1643985545141; Fri, 04 Feb 2022 06:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643985545; cv=none; d=google.com; s=arc-20160816; b=aVGjcDN+gQcgwwFcU5lKETPqqgBD7/n8im7dsCCIiLNsc99Jn9Z/ETDZRc2DYOBRMX FLqLnfcxB7xBAsweTslnB0kJCEqGR8I3KCif9iUtT49ePtE71J1hf9diudbI/mLI41OV S1qxSV1D5rzVKVC1kKXiUDlTegve6rCkwI5qB7YprGNz6BX2f7VV3fq1H9OuyTE+YeGv iLudOrKbG0JEhLLPnJbfFa5wxzE8aywibE8uDlliUcfnsXizc555OTuIZGlhnXb1G/tQ 5Tw4YUjYkBrJlCCKOOKja0x1KlnPe/2fmf47EXy8ynH0RdgChlfjm3s+056Dza9G9hxI wc7Q== 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=nOy9ac3Osmpn7XAAKQrnuApPz2GZsHlbmH0fkdv1rps=; b=Fq/H5W5fitUBfK1ISRRPaX9xZEXypWQJYWqTw1+7sqj0uO1dm7Q8AYcshF1IggNzhg TaLf6tZDEJde4kG8UsuXQaUSPVWe3RN4jX+9d6OpHfcxHbmb9lKFKfAvwXRBvamQ+atU 2PfdKHKkxONT0SQ8z7fVnqikOOvX9Bwf8adfvSOUOzDXOXU73JPgTMuZRGyOsVrWw1eN 6ZsDnmNuq6AJQ32hn9s07DQMvUoETyRvUlqdn2AKMIEN220qyMYPDXV42dld8zONHt6y AIEiZTbKSl0gr118Ag/sUu5j7sjtEx87FW/RPG67HWBfYyhlVWiqJfejwVAfDJCMV553 x/vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hP4jTDKI; 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=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds6si1308783ejc.988.2022.02.04.06.38.38; Fri, 04 Feb 2022 06:39:05 -0800 (PST) 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=@ibm.com header.s=pp1 header.b=hP4jTDKI; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242832AbiBAUju (ORCPT + 99 others); Tue, 1 Feb 2022 15:39:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33772 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240631AbiBAUiT (ORCPT ); Tue, 1 Feb 2022 15:38:19 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 211Js69d031070; Tue, 1 Feb 2022 20:37:53 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=nOy9ac3Osmpn7XAAKQrnuApPz2GZsHlbmH0fkdv1rps=; b=hP4jTDKIIFxl9Zd5A0Pkig5DREL/JBeOHgxqIZx45MlamoO1wK7drMRjbZ3qzWjsD+i7 Wy0nU26rf1cr0FDAH88p3B4Sn/TH+l6qX+STORY5R6/uDrWAnlBQuPR3lr8q4fEfiLlx d6gDmw9gcUCOJC70/jPnAp5t/cyYm9YVibeFQXTpDYEif2URi6qHyJhDR3KoX45yyPkA dQ6KYOn/YLGcrpyTmYT6zpyWZT1An898zaYFe+jQJaukxmK+q+YT3FaHPwtHMF5/O+1l 2IENFg5TJTdZnvB/KFOzw0uGQeXxwLvqzuIc97AaSKX8lE1SuOViX+FKjvZpZLq9wOoO qQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dybe58pwa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:53 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 211JwurZ015248; Tue, 1 Feb 2022 20:37:52 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dybe58pw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:52 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 211KX06w023951; Tue, 1 Feb 2022 20:37:52 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 3dvw7ah5d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:52 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 211KbpJh25100574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Feb 2022 20:37:51 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08107B206C; Tue, 1 Feb 2022 20:37:51 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E96EEB206E; Tue, 1 Feb 2022 20:37:50 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 1 Feb 2022 20:37:50 +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 Subject: [PATCH v10 14/27] userns: Add pointer to ima_namespace to user_namespace Date: Tue, 1 Feb 2022 15:37:22 -0500 Message-Id: <20220201203735.164593-15-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220201203735.164593-1-stefanb@linux.ibm.com> References: <20220201203735.164593-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dmsAaTI8YXxKI527ueP2qRI5ZjU0y0Oc X-Proofpoint-ORIG-GUID: 9PgE0ykE0XLSK5UXvqfrwkspSnfy65qG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-01_09,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202010114 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. Signed-off-by: Stefan Berger --- 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 b6ab66a546ae..0cf2a80c8b35 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