linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Eric Farman <farman@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 1/2][next] vfio/ccw: Replace one-element array with flexible-array member
Date: Tue, 23 May 2023 19:47:03 +0200	[thread overview]
Message-ID: <98460663-eff1-6f42-1371-6c44ec6dc288@wanadoo.fr> (raw)
In-Reply-To: <c3a473c2-1d4a-1b8a-648f-7f75b800ecd7@wanadoo.fr>



Le 23/05/2023 à 19:45, Christophe JAILLET a écrit :
> Le 23/05/2023 à 03:35, Gustavo A. R. Silva a écrit :
>> One-element arrays are deprecated, and we are replacing them with 
>> flexible
>> array members instead. So, replace one-element array with flexible-array
>> member in struct vfio_ccw_parent and refactor the the rest of the code
>> accordingly.
>>
>> Link: https://github.com/KSPP/linux/issues/79
>> Link: https://github.com/KSPP/linux/issues/297
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> ---
>>   drivers/s390/cio/vfio_ccw_drv.c     | 3 ++-
>>   drivers/s390/cio/vfio_ccw_private.h | 2 +-
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/s390/cio/vfio_ccw_drv.c 
>> b/drivers/s390/cio/vfio_ccw_drv.c
>> index ff538a086fc7..57906a9c6324 100644
>> --- a/drivers/s390/cio/vfio_ccw_drv.c
>> +++ b/drivers/s390/cio/vfio_ccw_drv.c
>> @@ -171,7 +171,8 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
>>           return -ENODEV;
>>       }
>> -    parent = kzalloc(sizeof(*parent), GFP_KERNEL);
>> +    parent = kzalloc(sizeof(*parent) + sizeof(struct mdev_type *),
> 
> Hi, wouldn't:
> 
>     parent = kzalloc(struct_size(parent, mdev_types, 1)),
> 
> be more informative and in the spirit of flexible array use?

Ok, patch 2/2.

Sorry for the noise.

CJ

> 
> Just my 2c,
> 
> CJ
> 
>> +             GFP_KERNEL);
>>       if (!parent)
>>           return -ENOMEM;
>> diff --git a/drivers/s390/cio/vfio_ccw_private.h 
>> b/drivers/s390/cio/vfio_ccw_private.h
>> index b441ae6700fd..b62bbc5c6376 100644
>> --- a/drivers/s390/cio/vfio_ccw_private.h
>> +++ b/drivers/s390/cio/vfio_ccw_private.h
>> @@ -79,7 +79,7 @@ struct vfio_ccw_parent {
>>       struct mdev_parent    parent;
>>       struct mdev_type    mdev_type;
>> -    struct mdev_type    *mdev_types[1];
>> +    struct mdev_type    *mdev_types[];
>>   };
>>   /**
> 
> 

  reply	other threads:[~2023-05-23 17:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23  1:34 [PATCH 0/2][next] vfio/ccw: Replace one-element array with flexible-array member Gustavo A. R. Silva
2023-05-23  1:35 ` [PATCH 1/2][next] " Gustavo A. R. Silva
2023-05-23 16:33   ` Eric Farman
2023-05-23 17:29   ` Kees Cook
2023-05-23 17:45   ` Christophe JAILLET
2023-05-23 17:47     ` Marion & Christophe JAILLET [this message]
2023-05-23  1:35 ` [PATCH 2/2][next] vfio/ccw: Use struct_size() helper Gustavo A. R. Silva
2023-05-23 16:33   ` Eric Farman
2023-05-23 17:30   ` Kees Cook
2023-05-23 16:36 ` [PATCH 0/2][next] vfio/ccw: Replace one-element array with flexible-array member Matthew Rosato
2023-05-23 18:58 ` Alexander Gordeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98460663-eff1-6f42-1371-6c44ec6dc288@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=farman@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gustavoars@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=vneethv@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).