From: Paul Moore <paul@paul-moore.com>
To: Tanya Agarwal <tanyaagarwal25699@gmail.com>,
jmorris@namei.org, serge@hallyn.com
Cc: kees@kernel.org, yuehaibing@huawei.com,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, matthewgarrett@google.com,
skhan@linuxfoundation.org, anupnewsmail@gmail.com,
tanyaagarwal25699@gmail.com
Subject: Re: [PATCH v2] lockdown: Initialize array before use
Date: Sat, 04 Jan 2025 23:15:07 -0500 [thread overview]
Message-ID: <018b4316dc1089799101308931a47fdc@paul-moore.com> (raw)
In-Reply-To: <20250104191006.3807-1-tanyaagarwal25699@gmail.com>
On Jan 4, 2025 Tanya Agarwal <tanyaagarwal25699@gmail.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@gmail.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
next prev parent reply other threads:[~2025-01-05 4:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-04 19:10 [PATCH V2] " Tanya Agarwal
2025-01-05 4:15 ` Paul Moore [this message]
2025-01-05 6:07 ` [PATCH v2] " Tanya Agarwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=018b4316dc1089799101308931a47fdc@paul-moore.com \
--to=paul@paul-moore.com \
--cc=anupnewsmail@gmail.com \
--cc=jmorris@namei.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=matthewgarrett@google.com \
--cc=serge@hallyn.com \
--cc=skhan@linuxfoundation.org \
--cc=tanyaagarwal25699@gmail.com \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®