We study azimuthal asymmetries in heavy quark pair production in unpolarized electron-proton and proton-proton collisions, where the asymmetries originate from the linear polarization of gluons inside unpolarized hadrons. We provide cross section expressions and study the maximal asymmetries allowed by positivity, for both charm and bottom quark pair production. The upper bounds on the asymmetries are shown to be very large depending on the transverse momentum of the heavy quarks, which is promising especially for their measurements at a possible future Electron-Ion Collider or a Large Hadron electron Collider. We also study the analogous processes and asymmetries in muon pair production as a means to probe linearly polarized photons inside unpolarized protons. For increasing invariant mass of the muon pair the asymmetries become very similar to the heavy quark pair ones. Finally, we discuss the process dependence of the results that arises due to differences in color flow and address the problem with factorization in case of proton-proton collisions.