  The existence of a stably stratified layer underneath the core-mantle
boundary (CMB) has been recently revived by corroborating evidences coming from
seismic studies, mineral physics and thermal evolution models. Such a layer
could find its physical origination either in compositional stratification due
to the accumulation of light elements at the top or the core or in thermal
stratification due to the heat flux becoming locally sub-adiabatic. The exact
properties of this stably-stratified layer, namely its size $\mathcal{H}_S$ and
the degree of its stratification characterised by the Brunt-V\"ais\"al\"a
frequency $N$, are however uncertain and highly debated. A stable layer
underneath the CMB can have crucial dynamical impacts on the geodynamo. Because
of the inhibition of the convective motions, a stable layer is expected to
primarily act as a low-pass filter on the magnetic field, smoothing out the
rapidly-varying and small-scale features by skin effect. To investigate this
effect more systematically, we compute 70 global geodynamo models varying the
size of the stably-stratified layer from 0 to 300~km and its amplitude from
$N/\Omega = 0$ to $N/\Omega \simeq 50$, $\Omega$ being the rotation rate. We
show that the penetration of the convective flow in the stably-stratified layer
is controlled by the typical size of the convective eddies and by the local
variations of the ratio $N/\Omega$. Using quantitative measures of the degree
of morphological semblance between the magnetic field obtained in numerical
models and the geomagnetic field at the CMB, we establish an upper bound for
the stable layer thickness $\mathcal{H}_s < (N/\Omega)^{-1} d_c$, $d_c$ being
the horizontal size of the convective flow at the base of the stable layer.
This defines a strong geomagnetic constraint on the properties of a
stably-stratified layer beneath the CMB.
