[Home]

Summary:DAHLIN-00231: [patch] inconsistent read from /proc/dahdi if size changes
Reporter:Tzafrir Cohen (tzafrir)Labels:
Date Opened:2011-02-07 09:29:08.000-0600Date Closed:2011-02-20 17:13:23.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 0001-DAHDI-linux-trunk-replace-old-proc-interface-by-mode.patch
( 1) proc_cheating.diff
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 #00/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 #00/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.
Comments:By: Shaun Ruffell (sruffell) 2011-02-07 14:13:44.000-0600

Looks good to me...feel free to add

Acked-by: Shaun Ruffell <sruffell@digium.com>


(I didn't test it on 2.6.9-89.0.25.EL-smp-i686 but I made sure it compiled)



By: Digium Subversion (svnbot) 2011-02-20 17:13:22.000-0600

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@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-By: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

(closes issue DAHLIN-231)
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