[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zw/KoQRfBl5Y9xyS@tissot.1015granger.net>
Date: Wed, 16 Oct 2024 10:16:01 -0400
From: Chuck Lever <chuck.lever@...cle.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Jeff Layton <jlayton@...nel.org>, Neil Brown <neilb@...e.de>,
Olga Kornievskaia <okorniev@...hat.com>, Dai Ngo <Dai.Ngo@...cle.com>,
Tom Talpey <tom@...pey.com>, linux-nfs@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org,
Kees Cook <kees@...nel.org>
Subject: Re: [PATCH 2/5][next] nfsd: avoid -Wflex-array-member-not-at-end
warnings
On Tue, Oct 15, 2024 at 06:29:31PM -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Address the following warnings by changing the type of the middle struct
> members in `struct nfsd_genl_rqstp`, which are currently causing trouble,
> from `struct sockaddr` to `struct sockaddr_legacy`. Note that the latter
> struct doesn't contain a flexible-array member.
>
> fs/nfsd/nfsd.h:74:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> fs/nfsd/nfsd.h:75:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Also, update some related code, accordingly.
>
> No binary differences are present after these changes.
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> ---
> fs/nfsd/nfsctl.c | 4 ++--
> fs/nfsd/nfsd.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 3adbc05ebaac..884bfdc7a255 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -1599,9 +1599,9 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,
> genl_rqstp.rq_stime = rqstp->rq_stime;
> genl_rqstp.rq_opcnt = 0;
> memcpy(&genl_rqstp.rq_daddr, svc_daddr(rqstp),
> - sizeof(struct sockaddr));
> + sizeof(struct sockaddr_legacy));
> memcpy(&genl_rqstp.rq_saddr, svc_addr(rqstp),
> - sizeof(struct sockaddr));
> + sizeof(struct sockaddr_legacy));
>
> #ifdef CONFIG_NFSD_V4
> if (rqstp->rq_vers == NFS4_VERSION &&
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> index 004415651295..44be32510595 100644
> --- a/fs/nfsd/nfsd.h
> +++ b/fs/nfsd/nfsd.h
> @@ -71,8 +71,8 @@ struct readdir_cd {
> #define NFSD_MAX_OPS_PER_COMPOUND 50
>
> struct nfsd_genl_rqstp {
> - struct sockaddr rq_daddr;
> - struct sockaddr rq_saddr;
> + struct sockaddr_legacy rq_daddr;
> + struct sockaddr_legacy rq_saddr;
I was hoping to find a struct definition that was simply a union of
sockaddr_in and sockaddr_in6, which we have in nfs-utils but I guess
not here in the kernel.
Can we use "struct sockaddr_storage" safely here? Then above,
replace the raw memcpy() with rpc_copy_addr() ?
> unsigned long rq_flags;
> ktime_t rq_stime;
> __be32 rq_xid;
> --
> 2.34.1
>
--
Chuck Lever
Powered by blists - more mailing lists