From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E16CD1E495 for ; Sun, 5 Jan 2025 04:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736050512; cv=none; b=O+hntXtolyzS3UcV9l2CKIL9iQlHpi66vuk6aXsGnthxYKlJagnq8shIFZRTTEiyHzKckEw/gkZX61QPGkCgBb02tqF52cq2rqhfyJX/WFTWdUcyiQSt2/VfZBNZ0R83MckTZMrA7GsSnYfueWYnAkyy9LX+bIJT+D62Qe2QLZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736050512; c=relaxed/simple; bh=P9eOjaOI2LC9LhZ6Px+trgodUECZTt6C+WiTYfGakzQ=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=a2J4VpWgeCU6P01GOdt/irsevJOuZgELlnf092BLiRW7FMqr299oQ4MA9lAFmLuoUwVFBHgxuPkHDrJZYu/IhPvh72tTnRV5tjX4kJ9VUgNalMGKWbG8D643qFSkgh2onkmcuStJWNbROc/CqNT7/jrEmXVEgYOIRVOq607dJLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=PAR9kRix; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="PAR9kRix" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6d888fc8300so65079606d6.3 for ; Sat, 04 Jan 2025 20:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1736050509; x=1736655309; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=mnkW2Ito+yFWYvNl8ukUMqSS1ZhIA/mI5uOYZFH7SfM=; b=PAR9kRixZaYZj37wnkhPaFT8gfFzdpTMjkZQiNscrLdUH/zLP8Q+VRGMt5am8nvj8b hZIPd3AnI8F6rbVSjWqklTr7quVAgsYsXu+a2hIbM7fYBuu+phz3lGBoXZHqmhVIwZNw wM+4mxxbK1eNbMzylEup+YVOhGQ0L++ajzYg8rLShcHJK3ZXVFTVie2VtjK94OyINyY3 ofeZpthOpQEO5TeVKMgZUpFmcvoio9cWwJCMz3tRZAHleBI7cm9sz0KNEWKHeEk/T0WV 8f8dtHYSnMv2WqBLShvszW7a/gUaB1J4uNM2STSaTDpOmNEru6uZl/3s4OaHdyxe9gCU gliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736050509; x=1736655309; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=mnkW2Ito+yFWYvNl8ukUMqSS1ZhIA/mI5uOYZFH7SfM=; b=GdApYVuIQ34nnTcmhI1az75SVWN0D1S/12I5x1ucIp1sOnqwSQUafa+oe3J2FlaHEc sCcLsP54C87edbtEYynairmq6vYWepmimdbqxqEY4y6jLUOhZqNkykONZxlUjo+uPL+R btaZIyFwO8A2HR0ILq1ioqNtIdmu5vVKkYZXmGpX/7LRKKaGrh5+IpwYzQt3+ydguZVW Gn8+vT8XewSHKbU3ItIFd2zZsguqh8rWi2TGR1GtUuL2FKsoIH++jp4I4b+vOtecY2iw TBCOqplacC8XFlWzAJYiEkpq7MPdjrCTR0B16RSTSfOiWPS3SgcADmVnBH/yXjWJAVbk /wBQ== X-Forwarded-Encrypted: i=1; AJvYcCXn4lZyzbmHlUPGV0mvTxQSG6pqnYnINNNz1OPU1F67oahy3SRZjRFjV9goKJmGFrerRHq06MtGerJIi8g=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7nb/28/+xWJ9QlEArsjfXxgpb6+majV5QmIHUVsyCVuyhwe6k z4qsV63fKHKmCtstwlwJN5L3nKoPEBMB32yMXGNFXI/fp/jDe08bMHIC8WrOsg== X-Gm-Gg: ASbGncvZP22OkZq6L2Rt/R+3U4WOYOtAZnbJjYYtC9pWgIIKCYxW/75zrjYeQWZoSGG PE5uoCIN0S7FCUp1MIs/S/hcKI1lqqCAmMkllhuuFGnaUFjM67N6FPjOPmnxVKk6+Dnal2s3JME 6Z3csj+OKbOHB/5lbF90ZFEmwTgQtwrD5BlomFV7g4fBYr7W/0cQDWkqIMY1ESf2ULPCGvQRMLE sv45uBUJFxcEMtutkuFRD+WamNMzJwA3Enjf/wVvugBBvnUEfg= X-Google-Smtp-Source: AGHT+IH1yr+84FG4k22YoYqBX+gg+RpxcYNPFOy6IvkpIUQv6J8BwbJD0+YUBjKVZ/nXreKrgSCzJg== X-Received: by 2002:a05:6214:2689:b0:6d8:8f14:2f5f with SMTP id 6a1803df08f44-6dd23349b0dmr1002590736d6.23.1736050508849; Sat, 04 Jan 2025 20:15:08 -0800 (PST) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dd181c13b6sm156918956d6.96.2025.01.04.20.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2025 20:15:08 -0800 (PST) Date: Sat, 04 Jan 2025 23:15:07 -0500 Message-ID: <018b4316dc1089799101308931a47fdc@paul-moore.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20250104_1133/pstg-lib:20250104_1133/pstg-pwork:20250104_1133 From: Paul Moore To: Tanya Agarwal , 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 References: <20250104191006.3807-1-tanyaagarwal25699@gmail.com> In-Reply-To: <20250104191006.3807-1-tanyaagarwal25699@gmail.com> On Jan 4, 2025 Tanya Agarwal 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 > --- > 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