I agree that Thermodynamics involving E & M fields is complicated. A signal is that no previous answer identifies the real issue.
The crucial point is that in expressions like $$ dU = T dS +H dM + \mu dN $$ or $$ dG = -S dT -M dH + \mu dN, $$ $U$ and $G$ are not the total internal energy and Gibbs free energy, but only the part depending on the magnetization density of the thermodynamic potentials (see, for instance, Landau&Lifshitz, Electrodynamics of continuous media. In both expressions, a missing term is required to provide the physical variation of energy. It is the differential of the energy of the applied magnetic field in the absence of the sample ( $H dH$ in $dU$ or $-HdH$ in $dG$ ).
The addition of such a term shows that the proper convexity condition requires $$ 1 + \chi_T \geq 0. $$ Thus accommodating para/ferro-magnets ($\chi_T >0$) and diamagnets ($-1<\chi_T <0$).