linux_old1/kernel/time
Miao Xie 5e2cb1018a time: fix sysfs_show_{available,current}_clocksources() buffer overflow problem
I found that there is a buffer overflow problem in the following code.

Version:	2.6.24-rc2,
File:		kernel/time/clocksource.c:417-432
--------------------------------------------------------------------
static ssize_t
sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
{
	struct clocksource *src;
	char *curr = buf;

	spin_lock_irq(&clocksource_lock);
	list_for_each_entry(src, &clocksource_list, list) {
		curr += sprintf(curr, "%s ", src->name);
	}
	spin_unlock_irq(&clocksource_lock);

	curr += sprintf(curr, "\n");

	return curr - buf;
}
-----------------------------------------------------------------------

sysfs_show_current_clocksources() also has the same problem though in practice
the size of current clocksource's name won't exceed PAGE_SIZE.

I fix the bug by using snprintf according to the specification of the kernel
(Version:2.6.24-rc2,File:Documentation/filesystems/sysfs.txt)

Fix sysfs_show_available_clocksources() and sysfs_show_current_clocksources()
buffer overflow problem with snprintf().

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-06 10:41:03 -08:00
..
Kconfig clockevents: Allow build w/o run-tine usage for migration purposes 2007-10-12 23:04:05 +02:00
Makefile clockevents: Allow build w/o run-tine usage for migration purposes 2007-10-12 23:04:05 +02:00
clockevents.c x86: make clockevents more robust 2008-01-30 13:30:03 +01:00
clocksource.c time: fix sysfs_show_{available,current}_clocksources() buffer overflow problem 2008-02-06 10:41:03 -08:00
jiffies.c [PATCH] fix jiffies clocksource inittime 2007-04-04 21:12:47 -07:00
ntp.c time: add ADJ_OFFSET_SS_READ 2007-11-26 20:42:19 +01:00
tick-broadcast.c timer: clean up tick-broadcast.c 2008-01-30 13:30:01 +01:00
tick-common.c clockevents: introduce force broadcast notifier 2007-10-14 22:57:45 +02:00
tick-internal.h timer: clean up tick-broadcast.c 2008-01-30 13:30:01 +01:00
tick-oneshot.c highres: improve debug output 2007-07-21 17:49:15 -07:00
tick-sched.c tick-sched: add more debug information 2008-02-01 17:45:14 +01:00
timekeeping.c timekeeping: update xtime_cache when time(zone) changes 2008-02-01 17:45:13 +01:00
timer_list.c tick-sched: add more debug information 2008-02-01 17:45:14 +01:00
timer_stats.c time: more timer related cleanups 2008-01-30 13:30:00 +01:00