It is shown that substitution of C or N for O recently proposed as a way to create ferromagnetism in otherwise nonmagnetic oxide insulators is curtailed by formation of impurity pairs, and the resultant C2 spin=1 dimers as well as the isoelectronic N2(2+) interact antiferromagnetically in p-type MgO. For C-doped ZnO, however, we demonstrate using the Heyd-Scuseria-Ernzerhof hybrid functional that a resonance of the spin-polarized C2 ppπ* states with the host conduction band results in a long-range ferromagnetic interaction. Magnetism of open-shell impurity molecules is proposed as a possible route to d(0)-ferromagnetism in oxide spintronic materials.