Message ID | 3c10549ebe1564eade68a2515bde233527376971.1684805398.git.gustavoars@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1832191vqo; Mon, 22 May 2023 18:45:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PO8u0qCzJV9McFktOW+rlk6gM7cP2HNOw1wOcfMxXxhtNLBWNGjfQulurfVtx9VVewzrk X-Received: by 2002:a17:90b:3582:b0:255:435e:cec4 with SMTP id mm2-20020a17090b358200b00255435ecec4mr7180543pjb.24.1684806355199; Mon, 22 May 2023 18:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684806355; cv=none; d=google.com; s=arc-20160816; b=sKhnwlaSXDjNp70YFtGiv6cOkt+Sxu9gHm2Nnw37vNkvEDxnmmzp2QtpzKt3qBV+I7 O924rLM+W0BGW9JEtrvbg981ZcZpp830yDYSQaCQEMA2wa6VnzHcfEfsuv+nIE4CdpVy XJnIWkGrZSk8k3Q5ZqJEao545j4hGOVfJ5uzgIvZex6wDb2f8CqI/Shp3g+ZY5Fdp+I3 vyov+M7AWa8oHcFZaJw58xtrB7TzQHc7XhZ4k36TleMTLQRVo3UCtxG33phOh6dpKq2m H4hYF1twPgCS8aUH6lR5DtZPnsgtrvgY8Ow4XYr605Cu1mTlqEIpNcFhgCxD54NCGUNx ZDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HoscKaEKI1N5lQpIPffXVG2ttrag9ziKzIpewlFqvfw=; b=gI3O5xJN7npRjSgIp0omJ/Hrw02BMVWOWvRikvPz0aXEYP98VJ1sDdd8gLaEmYK225 f3YainFW6xNmXnkfaqSTXv+OhenXtcOQVUzZcqUflxCU4/l8PFqJPm3tR9xVwGnSaAjH L2Ziw2ezpEQRqsyj16oYq0jbXxFxYu7PnsRf1KjoodTcvC+8gdRmU+64pkJ2dUMlpjKg Mm7P9bI1w0Wv/HySu+AUCXDHltjejvMwv4wWkNTomS634vfOO7/VlwSj1a3DsMfe5Yzz n6omBuwVLumeW2ecGXwBU7lBDSxOqy9dYkfB94IgfhL1taEFOIDR2r9yihBBrOnTjLUY tPTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VfscvJfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a17090ad80100b002531c43fc41si5413284pjv.178.2023.05.22.18.45.40; Mon, 22 May 2023 18:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VfscvJfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234936AbjEWBeZ (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Mon, 22 May 2023 21:34:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbjEWBeX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 21:34:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445868E; Mon, 22 May 2023 18:34:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 79B4662D89; Tue, 23 May 2023 01:34:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13F37C433EF; Tue, 23 May 2023 01:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684805660; bh=BmXuXL/UqVGFg/YhKou0jzuTdayluGE9Gf9Xkd6BVDg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VfscvJfn2ijg4fxrfryZM+rU1I0wnEP4MwW1JE7SHohU7DE9kVcS4HjalgALAffN7 8d3CKw/1b4BibMj/OUI75yQbJGV5kDG8GAs28Y/i/LwoUTP43GmqVQiin9IEBL7JT+ Xmz1mTEKTvhmGB7FPfUDnTcYPIfjOHqoBp7H+ZE4I80oyDsXaUFeXuZXZGUVinrSTf SFkCl0DqANpM+H5LZz7G2s0dorWeznI8JXT0BmR3lkJMtRGu7o4ICJLS7QaFsACoR2 bDsXg84vGUHdtQZ1C4lvtpAQzHyZZmdApp6/9eVz3rt80/+kYS/y8ZMtoiTbAqsfLr sJD7l6zWlkVNA== Date: Mon, 22 May 2023 19:35:12 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: 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, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH 1/2][next] vfio/ccw: Replace one-element array with flexible-array member Message-ID: <3c10549ebe1564eade68a2515bde233527376971.1684805398.git.gustavoars@kernel.org> References: <cover.1684805398.git.gustavoars@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <cover.1684805398.git.gustavoars@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766647420494796092?= X-GMAIL-MSGID: =?utf-8?q?1766647508493465776?= |
Series |
vfio/ccw: Replace one-element array with flexible-array member
|
|
Commit Message
Gustavo A. R. Silva
May 23, 2023, 1:35 a.m. UTC
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(-)
Comments
On Mon, 2023-05-22 at 19:35 -0600, Gustavo A. R. Silva wrote: > 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 s/the the/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> Reviewed-by: Eric Farman <farman@linux.ibm.com> > --- > 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 > *), > + 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[]; > }; > > /**
On Mon, May 22, 2023 at 07:35:12PM -0600, Gustavo A. R. Silva wrote: > 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> Reviewed-by: Kees Cook <keescook@chromium.org>
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? 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[]; > }; > > /**
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[]; >> }; >> /** > >
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 *), + 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[]; }; /**