-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@kernel.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;
unsigned long rq_flags;
ktime_t rq_stime;
__be32 rq_xid;
--
2.34.1
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@kernel.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
On Thu, 17 Oct 2024, Chuck Lever wrote: > 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@kernel.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() ? sockaddr_storage is conceptually the right solution. It is 128 bytes so 2 of them will waste about 200 bytes on the stack. Does that matter these days? Probably not. I do like using rpc_copy_addr(). NeilBrown > > > > unsigned long rq_flags; > > ktime_t rq_stime; > > __be32 rq_xid; > > -- > > 2.34.1 > > > > -- > Chuck Lever >
© 2016 - 2024 Red Hat, Inc.