Linearly polarized small- x gluons in forward heavy-quark pair production