GMASS ultradeep spectroscopy of galaxies at z ~ 2 . I. The stellar metallicity