Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1059413pxb; Thu, 15 Apr 2021 12:58:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvoC7zbGmOT1oqUSbpuee25aOeQDrZBzJS2dw67zqwi5SwfDnENp04hPj6PboAFEpVDjtg X-Received: by 2002:a17:907:76c5:: with SMTP id kf5mr5026940ejc.526.1618516724898; Thu, 15 Apr 2021 12:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618516724; cv=none; d=google.com; s=arc-20160816; b=aVetohds76FW9gUY/DQ6sBdoU+O8vzrpW2yKdky0lgoA6FzCrjfi6emOGbRm1zYnAX W7Ba1bGR+FoVfFVxteT+ctHi1mb9RYB/363tK7+Qu9oxCi8WrvWs9vSsVGvgkbmpnz+Q 8aaXEDSHnc8Zzvb8sVAD32XWrEekxd8rlHAj/hYaw6du9DMOZcInZZc69t6nC8vyxhre QGzD5OVv9EiKlduv/bMR3/m/oE6ca9Jbw+MqKoo5Q67syaVMmJlVypYuHrAIUDIV+nF4 Q7NsOkdQX4s4Y+0j/E1/E7OPBc5gq7eaFGHLbHJX5rkqVh08VR1f8kXeTr5BkZl/yQUv 9SGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=0kHnTRwN0hxqCsvTD3VbFwdfLw6YEEfoemtA7hgFdeY=; b=OHEW2lQVIVFn9tuRiCspRIG2LnmacYQTd1wdK3yrLrnF3UglPdBrr6EdPb4cHIzPW+ f4ZJ27o34TZUeO9hSvPtEbgnDdaDBTsg79zTwpJZIobuL5CKUwZiusnWJtim1g6Xu+cZ PLWArD1IT8PXU40IiKy45w2cYh2laTIv43L5BRNvCwiCLBwNGicu30Vs/jeVm1jnwA9K FUJWP+ng2CW4JioiDlYDb2y1XvtTtZblcQrTmhZMXLL0o2ndWPodKuIw0adv3mfK+RdZ vnPTCiUjAINj029MwxVKnKZJDzlS14b/IiZl15yhD3a7IIFhZmNUvtvJt4BB0UPrnYa5 UWyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Uz5ISGpv; 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 f8si3297687edd.395.2021.04.15.12.58.20; Thu, 15 Apr 2021 12:58:44 -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=Uz5ISGpv; 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 S235111AbhDOT4k (ORCPT + 99 others); Thu, 15 Apr 2021 15:56:40 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.191]:19970 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234815AbhDOT4e (ORCPT ); Thu, 15 Apr 2021 15:56:34 -0400 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 6872140159B18 for ; Thu, 15 Apr 2021 14:54:24 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id X84Gl39nsPkftX84GlLYCK; Thu, 15 Apr 2021 14:54:24 -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:From:References:Cc:To:Subject: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=0kHnTRwN0hxqCsvTD3VbFwdfLw6YEEfoemtA7hgFdeY=; b=Uz5ISGpvbu8Eh1ur5FcrX5PwqN L/Jl1ogfKgW2x9xQaRMfWaV1L0HpT+UGvP/6RH7IxwPKtVJ7miG6I21IxzHg8JqlNP4TUcsqdhOgO zpz2soKPSa0UKVS6Guo6BokfVR2PiAu03lBnbn7f3fUMCLggwBfV1AqtTT0zBt4ExnDFtosuM4u+O fsoOSRFxwzYtVpQhnP6PFVbfYrc50eGqZf4QmH7dQTohqgNSgsuXcBxMNi/MgFS0hIUlq0RCUTXbR mB224o3I1uvTbZOjXX2a0eO4phhoo/7CSQUvThlgi7T0DaHJ9CYLF52iIcwbEPurF+wqrPkDzV4XS eW/PIiHQ==; Received: from 187-162-31-110.static.axtel.net ([187.162.31.110]:47186 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lX84D-001iz4-TV; Thu, 15 Apr 2021 14:54:21 -0500 Subject: Re: [PATCH][next] hpfs: Replace one-element array with flexible-array member To: "Gustavo A. R. Silva" , Mikulas Patocka Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Andrew Morton References: <20210326173510.GA81212@embeddedor> From: "Gustavo A. R. Silva" Message-ID: Date: Thu, 15 Apr 2021 14:54:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210326173510.GA81212@embeddedor> 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: 187.162.31.110 X-Source-L: No X-Exim-ID: 1lX84D-001iz4-TV X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-31-110.static.axtel.net ([192.168.15.8]) [187.162.31.110]:47186 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 3 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, Friendly ping: who can take this, please? Thanks -- Gustavo On 3/26/21 12:35, Gustavo A. R. Silva wrote: > There is a regular need in the kernel to provide a way to declare having > a dynamically sized set of trailing elements in a structure. Kernel code > should always use “flexible array members”[1] for these cases. The older > style of one-element or zero-length arrays should no longer be used[2]. > > Also, this helps with the ongoing efforts to enable -Warray-bounds by > fixing the following warning: > > CC [M] fs/hpfs/dir.o > fs/hpfs/dir.c: In function ‘hpfs_readdir’: > fs/hpfs/dir.c:163:41: warning: array subscript 1 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} [-Warray-bounds] > 163 | || de ->name[0] != 1 || de->name[1] != 1)) > | ~~~~~~~~^~~ > > [1] https://en.wikipedia.org/wiki/Flexible_array_member > [2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/109 > Signed-off-by: Gustavo A. R. Silva > --- > fs/hpfs/hpfs.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h > index 302f45101a96..d92c4af3e1b4 100644 > --- a/fs/hpfs/hpfs.h > +++ b/fs/hpfs/hpfs.h > @@ -356,7 +356,8 @@ struct hpfs_dirent { > u8 no_of_acls; /* number of ACL's (low 3 bits) */ > u8 ix; /* code page index (of filename), see > struct code_page_data */ > - u8 namelen, name[1]; /* file name */ > + u8 namelen; /* file name length */ > + u8 name[]; /* file name */ > /* dnode_secno down; btree down pointer, if present, > follows name on next word boundary, or maybe it > precedes next dirent, which is on a word boundary. */ >