• Lars Ellenberg's avatar
    drbd: fix NULL deref in remember_new_state · 2b479766
    Lars Ellenberg authored
    The recent (not yet released) backport of the extended state broadcasts
    to support the "events2" subcommand of drbdsetup had some glitches.
    
    remember_old_state() would first count all connections with a
    net_conf != NULL, then allocate a suitable array, then populate that
    array with all connections found to have net_conf != NULL.
    
    This races with the state change to C_STANDALONE,
    and the NULL assignment there.
    
    remember_new_state() then iterates over said connection array,
    assuming that it would be fully populated.
    
    But rcu_lock() just makes sure the thing some pointer points to,
    if any, won't go away. It does not make the pointer itself immutable.
    
    In fact there is no need to "filter" connections based on whether or not
    they have a currently valid configuration.  Just record them always, if
    they don't have a config, that's fine, there will be no change then.
    Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
    Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
    Signed-off-by: default avatarJens Axboe <axboe@fb.com>
    2b479766
drbd_state.c 71.2 KB