[PATCH] add check to /proc/devices read routines
Patch to add check to get_chrdev_list and get_blkdev_list to prevent reads of /proc/devices from spilling over the provided page if more than 4096 bytes of string data are generated from all the registered character and block devices in a system Signed-off-by: Neil Horman <nhorman@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: <viro@parcelfarce.linux.theplanet.co.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:

committed by
Linus Torvalds

parent
3bc1ee3e8f
commit
ac20427ef6
@@ -56,10 +56,21 @@ int get_chrdev_list(char *page)
|
||||
|
||||
down(&chrdevs_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) {
|
||||
for (cd = chrdevs[i]; cd; cd = cd->next)
|
||||
for (cd = chrdevs[i]; cd; cd = cd->next) {
|
||||
/*
|
||||
* if the current name, plus the 5 extra characters
|
||||
* in the device line for this entry
|
||||
* would run us off the page, we're done
|
||||
*/
|
||||
if ((len+strlen(cd->name) + 5) >= PAGE_SIZE)
|
||||
goto page_full;
|
||||
|
||||
|
||||
len += sprintf(page+len, "%3d %s\n",
|
||||
cd->major, cd->name);
|
||||
}
|
||||
}
|
||||
page_full:
|
||||
up(&chrdevs_lock);
|
||||
|
||||
return len;
|
||||
|
Reference in New Issue
Block a user