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-next>] [day] [month] [year] [list]
Date:	Fri, 23 Jul 2010 10:48:17 -0700
From:	Joe Perches <joe@...ches.com>
To:	Dan Carpenter <error27@...il.com>
Cc:	Bruno Randolf <br1@...fach.org>,
	"Luis R. Rodriguez" <lrodriguez@...eros.com>,
	Nick Kossifidis <mickflemm@...il.com>,
	Jiri Slaby <jirislaby@...il.com>,
	Bob Copeland <me@...copeland.com>,
	"John W. Linville" <linville@...driver.com>,
	linux-wireless@...r.kernel.org, ath5k-devel@...ts.ath5k.org,
	kernel-janitors <kernel-janitors@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [patch -next] ath5k: snprintf() returns largish values

On Fri, 2010-07-23 at 12:04 +0200, Dan Carpenter wrote:
> This is a smatch thing.  I suppose someday I will fix smatch to
> evaulate the strings themselves and verify that the buffer is large
> enough.  But for now it's nice to be able to automatically check that
> the buffers don't overflow.  

There are also many repeated uses of snprintf in kernel sources
that could similarly be a problem.

	bar += snprintf(foo + bar, ...)
	bar += snprintf(foo + bar, ...)
or
	foo += snprintf(foo, ...)
	foo += snprintf(foo, ...)

For instance:

$ grep -P -n -A 4 -m 3 "\+=\s*snprintf" drivers/net/wireless/ath/ath5k/debug.c
210:	len += snprintf(buf+len, sizeof(buf)-len,
211-		"%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
212-		"AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
213-		(v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
214-
215:	len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
216-		"AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
217-
218:	len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
219-		"AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
220-

A conversion from snprintf to scnprintf might be appropriate
for those patterns.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ