Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp299791lqp; Thu, 4 Apr 2024 13:37:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEKFiEu11yVfiH2fHbA50FeHJW/iOVDJ4iVuTiaxpFmudFl49M/E+NGpMQE+kOkDyG4wGE9crQMQtIpf0y6kkeHPDktx4AQ9OVISts8g== X-Google-Smtp-Source: AGHT+IFXa/QOna3XKYGwBhMJbCsC2qnSKJSFq9S9KL9Gy/C6Dh8Q24XrlTXzOjh6XE/K3aGm3xbf X-Received: by 2002:a17:902:b788:b0:1e2:9c3b:df8d with SMTP id e8-20020a170902b78800b001e29c3bdf8dmr3322980pls.20.1712263052733; Thu, 04 Apr 2024 13:37:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712263052; cv=pass; d=google.com; s=arc-20160816; b=wKanDEwOme8Hsg4zhzd7nUYQe4qLQtF7DxttKx0qY11x6ostITT4iEuywq+v9OdKVT Yb+Q2n9k6Gkp1hy8XnZ3UHjbFy+teObYZygHDvGltOjiuH/P+zMTUnUyCRrP6sG7ORoL GhTH4n3s5wmsdXI60hbiwc5QbvtngEMbg3LUZOzOFd85eDTo6OVtOivBnWaACyQu+64P Ofan1lyLriLk2dMdclmipsBOo6Y6X9qoVBumAOGAhC79n02GF6iAK4dckUvXET/f9Q2r 4az5gg5RU01jV9vn7svBoZ10Ttg28hu+Esp8bHmxPI4n+eIDEAMhpKtu9yq8CpzxLzng 8B4Q== 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=Vq+lptyiRA9JJ5e/aNhf5SqSn6V7P4PE1G4+0cOGBO8=; fh=oqJEg7lptnjYvIR3eLB04M3p4ckqkeUvLtIanlFc9Ow=; b=IZfNDtmqAXe7CCH+dukSq5LItFChELs2PivYu1oV0ioM5JgGG/X0fB/r2ijKTJCUhh RNwgxwDUlWt3elYoEpObRU+QX2mZRCpua85blzP5icOLaLCO/jO8SCqyMfysewLEgMD5 XCiI8ioh3sRdkIc+/YagNiuKCOJcVzHyTdIBWMd3Fb4YvfnOa7qEJ46wESj/B5iwSJYz ijvyc/0tqoABA2oJAL5Dpop2frXx5jVZutvpox5U1ZlEIY/VMCXEPQol/FivyG4+BIKf 9lza8AYxgZpx3FsSkKAsKDO4ZqtbHqFprGiCliTdcLb9az5aq4v0R1NvCEM7Osvab/bu hf2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="q/N0Qg7e"; 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-132082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v12-20020a1709029a0c00b001e0892bb8d0si63496plp.222.2024.04.04.13.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 13:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="q/N0Qg7e"; 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-132082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132082-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CC9D6B2A9E3 for ; Thu, 4 Apr 2024 20:12:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 554651350EA; Thu, 4 Apr 2024 20:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="q/N0Qg7e" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 540FA1339BA; Thu, 4 Apr 2024 20:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712261548; cv=none; b=ttC0l64VBer80WWnltrHHnrom7P+KH6PN90XTcXoGfgYqIA8QHDmC3HuOsSFooQraLEwCvUUeI0Ur1b9dOifZiG9tMWvHY/7cdCW/3iYHyHoHPb+811HVgzhvovLKuJScEaqm73kdIfe0HO7fVidtB0mJ2DMwGkh2xicIN/VkCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712261548; c=relaxed/simple; bh=EVMGvafgBfGII3RlR8B+OnNiFJ1HBdwxUaoCS0beDwY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=jANx073DIKO08NdBjpp3qSAH3AVqO/tO6RmIoDX08tpzyf2B9iyuMZDxBQQSHv4+Wc86gaKO16guD2Q4/dtb6BeoDEIgEZdSsHhQq+NyAIR+hgg2AOCD9dZSS+habhNOKQgcKqjCHaZPBAwG+ncoB4WXECXuQpP7Mep7Sbs1zsI= 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=q/N0Qg7e; arc=none smtp.client-ip=148.163.158.5 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 (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 434K4Lif024701; Thu, 4 Apr 2024 20:12:00 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=Vq+lptyiRA9JJ5e/aNhf5SqSn6V7P4PE1G4+0cOGBO8=; b=q/N0Qg7eXYklXJJKy7OU7HMJI+I5t5nGr+wqlqvFENVTwHk6aLuKF/p02dFOCb1R2m5z v6CgCDNdVMraTxA3E2tViCfDi9EsvUqEUfKqdHjy35dgykdZJK+VIOoIgW1ocMRdrIST T4AufXqc+yx6SQT3R6eo2TvvYD656ngycn2PTmYpZ763Ph0JhRG8aKJgcLv5ZhOUots7 +g5DGSvIMMuo6fLdgSOylNbU+qAXkRLtIe2s3tFAb76j/9Ci6pl4CW63hT+cF4Ddlejm flFQqvbfZd9GVz1Y1KkH5rMWrmZHq45z92A+fDnholzzgwBEeV8MiBAJ7OtZqaE87czX kg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xa2w900kb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 20:12:00 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 434KBxQS003418; Thu, 4 Apr 2024 20:11:59 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xa2w900k6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 20:11:59 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 434JLP0d007723; Thu, 4 Apr 2024 20:11:59 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x9epwpcx0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 20:11:59 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 434KBu806750888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Apr 2024 20:11:58 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43B6358055; Thu, 4 Apr 2024 20:11:56 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 334045804B; Thu, 4 Apr 2024 20:11:55 +0000 (GMT) Received: from li-5cd3c5cc-21f9-11b2-a85c-a4381f30c2f3.ibm.com (unknown [9.61.110.28]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Apr 2024 20:11:55 +0000 (GMT) Message-ID: 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 16:11:54 -0400 In-Reply-To: <27d36ec8e0539c5d6bc760de7305299a2142f9f1.camel@linux.ibm.com> References: <27d36ec8e0539c5d6bc760de7305299a2142f9f1.camel@linux.ibm.com> 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-ORIG-GUID: cKQ50c5FNWZMYVHwbzG33Sdc9xNugIbj X-Proofpoint-GUID: 6QGzaMYvKNPwzhV7Q8RfDJC5OcsCCgGz 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_16,2024-04-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404040144 On Thu, 2024-04-04 at 12:49 -0400, Mimi Zohar wrote: > 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. With GCC-14, I'm seeing the "warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]" messages. As expected, with the patch no warnings. "checkpatch.pl --strict" complains "CHECK: Alignment should match open parenthesis". I'll queue the patch, but how about teaching checkpatch.pl to ignore __struct_group()? thanks, Mimi