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] [thread-next>] [day] [month] [year] [list]
Message-ID: <018b4316dc1089799101308931a47fdc@paul-moore.com>
Date: Sat, 04 Jan 2025 23:15:07 -0500
From: Paul Moore <paul@...l-moore.com>
To: Tanya Agarwal <tanyaagarwal25699@...il.com>, jmorris@...ei.org, serge@...lyn.com
Cc: kees@...nel.org, yuehaibing@...wei.com, linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org, matthewgarrett@...gle.com, skhan@...uxfoundation.org, anupnewsmail@...il.com, tanyaagarwal25699@...il.com
Subject: Re: [PATCH v2] lockdown: Initialize array before use

On Jan  4, 2025 Tanya Agarwal <tanyaagarwal25699@...il.com> wrote:
> 
> The static code analysis tool "Coverity Scan" pointed the following
> details out for further development considerations:
> CID 1486102: Uninitialized scalar variable (UNINIT)
> uninit_use_in_call: Using uninitialized value *temp when calling
> strlen.
> 
> Conclusion:
> Initialize array before use in lockdown_read().
> 
> Fixes: 000d388ed3bb ("security: Add a static lockdown policy LSM")
> Signed-off-by: Tanya Agarwal <tanyaagarwal25699@...il.com>
> ---
> V2: add Fixes tag and reword commit description
> 
> Coverity Link:
> https://scan7.scan.coverity.com/#/project-view/52849/11354?selectedIssue=1486102
> 
>  security/lockdown/lockdown.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
> index f2bdbd55aa2b..df2c8435a7a9 100644
> --- a/security/lockdown/lockdown.c
> +++ b/security/lockdown/lockdown.c
> @@ -96,7 +96,7 @@ static int __init lockdown_lsm_init(void)
>  static ssize_t lockdown_read(struct file *filp, char __user *buf, size_t count,
>  			     loff_t *ppos)
>  {
> -	char temp[80];
> +	char temp[80] = {0};
>  	int i, offset = 0;

Since @temp is a string, it reads a bit better if we initialize it with
double quotes, e.g. 'char temp[80] = ""'.

This is also a case where the static analysis is a bit misleading.  The
@temp variable is uninitialized only if the @lockdown_levels array is
empty and seeing as the @lockdown_levels array is a constant array
defined in the source, this isn't a real issue we need to worry about.
However, if you wanted to fix this simply to quiet Coverity, I think
that would be okay, especially since this isn't a hot code path.

>  	for (i = 0; i < ARRAY_SIZE(lockdown_levels); i++) {
> -- 
> 2.39.5

--
paul-moore.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ