[Home]

Summary:ASTERISK-13760: [patch] Race condition in ast_db_get()
Reporter:Makoto Dei (makoto)Labels:
Date Opened:2009-03-16 20:07:29Date Closed:2009-03-17 00:54:19
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) astdb-race.patch
Description:ast_db_get() may retrieve a wrong value because the data are copied
to the variable value after dblock is unlocked.
The copy should be done before unlock.

This can be reproduced on our cutomer's environment which is based on
Asterisk 1.2.18. I don't test it on the 1.4.x yet, but I believe that
this can be reproduced also on Asterisk 1.4 or later.

Attached patch will fix the problem.
Comments:By: Tilghman Lesher (tilghman) 2009-03-17 00:47:20

Okay, looks like I was a bit too hasty.  I will have this committed shortly.

By: Digium Subversion (svnbot) 2009-03-17 00:50:52

Repository: asterisk
Revision: 182449

U   branches/1.4/main/db.c

------------------------------------------------------------------------
r182449 | tilghman | 2009-03-17 00:50:52 -0500 (Tue, 17 Mar 2009) | 7 lines

Fix race in astdb
The underlying db1 implementation does not fully isolate the pages retrieved
from astdb, so the lock protecting accesses needs to be extended until the
copy from the shared memory structure is done.
(closes issue ASTERISK-13760)
Reported by: makoto

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=182449

By: Digium Subversion (svnbot) 2009-03-17 00:51:55

Repository: asterisk
Revision: 182450

_U  trunk/
U   trunk/main/db.c

------------------------------------------------------------------------
r182450 | tilghman | 2009-03-17 00:51:54 -0500 (Tue, 17 Mar 2009) | 14 lines

Merged revisions 182449 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r182449 | tilghman | 2009-03-17 00:50:52 -0500 (Tue, 17 Mar 2009) | 7 lines
 
 Fix race in astdb
 The underlying db1 implementation does not fully isolate the pages retrieved
 from astdb, so the lock protecting accesses needs to be extended until the
 copy from the shared memory structure is done.
 (closes issue ASTERISK-13760)
  Reported by: makoto
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=182450

By: Digium Subversion (svnbot) 2009-03-17 00:53:18

Repository: asterisk
Revision: 182451

_U  branches/1.6.0/
U   branches/1.6.0/main/db.c

------------------------------------------------------------------------
r182451 | tilghman | 2009-03-17 00:53:18 -0500 (Tue, 17 Mar 2009) | 21 lines

Merged revisions 182450 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r182450 | tilghman | 2009-03-17 00:51:54 -0500 (Tue, 17 Mar 2009) | 14 lines
 
 Merged revisions 182449 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r182449 | tilghman | 2009-03-17 00:50:52 -0500 (Tue, 17 Mar 2009) | 7 lines
   
   Fix race in astdb
   The underlying db1 implementation does not fully isolate the pages retrieved
   from astdb, so the lock protecting accesses needs to be extended until the
   copy from the shared memory structure is done.
   (closes issue ASTERISK-13760)
    Reported by: makoto
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=182451

By: Digium Subversion (svnbot) 2009-03-17 00:54:08

Repository: asterisk
Revision: 182452

_U  branches/1.6.1/
U   branches/1.6.1/main/db.c

------------------------------------------------------------------------
r182452 | tilghman | 2009-03-17 00:54:08 -0500 (Tue, 17 Mar 2009) | 21 lines

Merged revisions 182450 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r182450 | tilghman | 2009-03-17 00:51:54 -0500 (Tue, 17 Mar 2009) | 14 lines
 
 Merged revisions 182449 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r182449 | tilghman | 2009-03-17 00:50:52 -0500 (Tue, 17 Mar 2009) | 7 lines
   
   Fix race in astdb
   The underlying db1 implementation does not fully isolate the pages retrieved
   from astdb, so the lock protecting accesses needs to be extended until the
   copy from the shared memory structure is done.
   (closes issue ASTERISK-13760)
    Reported by: makoto
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=182452

By: Digium Subversion (svnbot) 2009-03-17 00:54:17

Repository: asterisk
Revision: 182453

_U  branches/1.6.2/
U   branches/1.6.2/main/db.c

------------------------------------------------------------------------
r182453 | tilghman | 2009-03-17 00:54:17 -0500 (Tue, 17 Mar 2009) | 21 lines

Merged revisions 182450 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r182450 | tilghman | 2009-03-17 00:51:54 -0500 (Tue, 17 Mar 2009) | 14 lines
 
 Merged revisions 182449 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r182449 | tilghman | 2009-03-17 00:50:52 -0500 (Tue, 17 Mar 2009) | 7 lines
   
   Fix race in astdb
   The underlying db1 implementation does not fully isolate the pages retrieved
   from astdb, so the lock protecting accesses needs to be extended until the
   copy from the shared memory structure is done.
   (closes issue ASTERISK-13760)
    Reported by: makoto
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=182453