On the second law of thermodynamics in modified Gauss–Bonnet gravity