TITLE: What conditions on a map of schemes guarantee that pullback of global sections is injective?
QUESTION [7 upvotes]: Consider a morphism of schemes $f: X \rightarrow Y$. What conditions on $f, X, Y$ are sufficient to guarantee that $H^0(Y, \mathscr{F}) \rightarrow H^0(X, f^* \mathscr{F})$ is injective for 

All $\mathscr{O}_Y$ modules $\mathscr{F}$?
All (quasi-)coherent $\mathscr{O}_Y$ modules $\mathscr{F}$?

A necessary condition for the first and second questions is that $f$ is surjective on closed points, since if $y \in Y \setminus f(X)$ is closed, we can take $\mathscr{F} = i_* \mathscr{O}_{k(y)}$. Then for any $x \in X$, $(f^* \mathscr{F})_x \simeq \mathscr{F}_{f(x)} = 0$, so $f^* \mathscr{F} = 0$. But $H^0(Y, \mathscr{F}) = k(y) \neq 0$. 
In the case that $\mathscr{F}$ is a locally free sheaf, $f$ is quasi-compact and $Y$ is reduced, this condition is also sufficient (and in fact, we only need $f$ to be dominant). To see this, the map $H^0(Y, \mathscr{F}) \rightarrow H^0(X, f^* \mathscr{F})$ is the global part of the canonical map of sheaves $\mathscr{F} \rightarrow f_* f^* \mathscr{F}$. Let $U$ be an affine open set such that $\mathscr{F}|_U \simeq \mathscr{O}_U$. Then on $U$, the canonical map is identified with the structure map $\mathscr{O}_U \rightarrow f_* \mathscr{O}_{f^{-1}(U)}$, which is injective since $\mathscr{O}_Y \rightarrow f_* \mathscr{O}_X$ is injective under these hypotheses.
Is this condition also sufficient for the first two questions? 
The affine version of the question is:

Which extensions of rings $A \subseteq B$ have the property that for any (resp. any finitely presented) $A$-module $M$, the map $M \rightarrow M \otimes_A B$ is injective? 

Since this always holds when $M$ is flat (which implies locally free in the finitely presented case), it seems natural to guess that we should require $B$ to be faithfully flat over $A$. However, I cannot find a way to use this property or a counterexample when $\mathrm{Spec} \ B \rightarrow \mathrm{Spec} \ A$ is surjective but $B$ is not flat over $A$.
EDIT I found a partial answer to this question in EGA IV-2 2.2.8: if $X, Y$ are arbitrary and $f$ is faithfully flat, then the canonical morphism is injective for all sheaves of quasi-coherent modules. This goes by identifying the global sections of $\mathscr{F}$ with morphisms $u: \mathscr{O}_Y \rightarrow \mathscr{F}$ and noting that the canonical map agrees with the map $u \rightarrow f^*(u)$. Faithful flatness says that if $f^*(u) = 0$ then $u = 0$. Actually, Remark 2.2.9 says that the $\mathscr{O}_Y$-module $\mathscr{F}$ does not need to be quasi-coherent for this proof to go through, although the proof is unclear to me. 
Also, Alex provided a counterexample in the case that $f$ is surjective but not flat. So now, the remaining question is:
If $X$ and $Y$ are "nice enough", does $f$ really have to be flat?
EDIT 2 Here is an easy counterexample when $X, Y$ are both smooth but not integral. Let $Y = \mathbf{A}^1$, $X = (\mathbf{A}^1 \setminus \{0\}) \sqcup \{0\}$, and $f$ the map given on rings by $k[x] \rightarrow k \times k[x,x^{-1}]$, $x \mapsto (0, x)$. Then let $\mathscr{F}$ be the coherent sheaf corresponding to the module $k[x]/x^2$. $f^* \mathscr{F} \simeq k$, since $(0,1) = x^2 * x^{-2}$ is killed. Then, $x$ maps to $0$ in the global section map.

REPLY [3 votes]: If $Y$ is Noetherian, so that any quasi-coherent sheaf can be written as a direct limit of coherent sheaves, then we see that the questions for coherent and quasi-coherent sheaves are equivalent.
Furthermore, the pushforward of a quasi-coherent sheaf on any open $U\subset Y$ is quasi-coherent on $Y$, and so the question for $f:X \to Y$
is equivalent to the analogous question for each $f^{-1}(U) \to U$, as $U$ ranges over the members of an open cover of $Y$, say an affine open cover.
If $f$ is quasi-compact (e.g. if $X$ is also Noetherian), then $f^{-1}(U)$ is a union of finitely many affines, and so we may find a surjective map $V \to f^{-1}(U)$ with affine source which is locally on the domain an open immersion, and so the question reduces to the case of $V \to U$, with both $U$ and $V$ affine.
In this case, as has basically been observed already, a sufficient condition
is that the corresponding ring map $A \to B$ admit a section (as a morphism
of $A$-modules), or even admits a section after a faithfully flat base-change.  (Thus if $X\to Y$ is faithfully flat, we get a positive answer, because if $A \to B$ is faithfully flat, then the base-changed morphism $B \to B\otimes_A B$ admits
a section, even as a map of rings, namely the multiplication map $B\otimes_A B \to B$.)
There are other cases where one necessarily has sections: e.g. Hochster's direct summand conjecture, whose proof was recently completed by Andre (see
here) shows that if $R \subset S$ is a finite extension with $R$ a Noetherian regular ring splits as a map of $R$-modules.  So if $X\to Y$ is a finite surjective morphism of Noetherian schemes, with $Y$ furthermore regular, then the question has a positive answer (but you should check that my reductions to the affine case are correct!).