Summary: | DAHLIN-00111: [patch] procfs in dahdi can produce wrong (broken) data and warning | ||
Reporter: | Pavel Selivanov (biohumanoid) | Labels: | |
Date Opened: | 2009-06-02 06:11:39 | Date Closed: | 2009-06-04 16:17:33 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | dahdi (the module) |
Versions: | 2.2.0-rc5 | Frequency of Occurrence | |
Related Issues: | |||
Environment: | Attachments: | ( 0) dahdi-base.c.patch | |
Description: | /* In Linux 2.6, this MUST NOT EXECEED 1024 bytes in one read! */ It's not truth... /* In Linux 2.6, page is always PROC_BLOCK_SIZE=(PAGE_SIZE-1024) bytes. * 0<count<=PROC_BLOCK_SIZE . count=1 will produce an error in * vsnprintf ('head -c 1 /proc/dahdi/1', 'dd bs=1').*/ head -c 10 /proc/dahdi/1 or if you have a lot of channels, you will see the following: May 25 15:48:28 asteroid kernel: [ 722.051812] WARNING: at lib/vsprintf.c:609 vsnprintf+0x38/0x452() and a broken output... ****** ADDITIONAL INFORMATION ****** The reason - someone used snprintf instead of sprintf, and count is the number of requested bytes (not allocated bytes). Provided patch is a (working) workaround. A better way to go - to use a newer procfs interface (seq_printf) or sysfs. An example: static int sky2_debug_show(struct seq_file *seq, void *v) { struct net_device *dev = seq->private; seq_printf(seq, "IRQ src=%x mask=%x control=%x\n", sky2_read32(hw, B0_ISRC), sky2_read32(hw, B0_IMSK), sky2_read32(hw, B0_Y2_SP_ICR)); //..... } static int sky2_debug_open(struct inode *inode, struct file *file) { return single_open(file, sky2_debug_show, inode->i_private); } static const struct file_operations sky2_debug_fops = { .owner = THIS_MODULE, .open = sky2_debug_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; sky2->debugfs = debugfs_create_file(dev->name, S_IRUGO, sky2_debug, dev, &sky2_debug_fops); | ||
Comments: | By: Digium Subversion (svnbot) 2009-06-04 16:14:54 Repository: dahdi Revision: 6675 U linux/trunk/drivers/dahdi/dahdi-base.c ------------------------------------------------------------------------ r6675 | sruffell | 2009-06-04 16:14:53 -0500 (Thu, 04 Jun 2009) | 7 lines dahdi-base: Fix bug in procfs handling. Fix bug in procfs handling where it was possible to get a warning in lib/vsprintf.c when reading from /proc/dahdi/x. Patch by: biohumanoid (closes issue DAHLIN-111) ------------------------------------------------------------------------ http://svn.digium.com/view/dahdi?view=rev&revision=6675 By: Shaun Ruffell (sruffell) 2009-06-04 16:17:33 Eerie timing...I ran into this again for the first time after making the original change to snprintf (I'm guilty), and then saw this issue. Anyway...hopefully after 2.2.0 is out, we'll see some movement towards sysfs. |