From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustavo A. R. Silva Date: Tue, 11 Oct 2022 14:24:50 -0500 Subject: [Cluster-devel] [PATCH] [next] dlm: replace one-element array with fixed size array In-Reply-To: References: Message-ID: List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Oct 12, 2022 at 08:15:17AM +1300, Paulo Miguel Almeida wrote: > One-element arrays are deprecated. So, replace one-element array with > fixed size array member in struct dlm_ls, and refactor the rest of the > code, accordingly. > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/228 > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 > Link: https://lore.kernel.org/lkml/Y0W5jkiXUkpNl4ap at mail.google.com/ > > Signed-off-by: Paulo Miguel Almeida I think this should be versioned as v3. > --- > fs/dlm/dlm_internal.h | 2 +- > fs/dlm/lockspace.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h > index e34c3d2639a5..94fadb619ba0 100644 > --- a/fs/dlm/dlm_internal.h > +++ b/fs/dlm/dlm_internal.h > @@ -670,7 +670,7 @@ struct dlm_ls { > void *ls_ops_arg; > > int ls_namelen; > - char ls_name[1]; > + char ls_name[DLM_LOCKSPACE_LEN + 1]; > }; > > /* > diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c > index bae050df7abf..23de0d47cbc1 100644 > --- a/fs/dlm/lockspace.c > +++ b/fs/dlm/lockspace.c > @@ -473,7 +473,7 @@ static int new_lockspace(const char *name, const char *cluster, > > error = -ENOMEM; > > - ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS); > + ls = kzalloc(sizeof(struct dlm_ls), GFP_NOFS); sizeof(*ls) is preferred here....^^^ -- Gustavo From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 800F9C433F5 for ; Tue, 11 Oct 2022 19:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbiJKTZK (ORCPT ); Tue, 11 Oct 2022 15:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbiJKTZG (ORCPT ); Tue, 11 Oct 2022 15:25:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E36165A6; Tue, 11 Oct 2022 12:25:05 -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 ams.source.kernel.org (Postfix) with ESMTPS id D18F0B81673; Tue, 11 Oct 2022 19:25:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 745A6C433B5; Tue, 11 Oct 2022 19:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665516302; bh=3fp/xUhgJzjsTGb7S89xAhTVaadS8dJVok86wtoE330=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ow4mDD0TyZCIHW8Ky4hsjr14EBg/rumm8HPFhpn3AvWkbXSMqukI9ghtCWXVcySMr CRYTTrRVZYnUiEozI1gPrurONC+qHmIVXAAklJVV01ZojYrDrcJFokJ6rDOHROzv5H kocdh2puYT+HjU+N1Ip4zY0NLSXIxklGe4UoYRHnNrzShWgryiAwDRYrLPLxz+NsmY ntSqE5RTi6iSrZKWZKb9qHfOerhV3st87AW5py8Tkl/keGy7WTO3JaOmxhWmzrxaCu TPLgEjkiJAlTmJVLrLHHTZqPzixn6td2fouIIl3HAjF1cN17i0cLJ5ELkBILOMgGaW 6ZN64SJ+4LeGQ== Date: Tue, 11 Oct 2022 14:24:50 -0500 From: "Gustavo A. R. Silva" To: Paulo Miguel Almeida Cc: Christine Caulfield , David Teigland , cluster-devel@redhat.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] [next] dlm: replace one-element array with fixed size array Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Wed, Oct 12, 2022 at 08:15:17AM +1300, Paulo Miguel Almeida wrote: > One-element arrays are deprecated. So, replace one-element array with > fixed size array member in struct dlm_ls, and refactor the rest of the > code, accordingly. > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/228 > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 > Link: https://lore.kernel.org/lkml/Y0W5jkiXUkpNl4ap@mail.google.com/ > > Signed-off-by: Paulo Miguel Almeida I think this should be versioned as v3. > --- > fs/dlm/dlm_internal.h | 2 +- > fs/dlm/lockspace.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h > index e34c3d2639a5..94fadb619ba0 100644 > --- a/fs/dlm/dlm_internal.h > +++ b/fs/dlm/dlm_internal.h > @@ -670,7 +670,7 @@ struct dlm_ls { > void *ls_ops_arg; > > int ls_namelen; > - char ls_name[1]; > + char ls_name[DLM_LOCKSPACE_LEN + 1]; > }; > > /* > diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c > index bae050df7abf..23de0d47cbc1 100644 > --- a/fs/dlm/lockspace.c > +++ b/fs/dlm/lockspace.c > @@ -473,7 +473,7 @@ static int new_lockspace(const char *name, const char *cluster, > > error = -ENOMEM; > > - ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS); > + ls = kzalloc(sizeof(struct dlm_ls), GFP_NOFS); sizeof(*ls) is preferred here....^^^ -- Gustavo