Theory of spin Hall magnetoresistance