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]
Message-ID: <20190322152339.GA7692@fieldses.org>
Date:   Fri, 22 Mar 2019 11:23:39 -0400
From:   "J. Bruce Fields" <bfields@...ldses.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Jeff Layton <jlayton@...nel.org>,
        clang-built-linux@...glegroups.com,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Nathan Chancellor <natechancellor@...il.com>,
        Olga Kornievskaia <kolga@...app.com>,
        Chuck Lever <chuck.lever@...cle.com>,
        Scott Mayhew <smayhew@...hat.com>, linux-nfs@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nfsd: avoid uninitialized variable warning

On Fri, Mar 22, 2019 at 03:07:11PM +0100, Arnd Bergmann wrote:
> clang warns that 'contextlen' may be accessed without an initialization:
> 
> fs/nfsd/nfs4xdr.c:2911:9: error: variable 'contextlen' is uninitialized when used here [-Werror,-Wuninitialized]
>                                                                 contextlen);
>                                                                 ^~~~~~~~~~
> fs/nfsd/nfs4xdr.c:2424:16: note: initialize the variable 'contextlen' to silence this warning
>         int contextlen;
>                       ^
>                        = 0
> 
> Presumably this cannot happen, as FATTR4_WORD2_SECURITY_LABEL is
> set if CONFIG_NFSD_V4_SECURITY_LABEL is enabled.
> Adding another #ifdef like the other two in this function
> avoids the warning.

Thanks, applied.--b.

> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  fs/nfsd/nfs4xdr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 3de42a729093..a3a3455826aa 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2420,8 +2420,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
>  	__be32 status;
>  	int err;
>  	struct nfs4_acl *acl = NULL;
> +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
>  	void *context = NULL;
>  	int contextlen;
> +#endif
>  	bool contextsupport = false;
>  	struct nfsd4_compoundres *resp = rqstp->rq_resp;
>  	u32 minorversion = resp->cstate.minorversion;
> @@ -2906,12 +2908,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
>  			*p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA);
>  	}
>  
> +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
>  	if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
>  		status = nfsd4_encode_security_label(xdr, rqstp, context,
>  								contextlen);
>  		if (status)
>  			goto out;
>  	}
> +#endif
>  
>  	attrlen = htonl(xdr->buf->len - attrlen_offset - 4);
>  	write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4);
> -- 
> 2.20.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ