Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp771793ybh; Wed, 22 Jul 2020 12:49:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3svv0p3Jqzo99rHqGCCyAe8IpP4ZSy9gBUlsoEIPekXhcPNrinvACILqbOwJHw6TDcOsP X-Received: by 2002:a17:906:1e85:: with SMTP id e5mr1188143ejj.76.1595447377759; Wed, 22 Jul 2020 12:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595447377; cv=none; d=google.com; s=arc-20160816; b=t4nZ3ObsLldSuA0t2/gAZcxhRLYhEjoQ+zMPETs6wrTRvIqO7mGVVHqb55qai8khki PjZeW9atfUz0YLOHzYetXr8u1XfnrwC3oCaa2Ltm0PN+A/a5+k1ttczo5YglJD10aA0h 5Q0ij/7jIPDY+5e5hoBn6RG5b3Q/QSstaZG2YcQm4AaccQbgnfnYFl3mKonK8CvYJdS8 Ld3Wb61GIz/h/wQFnGx8UT4/I5xY5lx60WKwYuMtQ0Tu9qdXmPdNpiMOh+SxvH2lv/yD 0uPx/Ni9UknzU1jNlmEr2wLaNq0DPBsr1a7s5uQYQQdeBTNYCLJWckPm8AEeQLFip+ug 5/VA== 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=jJEeIskCU94/uy46H+vlxkYWS0tQWGpTRtC/J7YvjtU=; b=KaKmqd4hZ+4B+zJXueUWT8iHhFdUyXKpd+kS78yUzSh4YKr/Mu8N4outaZkN876X/e OwCdSup3EhOadOnbfQVP0oOUtU5sKPwsZagYG9+ANT0sFfqcOU549a714qerhyasBTBO GM5WgnMMKpkENfmsVIq6mRqA8VB31gntU1Gm29pmWr2fqFVLlBYroYgiR8xs+fWOJOhA gPsbBavNRoNllHsltvifIU7b1bZcT/NJRwr0J1Cv8V9dXXAyP3JZxtnDxLDwuzAAnsVd vSUmPAnvoHxYQyAtAopUQScpjQpx68tm7dK06wfPiJEjAdW6lUizptNmWXXyOvIueE0+ fzCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=uP27SHBa; 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 c9si588958ejx.552.2020.07.22.12.49.14; Wed, 22 Jul 2020 12:49:37 -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=uP27SHBa; 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 S1732493AbgGVTsk (ORCPT + 99 others); Wed, 22 Jul 2020 15:48:40 -0400 Received: from gateway24.websitewelcome.com ([192.185.51.202]:35903 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgGVTsj (ORCPT ); Wed, 22 Jul 2020 15:48:39 -0400 X-Greylist: delayed 1268 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Jul 2020 15:48:38 EDT Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 04C24418AF for ; Wed, 22 Jul 2020 14:25:46 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id yKLBjQFbCSxZVyKLBj2qw5; Wed, 22 Jul 2020 14:23:45 -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=jJEeIskCU94/uy46H+vlxkYWS0tQWGpTRtC/J7YvjtU=; b=uP27SHBaPuzgMSCx/+bPwwtbXw dtKmf6+REHWhATru6rkj220R5+2gwiX7INCBvTl8cRN99t9+g8gzZwMqidh0ZtKtEMKmQbfMZrkAB 4jdDIgQUHqN3fViUk99eHq/UJJKenBYsppy1iYCs/GdlP+bBuwVh94bs4M4JkYNOCmWwWQlIjYfYL 6IZJAZxu6lvfSdCA6bKJv049xzjp/CU6VauL1LPk+d5GLfm7OZMgr15O1SLYbvsT9FiREzyVp+FQp kA/bBzLmuChOfZDSg8VsD1uyhbGkrcXxLTAy01CGumGH6D2hIVVdO0hvz3+PAScu9lCpsYBzk8iAB tQu580jQ==; Received: from [201.162.161.216] (port=41852 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 1jyKLA-0014CO-OK; Wed, 22 Jul 2020 14:23:44 -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> From: "Gustavo A. R. Silva" Autocrypt: addr=gustavo@embeddedor.com; keydata= xsFNBFssHAwBEADIy3ZoPq3z5UpsUknd2v+IQud4TMJnJLTeXgTf4biSDSrXn73JQgsISBwG 2Pm4wnOyEgYUyJd5tRWcIbsURAgei918mck3tug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UEn+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: Date: Wed, 22 Jul 2020 14:29:26 -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: <3cac21c8798b48bdb412a5504126489f@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.216 X-Source-L: No X-Exim-ID: 1jyKLA-0014CO-OK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.43.132]) [201.162.161.216]:41852 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 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. > >>> 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. 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; >>> >>> /** >>>