  Let $C$ be a smooth projective curve of genus $g \geq 11$, non-tetragonal,
considered in its canonical embedding in $\mathbf{P}^{g-1}$. We prove that $C$
is a linear section of an arithmetically Gorenstein normal variety $Y$ in
$\mathbf{P}^{g+r}$, not a cone, with $\dim(Y)=r+2$ and
$\omega_Y=\mathcal{O}_Y(-r)$, if the Gauss--Wahl map of $C$ has corank larger
or equal than $r+1$. This relies on previous work of Wahl and
Arbarello-Bruno-Sernesi; a partial converse is given via a theorem of Lvovski.
  We derive a similar result for $K3$ surfaces: Let $(S,L)$ be a polarized $K3$
surface of genus $g \geq 11$, non-tetragonal, and considered in its embedding
in $|L|^\vee \cong \mathbf{P}^g$. It is a linear section of a variety $Y$ as
above if $H^1(T_S \otimes L^\vee)$ has dimension larger or equal than $r$.
  We give various applications, including one to the following forgetful
modular map: Let $\mathcal{K}_g$ be the moduli space of polarized $K3$ surfaces
of genus $g$, and $\mathcal{KC}_g$ the space of pairs $(S,C)$ with $C$ a smooth
curve on $S$ and $(S,\mathcal{O}_S(C)) \in \mathcal{K}_g$; we consider the map
$c_g: (S,C) \in \mathcal{K}_g \mapsto C \in \mathcal{M}_g$. If $g \geq 11$, we
show that this map has smooth fibres over the locus of non-tetragonal curves,
with fibre-dimension over non-tetragonal $C$ the corank of the Gauss--Wahl map
of $C$ minus one.
