Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp175063lqp; Thu, 4 Apr 2024 09:50:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSOdcxRp7Ejyx784kLXy6OvIauGWq2QG37KqerGswNibBzGCpi/QWDAYTJbyOt91gYUkEHZAgoGZcl57QE5exr1Rtr2WSggxHiFjnAKA== X-Google-Smtp-Source: AGHT+IEtfrGy5GfKsZQORaG2oQZMZMehwKX3594Qp7xBiub0YEr9j/4sT5xQxAu0iRlaBb/QODxy X-Received: by 2002:a17:906:4a10:b0:a51:8a58:237c with SMTP id w16-20020a1709064a1000b00a518a58237cmr192373eju.35.1712249433681; Thu, 04 Apr 2024 09:50:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712249433; cv=pass; d=google.com; s=arc-20160816; b=KffC57fNFxUp+oykjwGkQ07Af7+QconcnPWzqyDWCRAaS81FmZyrpBO9AHbo34hoUN gxwieznKsIP86YnblbLa2QhBOfrsLkKoWFS7ATGl8ENbp846+KBNbBCzxJ0jNgc4EJh7 /fB0BMnz1Yk889OJp9slMOH++cKQzK9MKO2UqVtcoN+2SalMQ4vfat9PNwtAoiP8RMNX 3m2veBR8j87T8LWOrfsfKRdp0OaZTry89aiEJ6+gabgKSuj0iWEpaq7IUn1ofcgXoIe+ Z0Uz+JCLv+ux2KMRnG8gwR0CqZJoRgAEcsGL9lWMdoHDSRWxzZZStxOUm7GsXzcn6kXV QUyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=bdVj70TgvvAB/XwbPfr6Rf7uON1edbSCq/OzQHOOv9s=; fh=oqJEg7lptnjYvIR3eLB04M3p4ckqkeUvLtIanlFc9Ow=; b=buyNnjJSIPu8HXTPnfB5Xj00sayejVSryHPU+/qISLWZIA7hQX8D80Vvz3xUDFkuOy TWdEyNn79QeDuMglTmQNp5LUiubI+HeNSrYTlvId3oOgBN1ZM9gFMHKojotYxKUSx3pQ gfQ50uf6Y33KbMzcDO0zb1LuW3S/dfsdKUFc88l5Eqm1OBKnSH0RCPiEBqEvgWBbdRxz mL5R1OM3anU7+1LY+E19s7yONld9+//wOJW7l2HsxN7X8Umu9ajekL8++L47W5Yp8nv9 MzP1c5u4kD0blDCHrsa14OwiAHblRCzYFSddG/4cIPPySHl7nKrZ91+cW91D+WVJQnkG GOmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=accTUUmn; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-131853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n6-20020a170906118600b00a474dc7185csi8029527eja.538.2024.04.04.09.50.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 09:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=accTUUmn; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-131853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6A0E71F273AA for ; Thu, 4 Apr 2024 16:50:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91F6F7640E; Thu, 4 Apr 2024 16:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="accTUUmn" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B6A814A8B; Thu, 4 Apr 2024 16:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249423; cv=none; b=bqZ0dhjM0hPEPczmpp307C0gFgYPRbtPe8CNcxQi2bsdWNPTyjTd4Z9lf4RHAxmAiFREEXsG3muQWVEGox7G5z7UJ4nzcNPPJGxEjGVqSDWjmfVxyd7wFFtj/U7S6yEva0O5SntmtJeL2OaGC/s+ge4a6FK5TiNnwhwd7f38pic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249423; c=relaxed/simple; bh=duuvXRyazU2+2lIzUlGDb5oo8et3T5/0CRetwEqiMgA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=iWMA8EKNc27r8cKnQkUHwXZJgWk4FInzWb6ClJoLhoPlAIZrvRWbUdWZEE9YPlHSxopRk4PNkxMvgz1bBcPIAQhdyjVFCbo9H1JCeZNdTioJJQPnNF7jAn8gBno98GfHjIiEHixh/Bbldx5Y/Et/TcdTDGLaAroJx0JSx3dYmEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=accTUUmn; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 434FuB8Z020276; Thu, 4 Apr 2024 16:49:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=bdVj70TgvvAB/XwbPfr6Rf7uON1edbSCq/OzQHOOv9s=; b=accTUUmntu4DgR7NUZDo4p+mCy7P0fKn7263a5qWZ8SBAIv+klBDYwQcrK6YwrnBYA9b NtRZPxDfteZjSuGXx3+KKpZlMUhtcW+LAz7XHD8sDMdXVMgPhseT6qY4RdOQwJ2ummun LU1JCWhUDk964VwwyuG21s/uioRtZE+qYUmYhHiZ9/BhbSTF58Jqrbf3Sp7DWYvA3l96 djkHlxBbsXQh08yM9bn3rm0IPyE79M8/A8PSq+AH9ILnQvgoaDrM9+KNLQDnMGaQhXht nj+YzrHFuSBv+hx+4P1IYMHIuQsKYoROWTWQ1CYLtAr6Pahah2tCLqAlffid4NVOO87Q vA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x9xuw86vv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 16:49:59 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 434GnwOS023179; Thu, 4 Apr 2024 16:49:58 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x9xuw86vs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 16:49:58 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 434GVMYq003608; Thu, 4 Apr 2024 16:49:57 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x9epydaqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 16:49:57 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 434Gnskc11469416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Apr 2024 16:49:57 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97D3E58056; Thu, 4 Apr 2024 16:49:54 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0394A5805A; Thu, 4 Apr 2024 16:49:54 +0000 (GMT) Received: from li-5cd3c5cc-21f9-11b2-a85c-a4381f30c2f3.ibm.com (unknown [9.61.110.28]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Apr 2024 16:49:53 +0000 (GMT) Message-ID: <27d36ec8e0539c5d6bc760de7305299a2142f9f1.camel@linux.ibm.com> Subject: Re: [PATCH v5][next] integrity: Avoid -Wflex-array-member-not-at-end warnings From: Mimi Zohar To: "Gustavo A. R. Silva" , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Date: Thu, 04 Apr 2024 12:49:53 -0400 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-23.el8_9) X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7G1mvBz-_JYfcWI_EuIHlwQhBX0aA1n1 X-Proofpoint-ORIG-GUID: rGa29e18cm8TrLTRwfsfd7u0yycR1-yR Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-04_13,2024-04-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxscore=0 adultscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404040117 Hi Gustavo, On Thu, 2024-04-04 at 09:00 -0600, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > There is currently an object (`hdr)` in `struct ima_max_digest_data` > that contains a flexible structure (`struct ima_digest_data`): > > struct ima_max_digest_data { > struct ima_digest_data hdr; > u8 digest[HASH_MAX_DIGESTSIZE]; > } __packed; > > So, in order to avoid ending up with a flexible-array member in the > middle of a struct, we use the `__struct_group()` helper to separate > the flexible array from the rest of the members in the flexible > structure: > > struct ima_digest_data { > __struct_group(ima_digest_data_hdr, hdr, __packed, > > ... the rest of the members > > ); > u8 digest[]; > } __packed; > > And similarly for `struct evm_ima_xattr_data`. > > With the change described above, we can now declare an object of the > type of the tagged `struct ima_digest_data_hdr`, without embedding the > flexible array in the middle of another struct: > > struct ima_max_digest_data { > struct ima_digest_data_hdr hdr; > u8 digest[HASH_MAX_DIGESTSIZE]; > } __packed; > > And similarly for `struct evm_digest` and `struct evm_xattr`. > > We also use `container_of()` whenever we need to retrieve a pointer to > the flexible structure. > > So, with these changes, fix the following warnings: > > security/integrity/evm/evm.h:64:32: warning: structure containing a flexible > array member is not at the end of another structure [-Wflex-array-member-not- > at-end] > security/integrity/evm/../integrity.h:40:35: warning: structure containing a > flexible array member is not at the end of another structure [-Wflex-array- > member-not-at-end] > security/integrity/evm/../integrity.h:68:32: warning: structure containing a > flexible array member is not at the end of another structure [-Wflex-array- > member-not-at-end] > security/integrity/ima/../integrity.h:40:35: warning: structure containing a > flexible array member is not at the end of another structure [-Wflex-array- > member-not-at-end] > security/integrity/ima/../integrity.h:68:32: warning: structure containing a > flexible array member is not at the end of another structure [-Wflex-array- > member-not-at-end] > security/integrity/integrity.h:40:35: warning: structure containing a flexible > array member is not at the end of another structure [-Wflex-array-member-not- > at-end] > security/integrity/integrity.h:68:32: warning: structure containing a flexible > array member is not at the end of another structure [-Wflex-array-member-not- > at-end] > security/integrity/platform_certs/../integrity.h:40:35: warning: structure > containing a flexible array member is not at the end of another structure [- > Wflex-array-member-not-at-end] > security/integrity/platform_certs/../integrity.h:68:32: warning: structure > containing a flexible array member is not at the end of another structure [- > Wflex-array-member-not-at-end] > > Link: https://github.com/KSPP/linux/issues/202 > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Mimi Zohar Thanks, Gustavo. I already applied and tested v4, but was trying to actually see the errors with before pushing it out. Mimi