Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp890856ybh; Wed, 22 Jul 2020 16:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPu8+w+XAR8UPzM82T7g5Dz3F+MqV0cQGK0lp+JXIn0yusBxYPLiE98QcHrMEulSAj5PUQ X-Received: by 2002:a17:906:a892:: with SMTP id ha18mr1850153ejb.462.1595460186189; Wed, 22 Jul 2020 16:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595460186; cv=none; d=google.com; s=arc-20160816; b=bHqL4xzcvvUJcodzgyeFjCqWqvrVxFybGlAdfPby3bDKPzefZWqpLltO7ZdqHBytgi Zj/NgJDwyCc71ZWr7PZeGOJL5//nHpl3yj4/GCTsBiya3PZVHOUIYydsQUJJVzSTq9zO ZRc6yoXf8ZB+E4PmmuTMHBeaOn+3FBoheXlsX6MB+7KjoVNEyJkO36SxAcPj91E54QSQ iearutLIp3CN2R+WTraPpTMeBDcZ7i40zWtH8Q/WhWsq58T1GUyfCHFyMsSRHqfSvrDw DCxEiKv/BuX9b716+I0jVY4FCX1EpInEWXNWnGkBaKyUkaGWeBPkhALeOGAfhnBzgxgZ Ipxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:from:references:cc:to:dkim-signature; bh=eIzKJF8jNji+BynBmA3f+h/SU/2RQ4nZCvi7qumLhJQ=; b=R8rf/RLXS8td6pSJhGb4Kj3VGqyfb2bMvtfMyW3z2xR78IPYz8UEmzx8HxAG4vMTys 8kjWaviV3Mh12CB5y/x9O/uCgKchIV63wIpN8D+4tA8EucORaFFXyrZ2FgzGVun4tn11 GH4R5nfrTtiK6eb/uFKnlGoI4H7cBMRpeHZFNy7zNO/xBR07J04F60F718uVRU7Yt4+4 kcuh029vPhcUSTagviOgPN56b20b0c5Q1bwr3JVYigYA41eqlWytEqQoaknFYBEGmNLT 4QNX3z3m6yPavP9+GJDMW87J+02Al0JSqYhcqVsDcRU3SDjz5095seprVQfyVCZn8O9t dA3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=bDvwaPrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si892608edl.596.2020.07.22.16.22.43; Wed, 22 Jul 2020 16:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=bDvwaPrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733136AbgGVXUg (ORCPT + 99 others); Wed, 22 Jul 2020 19:20:36 -0400 Received: from gateway31.websitewelcome.com ([192.185.144.80]:21102 "EHLO gateway31.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733125AbgGVXUf (ORCPT ); Wed, 22 Jul 2020 19:20:35 -0400 X-Greylist: delayed 1457 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Jul 2020 19:20:33 EDT Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 021E713C460 for ; Wed, 22 Jul 2020 17:56:14 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id yNenjKktCzOauyNenj8cyo; Wed, 22 Jul 2020 17:56:13 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:Subject:From:References:Cc:To:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eIzKJF8jNji+BynBmA3f+h/SU/2RQ4nZCvi7qumLhJQ=; b=bDvwaPrQvUsed6SrcORIS7JSCq DQ84Mvaxim5ENYjs5h/qH1F7kLISvdrCvMUu/eQA+lCkPpJTj45/5jRCb51nlP4Ti+uLVI34tD7Fz NrsMV8l3upYsKq4f+CtMmrMqyldRGbsZjdgBgjfv3KThJ3owYodnLsbQ30i5VqfLZQDl4nfc2k0Sf hh9g+WNdZuEBoHTgTGCpShsTZ9yxXeiINhBsvm39eljzNMOvQDYC7TDyHQJo0QfdmWk5h6/xSeabc sUfhaHzPr4CZHua77HXQRb1DCB4W/DeMel6EMtx5S4FLDsPEhudvl1o5VPIRLnSDP+mpYtbV0sUFV Tz5ib43Q==; Received: from [201.162.161.222] (port=56764 helo=[192.168.43.132]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jyNem-002nvm-JK; Wed, 22 Jul 2020 17:56:13 -0500 To: "Winkler, Tomas" , "Gustavo A. R. Silva" , Arnd Bergmann , Greg Kroah-Hartman Cc: "linux-kernel@vger.kernel.org" , Kees Cook References: <20200714214516.GA1040@embeddedor> <5198b29f-2e62-4910-4a4d-52c7991915c5@embeddedor.com> <3cac21c8798b48bdb412a5504126489f@intel.com> <071940a8c76c4652b4fd58195719c471@intel.com> From: "Gustavo A. R. Silva" Autocrypt: addr=gustavo@embeddedor.com; keydata= xsFNBFssHAwBEADIy3ZoPq3z5UpsUknd2v+IQud4TMJnJLTeXgTf4biSDSrXn73JQgsISBwG 2Pm4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MHMb+In rHPP16aVDTBTPEGwgxXI38f7SUEn+NpbizWdLNz2hc907DvoPm6HEGCanpcAEQEAAcLBZQQY AQgADwUCWywcDAIbDAUJCWYBgAAKCRBHBbTLRwbbMdsZEACUjmsJx2CAY+QSUMebQRFjKavw XB/xE7fTt2ahuhHT8qQ/lWuRQedg4baInw9nhoPE+VenOzhGeGlsJ0Ys52sdXvUjUocKgUQq 6ekOHbcw919nO5L9J2ejMf/VC/quN3r3xijgRtmuuwZjmmi8ct24TpGeoBK4WrZGh/1hAYw4 ieARvKvgjXRstcEqM5thUNkOOIheud/VpY+48QcccPKbngy//zNJWKbRbeVnimua0OpqRXhC rEVm/xomeOvl1WK1BVO7z8DjSdEBGzbV76sPDJb/fw+y+VWrkEiddD/9CSfgfBNOb1p1jVnT 2mFgGneIWbU0zdDGhleI9UoQTr0e0b/7TU+Jo6TqwosP9nbk5hXw6uR5k5PF8ieyHVq3qatJ 9K1jPkBr8YWtI5uNwJJjTKIA1jHlj8McROroxMdI6qZ/wZ1ImuylpJuJwCDCORYf5kW61fcr HEDlIvGc371OOvw6ejF8ksX5+L2zwh43l/pKkSVGFpxtMV6d6J3eqwTafL86YJWH93PN+ZUh 6i6Rd2U/i8jH5WvzR57UeWxE4P8bQc0hNGrUsHQH6bpHV2lbuhDdqo+cM9ehGZEO3+gCDFmK rjspZjkJbB5Gadzvts5fcWGOXEvuT8uQSvl+vEL0g6vczsyPBtqoBLa9SNrSVtSixD1uOgyt AP7RWS474w== Subject: Re: [PATCH v2] mei: Avoid the use of one-element arrays Message-ID: <6e50fb93-8130-766f-8688-2a07a1744701@embeddedor.com> Date: Wed, 22 Jul 2020 18:01:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <071940a8c76c4652b4fd58195719c471@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 201.162.161.222 X-Source-L: No X-Exim-ID: 1jyNem-002nvm-JK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.43.132]) [201.162.161.222]:56764 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 5 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/22/20 17:40, Winkler, Tomas wrote: >> >> Hi Tomas, >> >> Please, see my comments below... >> >> On 7/22/20 14:04, Winkler, Tomas wrote: >>> >>>> >>>> Hi all, >>>> >>>> Friendly ping: who can take this? :) >>>> >>>> Thanks >>>> -- >>>> Gustavo >>>> >>>> On 7/14/20 16:45, Gustavo A. R. Silva wrote: >>>>> One-element arrays are being deprecated[1]. Replace the one-element >>>>> arrays with a simple value type u8 reserved, once this is just a >>>>> placeholder for alignment. >>>>> >>>>> Also, while there, use the preferred form for passing a size of a struct. >>>>> The alternative form where struct name is spelled out hurts >>>>> readability and introduces an opportunity for a bug when the >>>>> variable type is changed but the corresponding sizeof that is passed >>>>> as argument is >>>> not. >>>>> >>>>> [1] https://github.com/KSPP/linux/issues/79 >>>>> >>>>> Signed-off-by: Gustavo A. R. Silva >>>>> --- >>>>> Changes in v2: >>>>> - Use a more concise changelog text. >>>>> >>>>> drivers/misc/mei/hbm.c | 4 ++-- >>>>> drivers/misc/mei/hw.h | 6 +++--- >>>>> 2 files changed, 5 insertions(+), 5 deletions(-) >>>>> >>>>> diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index >>>>> a44094cdbc36..f020d5594154 100644 >>>>> --- a/drivers/misc/mei/hbm.c >>>>> +++ b/drivers/misc/mei/hbm.c >>>>> @@ -408,14 +408,14 @@ static int mei_hbm_add_cl_resp(struct >>>>> mei_device *dev, u8 addr, u8 status) { >>>>> struct mei_msg_hdr mei_hdr; >>>>> struct hbm_add_client_response resp; >>>>> - const size_t len = sizeof(struct hbm_add_client_response); >>>>> + const size_t len = sizeof(resp); >>>>> int ret; >>>>> >>>>> dev_dbg(dev->dev, "adding client response\n"); >>>>> >>>>> mei_hbm_hdr(&mei_hdr, len); >>>>> >>>>> - memset(&resp, 0, sizeof(struct hbm_add_client_response)); >>>>> + memset(&resp, 0, len); >>>>> resp.hbm_cmd = MEI_HBM_ADD_CLIENT_RES_CMD; >>>>> resp.me_addr = addr; >>>>> resp.status = status; >>> >>> This should be probably in a different patch it's not related to the second >> part. > > > Frankly I will post other version of this that cleans the whole file. > Sounds good. :) >>> >>>>> diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h index >>>>> b1a8d5ec88b3..8c0297f0e7f3 100644 >>>>> --- a/drivers/misc/mei/hw.h >>>>> +++ b/drivers/misc/mei/hw.h >>> I have second thoughts of this part as all reserved fields in this >>> file are of form u8 reserved[X], so we will lose that uniformity with >>> this change, you have to look at the file as whole not just at the patch. So I >> prefer we drop that part of the patch. >>> >> >> This is actually the main point of this patch: the removal of one-element >> arrays. >> And yeah, every place in the kernel that uses the form that you mention will >> see it's uniformity slightly modified, and that's for a good cause: the removal >> of one-element arrays, so we can enable bounds checking. > > I was going over https://github.com/KSPP/linux/issues/79, I'm not sure this all related to flexible arrays, I've opened a new issue for this: https://github.com/KSPP/linux/issues/86 And I'm already including the link above in these sorts of patches; please, see: https://lore.kernel.org/lkml/20200717215500.GA13910@embeddedor/ > those are just reserved struct members. So because it's hard to identify a legitimate usage of single element arrays > we are going to kill them all? It's more esthetic / readability issue here but there might be some legit use case for one element array, no? > The code is continuously evolving and, if a one-element array is not intended to be used as a variable-length array at all, I frankly cannot think of any another use that is not merely esthetic/readability. :) Thanks -- Gustavo > >> >> Thanks >> -- >> Gustavo >> >>>>> @@ -346,13 +346,13 @@ struct hbm_add_client_request { >>>>> * @hbm_cmd: bus message command header >>>>> * @me_addr: address of the client in ME >>>>> * @status: if HBMS_SUCCESS then the client can now accept >> connections. >>>>> - * @reserved: reserved >>>>> + * @reserved: reserved for alignment. >>>>> */ >>>>> struct hbm_add_client_response { >>>>> u8 hbm_cmd; >>>>> u8 me_addr; >>>>> u8 status; >>>>> - u8 reserved[1]; >>>>> + u8 reserved; >>>>> } __packed; >>>>> >>>>> /** >>>>> @@ -461,7 +461,7 @@ struct hbm_notification { >>>>> u8 hbm_cmd; >>>>> u8 me_addr; >>>>> u8 host_addr; >>>>> - u8 reserved[1]; >>>>> + u8 reserved; >>>>> } __packed; >>>>> >>>>> /** >>>>>