lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 11 Nov 2022 15:06:23 +0000
From:   Chuck Lever III <chuck.lever@...cle.com>
To:     Xiu Jianfeng <xiujianfeng@...wei.com>
CC:     Jeff Layton <jlayton@...nel.org>,
        Linux NFS Mailing List <linux-nfs@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] NFSD: Use struct_size() helpler in alloc_session()



> On Nov 11, 2022, at 4:18 AM, Xiu Jianfeng <xiujianfeng@...wei.com> wrote:
> 
> Use struct_size() helper to simplify the code, no functional changes.
> 
> Signed-off-by: Xiu Jianfeng <xiujianfeng@...wei.com>

Applied to nfsd's for-next tree. Thanks!


> ---
> fs/nfsd/nfs4state.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 2ec981fd2985..97badca3135e 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1833,13 +1833,12 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fattrs,
> 	int numslots = fattrs->maxreqs;
> 	int slotsize = slot_bytes(fattrs);
> 	struct nfsd4_session *new;
> -	int mem, i;
> +	int i;
> 
> -	BUILD_BUG_ON(NFSD_MAX_SLOTS_PER_SESSION * sizeof(struct nfsd4_slot *)
> -			+ sizeof(struct nfsd4_session) > PAGE_SIZE);
> -	mem = numslots * sizeof(struct nfsd4_slot *);
> +	BUILD_BUG_ON(struct_size(new, se_slots, NFSD_MAX_SLOTS_PER_SESSION)
> +		     > PAGE_SIZE);
> 
> -	new = kzalloc(sizeof(*new) + mem, GFP_KERNEL);
> +	new = kzalloc(struct_size(new, se_slots, numslots), GFP_KERNEL);
> 	if (!new)
> 		return NULL;
> 	/* allocate each struct nfsd4_slot and data cache in one piece */
> -- 
> 2.17.1
> 

--
Chuck Lever



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ