git: socket: Avoid possible race between netmsg_so_notify() and sowakeup()

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Fri Jul 19 02:24:59 PDT 2013


commit ccae972d65bbf7c434fd030a3f6dd886e57cbc3d
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Fri Jul 19 16:40:07 2013 +0800

    socket: Avoid possible race between netmsg_so_notify() and sowakeup()
    
    The race is concerning SSB_MEVENT setup and testing.  Originally:
    
                 CPU X                          CPU Y
        get token                                 :
        if (predict cond false) {                 :
               :                        set predict cond true
               :                        if (SSB_MEVENT) {
               :                            get token
               :                            wake up notifies
               :                            rel token
               :                        }
            queue notify                          :
            set SSB_MEVENT                        :
        }                                         :
        rel token
    
    This commit always set SSB_MEVENT before predict testing, after getting
    the socket token, so the race could be avoided.
    
    Reviewed-by: dillon@

Summary of changes:
 sys/kern/uipc_msg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ccae972d65bbf7c434fd030a3f6dd886e57cbc3d


-- 
DragonFly BSD source repository



More information about the Commits mailing list