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: <4D56541D.3030409@uw.no>
Date:	Sat, 12 Feb 2011 09:34:21 +0000
From:	"Daniel K." <dk@...no>
To:	Jesper Juhl <jj@...osbits.net>
CC:	linux-kernel@...r.kernel.org, linux-raid@...r.kernel.org,
	Neil Brown <neilb@...e.de>, Neil Brown <neilb@....unsw.edu.au>
Subject: Re: [PATCH] md: Remove risk of overflow via sprintf) by using snprintf()
 in md_check_recovery()

Jesper Juhl wrote:
> sprintf() is dangerous - given the wrong source string it will overflow 
> the destination. snprintf() is safer in that at least we'll never overflow 
> the destination. Even if overflow will never happen today, code changes 
> over time and snprintf() is just safer in the long run.

> -						sprintf(nm,"rd%d", rdev->raid_disk);
> +						snprintf(nm, sizeof(nm), "rd%d", rdev->raid_disk);
>  						sysfs_remove_link(&mddev->kobj, nm);

What if "rd1234" get truncated to "rd123" and you remove the wrong link.
(No, I didn't actually bother to check how much room was allocated.)

Isn't it better to overflow than silently to unlink the wrong file?

What will happen when you try to unlink the "rd123" file again, when the 
actual 123 is meant?

Whatever the real fix is, should this be checked for at create_link time 
as well?


Daniel K.
--
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