NetBSD Problem Report #58634

From www@netbsd.org  Sat Aug 24 20:46:02 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 760C91A9241
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 24 Aug 2024 20:46:02 +0000 (UTC)
Message-Id: <20240824204601.72E3E1A9242@mollari.NetBSD.org>
Date: Sat, 24 Aug 2024 20:46:01 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: smsc(4): uninitialized stack data returned on I/O error in smsc_uno_miibus_readreg
X-Send-Pr-Version: www-1.0

>Number:         58634
>Category:       kern
>Synopsis:       smsc(4): uninitialized stack data returned on I/O error in smsc_uno_miibus_readreg
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 24 20:50:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, ...
>Organization:
The NetBSMSCD Miidation
>Environment:
>Description:
*** CID 1597788:  Error handling issues  (CHECKED_RETURN)
/sys/dev/usb/if_smsc.c: 302 in smsc_uno_miibus_readreg()
296     	if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
297     		smsc_warn_printf(un, "MII read timeout\n");
298     		*val = 0;
299     		return ETIMEDOUT;
300     	}
301     
>>>     CID 1597788:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "smsc_readreg" without checking return value (as is done elsewhere 9 out of 10 times).
302     	smsc_readreg(un, SMSC_MII_DATA, &data);
303     
304     	*val = data & 0xffff;
305     	return 0;
306     }
307     

smsc_readreg doesn't guarantee data is initialized on error.
>How-To-Repeat:
code inspection
>Fix:
Yes, please!  Check for smsc_readreg error and just return 0 or something in this case.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.