[asterisk-bugs] [DAHDI-linux 0018760]: [patch] inconsistent read from /proc/dahdi if size changes

Asterisk Bug Tracker noreply at bugs.digium.com
Sun Feb 20 17:13:22 CST 2011


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=18760 
====================================================================== 
Reported By:                tzafrir
Assigned To:                
====================================================================== 
Project:                    DAHDI-linux
Issue ID:                   18760
Category:                   General
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     confirmed
JIRA:                        
Reviewboard Link:            
====================================================================== 
Date Submitted:             2011-02-07 09:29 CST
Last Modified:              2011-02-20 17:13 CST
====================================================================== 
Summary:                    [patch] inconsistent read from /proc/dahdi if size
changes
Description: 
Reading from a file should be done in a loop, testing for extra output.
If at the time of this read loop the "size" of /proc/dahdi/N increases,
you get extra output.

I have applied the attached patch, which simulates such a change by adding
some extra text (" CHEATING") to each line.

The effect:
# cat /proc/dahdi/1
Span 1: XBUS-00/XPD-00 "Xorcom XPD https://issues.asterisk.org/view.php?id=0/00:
BRI_NT"

           1 XPP_BRI_NT/00/00/0
           2 XPP_BRI_NT/00/00/1
           3 XPP_BRI_NT/00/00/2
P_BRI_NT/00/00/2  CHEATING

# cat /proc/dahdi/9
Span 9: XBUS-00/XPD-10 "Xorcom XPD https://issues.asterisk.org/view.php?id=0/10:
FXS" (MASTER)

          25 XPP_FXS/00/10/0
          26 XPP_FXS/00/10/1
          27 XPP_FXS/00/10/2
          28 XPP_FXS/00/10/3
          29 XPP_FXS/00/10/4
          30 XPP_FXS/00/10/5
          31 XPP_FXS/00/10/6
          32 XPP_FXS/00/10/7
HEATING
          31 XPP_FXS/00/10/6  CHEATING
          32 XPP_FXS/00/10/7  CHEATING

# strace -eread cat /proc/dahdi/1 >/dev/null
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1\0004\0\0\0\4"...,
512) = 512
read(3, "Span 1: XBUS-00/XPD-00 \"Xorcom XP"..., 4096) = 131
read(3, "P_BRI_NT/00/00/2  CHEATING\n"..., 4096) = 27
read(3, ""..., 4096)                    = 0

# strace -eread cat /proc/dahdi/9 >/dev/null
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1\0004\0\0\0\4"...,
512) = 512
read(3, "Span 9: XBUS-00/XPD-10 \"Xorcom XP"..., 4096) = 243
read(3, "HEATING\n\t  31 XPP_FXS/00/10/6  CH"..., 4096) = 72
read(3, ""..., 4096)                    = 0

We would have expected the second read to return 0. But setting 'eof=1'
does not provide this desired effect.
====================================================================== 

---------------------------------------------------------------------- 
 (0132208) svnbot (reporter) - 2011-02-20 17:13
 https://issues.asterisk.org/view.php?id=18760#c132208 
---------------------------------------------------------------------- 
Repository: dahdi
Revision: 9770

U   linux/trunk/drivers/dahdi/dahdi-base.c

------------------------------------------------------------------------
r9770 | tzafrir | 2011-02-20 17:13:21 -0600 (Sun, 20 Feb 2011) | 13 lines

replace old proc interface by modern seq_file

Switch to using the newer seq_file interface for procfs. Fixes a
race when you read the "file" while its size increases (e.g. the span
enters an alarm state).

Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Shaun Ruffell <sruffell at digium.com>
Acked-By: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

(closes issue https://issues.asterisk.org/view.php?id=18760)
Patches:
      0001-DAHDI-linux-trunk-replace-old-proc-interface-by-mode.patch
uploaded by tzafrir (license 46)
------------------------------------------------------------------------

http://svn.digium.com/view/dahdi?view=rev&revision=9770 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-02-20 17:13 svnbot         Checkin                                      
2011-02-20 17:13 svnbot         Note Added: 0132208                          
======================================================================




More information about the asterisk-bugs mailing list