Solution (source code)

= Solution

Take bundle charts $\Phi_i:E|_{U_i}\to U_i\times\mathbb R^r$ with transition functions $g_{ij}:U_i\cap U_j\to GL(r,\mathbb R)$. Over $f^{-1}(U_i)$ define
$$
\widetilde\Phi_i(p,v)=(p,\operatorname{pr}_2\Phi_i(v)).
$$
Their transition functions are $g_{ij}\circ f$, so they give the fibre product
$$
f^*E=\coprod_{p\in M}E_{f(p)}
$$
a smooth manifold and make its projection to $M$ a rank-$r$ <pullback vector bundle>.

A local section $s:U\to E$ determines the section
$$
p\longmapsto(p,s(f(p)))
$$
of $f^*E$ over $f^{-1}(U)$. It is unique with second component $s\circ f$.