I am mostly writing this to correct my first comment. That comment addressed a completely different question: whether cohomology of a (split) generalized flag variety $G/B$ over a positive characteristic field $k$ equals cohomology of a (split) generalized flag variety of the same type over a characteristic $0$ field. For that question, which is not the question asked by the OP, the answer is positive by the Proper Base Change Theorem (you do not need to use affine pavings or "constancy of number").
Below I list some positive results about the question that the OP did ask in the classical types $A_n$, $B_n$,$C_n$, and $D_n$: in type $A_n$ and $C_n$, the cohomology is generated in degree $2$ in all characteristics, and for type $B_n$, $n\geq 3$, and for $D_n$, $n\geq 4$, the only "bad characteristc" is $2$. For the exceptional groups, there is an upper bound on the set of "bad primes" as in the answer by @NicholasKuhn.
Edit. The article of Demazure linked in the answer of @VictorPetrov proves much more: the ideal kernel is generated by Weyl invariants except in the case of bad primes. Also, the bad primes for type $G_2$ is $2$, the bad primes for type $E_6$, $E_7$, and $F_4$ are $2$ and $3$, and the bad primes for type $E_8$ are $2$, $3$, and $5$.
Notation. For every connected, simply connected topological space $M$, for every
coefficient ring $R$, the natural map $R\to H^0(M;R)$ is an isomorphism and $H^1(M;R)$ vanishes.
Denote by $q_{M;R}$ the natural homomorphism of graded $R$-algebras, $$q_{M;R}:\text{Sym}^*_R H^2(M;R) \to H^*(M;R).$$
Definition. The $R$-algebra $H^*(M;R)$ is $2$-generated if $q_{M;R}$ is surjective.
Let $G$ be a (split) semisimple complex Lie group. Denote by $T$ a maximal torus in $G$. Denote by $B$ a Borel subgroup of $G$ that contains $T$. The quotient space $B/T$ is isomorphic to affine space of complex dimension $m$ equal to the complex dimension of $G/B$. Thus the following surjection is an affine space bundle of relative dimension $m$, $$ \rho: G/T \to G/B. $$ Therefore, the pullback map $H^*(G/B;R)\to H^*(G/T;R)$ is an isomorphism. The conjugation action of the normalizer subgroup $N_G(T)$ on $G$ preserves left $T$-cosets. Thus, there is an induced action of $N_G(T)$ on $G/T$. By functoriality of cohomology, there is an induced action of $N_G(T)$ on $H^*(G/T;R)$. Of course the identity component $T$ of $N_G(T)$ acts trivially. Thus, there is an induced action on the graded $R$-algebra $H^*(G/B;R)$ by the Weyl group $W=N_G(T)/T$.
Notation. Denote by $\text{Sym}^*_R H^2(G/B;R)^W$ the graded $R$-subalgebra of Weyl-invariant elements of $\text{Sym}^*_R H^2(G/B;R)$. Denote by $\text{Sym}^*_R H^2(G/B;R)^W_+$ the graded ideal in this graded $R$-subalgebra generated by homogeneous Weyl-invariant elements of positive degree. Finally, denote by
$I_R$ the ideal in $\text{Sym}^*_R H^2(G/B;R)$ generated by $\text{Sym}^*_R H^2(G/B;R)^W_+$, $$I_R := \langle \left( \text{Sym}^*_R H^2(G/B;R)\right)^W_+ \rangle \subset \text{Sym}^*_R H^2(G/B;R).$$
Question. For which rings $R$ and for which type of simply connected, simple complex Lie group $G$ is the homomorphism $q_{G/B;R}$ surjective? Among those, for which rings does $\text{Ker}(q_{G/B;R})$ equal $I_R$?
Borel's Theorem. If $R$ contains $\mathbb{Q}$, then $q_{G/B;R}$ is surjective and the kernel ideal $\text{Ker}(q_{G/B;R})$ in the $r$-dimensional polynomial ring $\text{Sym}^*_{\mathbb{Q}} H^2(G/B;R)$ is a complete intersection ideal $I_R$ generated by the $r$ fundamental invariants $g_1,\dots,g_r$ of degrees $1+m_1,\dots,1+m_r$ with $1\leq m_1\leq \dots \leq m_r$. The fundamental invariants are primitive homogeneous elements in $\text{Sym}^*_{\mathbb{Z}}H^2(G/B;\mathbb{Z})^W_+$ such that the $R$-polynomial ring of Weyl-invariants equals the polynomial ring, $\left(\text{Sym}^*_R H^2(G/B;R)\right)^W=R[g_1,\dots,g_r].$
Poincaré Polynomial Corollary. The Poincaré polynomial $P_{\mathbb{Q}}(G/B,t) := \sum_{\ell=0}^{2n} b_{\ell}(G/B;\mathbb{Q})t^\ell$ equals $\prod_{i=1}^r (1+t^2+\dots + t^{2\ell}+\dots + t^{2m_i})$. In particular, the degrees of the fundamental invariants $m_i$ satisfy $m_1+\dots+m_r=m$ and $P_{\mathbb{Q}}(G/B,1) = (1+m_1)\cdots(1+m_r)$.
Note. Special cases of the corollary were known earlier to E. Cartan and to R. Brauer, but finally proved for all semisimple complex Lie groups by Borel and Chevalley. There is a wonderful history of this subject in the following article.
Pierre Cartier
A primer of Hopf algebras
http://preprints.ihes.fr/2006/M/M-06-40.pdf
The Bruhat Decomposition and the Universal Coefficients Theorem. The Bruhat decomposition of $G$ into double-$B$-cosets, $$G=\sqcup_{w\in W} BwB,$$ induces a partition of $G/B$ into locally closed subvarieties, $$G/B = \sqcup \mathbb{A}_w, \ \ \mathbb{A}_w:= (BwB)/B,$$ where each $\mathbb{A}_w$ is isomorphic to affine space $\mathbb{A}^{\ell(w)}$ for the Bruhat length $\ell(w)$ of $w$. In particular, the maximal length of an element equals $m$, the complex dimension of $G/B$.
Bruhat Decomposition. The homology of $G/B$ is a free $\mathbb{Z}$-module with one generator in degree $\ell(w)$ for each element $w\in W$. In particular, all nonzero homology groups have even degree, and $|W|$ equals $(1+m_1)\cdots (1+m_r)$. Moreover, the following cycle class map is an isomorphism of graded $\mathbb{Z}$-modules, $$\text{cl}:\text{CH}_*(G/B) \xrightarrow{\cong} H_*(G/B;\mathbb{Z}).$$
Proof. The first claim follows by the cellular decomposition of $G/B$ by the Bruhat cells. Thus $|W|$ equals $P(G/B,1)$, which equals $(1+m_1)\cdots (1+m_r)$ by the previous corollary. The final claim follows by Example 1.9.1, p. 23 of Fulton's Intersection theory. QED
Corollary 0. The integral cohomology of $G/B$ is a free Abelian group. Moreover, for every ring $R$, the following Change of Rings Homomorphism is an isomorphism, $$H^*(G/B;\mathbb{Z})\otimes_{\mathbb{Z}} R \to H^*(G/B;R).$$
Proof. This follows from the Universal Coefficients Theorem since the homology is a free Abelian group. QED
Corollary 1. The cokernel of $q_{G/B;\mathbb{Z}}$ is a graded Abelian group of finite order $N$. For every ring $R$, the homomorphism $q_{G/B;R}$ is surjective if and only if $N$ is invertible in $R$ (equivalently, each prime divisor of $N$ is invertible in $R$). In this case, the graded ideal $\text{Ker}(q_{G/B;R})$ has the same Poincaré polynomial as the ideal $\text{Ker}(q_{G/B;\mathbb{Q}})$ generated by $g_1,\dots,g_r$. If also $(g_1,\dots,g_r)$ form a regular sequence in the polynomial ring $\text{Sym}^*_R H^2(G/B;R)$, then $\text{Ker}(q_{G/B;R})$ equals the complete intersection ideal $\langle g_1,\dots,g_r\rangle$, which equals $I_R$.
Corollary 2. The kernel of $q_{G/B;\mathbb{Z}}$ contains $I_{\mathbb{Z}}$ as a subgroup of finite index $N'$. If both $N$ and $N'$ are invertible in $R$, then $q_{G/B;R}$ is surjective and $\text{Ker}(q_{G/B;R})$ equals $I_R$.
Leray Spectral Sequences. Consider a fiber bundle of topological spaces, $$\pi:E\to B,$$ with fibers $F_x$ for $x\in B$.
There is an induced Leray spectral sequence.
Leray Lemma. Assume that $B$ and a general fiber $F_x$ are connected and simply connected, that $H^*(B;R)$ is a free $R$-module of finite rank $b$, and that $H^*(F_x;R)$ is a free $R$-module of finite rank $f$. Then the free rank $e$ of $H^*(E;R)$ is at most $bf$, and $H^*(E;R)$ is a free $R$-module of rank $bf$ if and only if the Leray spectral sequence degenerates. In this case, if $H^*(E;R)$ is $2$-generated, then also $H^*(F_x;R)$ is $2$-generated. Conversely, if $H^*(B;R)$ and $H^*(F_x;R)$ are both $2$-generated and if $H^*(E;R)$ is a free $R$-module of rank $bf$, then also $H^*(E;R)$ is $2$-generated.
Proof. Since $B$ is simply connected, the Leray spectral sequence of $\pi$ is a stage-$2$ spectral sequence converging to the cohomology of $E$, $$E^{p,q}_2 = H^q(B;R)\otimes_R H^p(F_x;R) \Rightarrow H^{p+q}(E;R).$$ Thus $H^*(E;R)$ is a free $R$-module of rank $bf$, i.e., the free rank of $H^*(B;R)\otimes_R H^*(F_x;R)$, if and only if all of the differentials in the spectral sequence are zero.
When the spectral sequence degenerates, in particular all of the differentials out of $H^0(B;R)\otimes_R H^\ell(F_x;R)$ are zero. Thus, the natural pullback homomorphisms
$H^\ell(E;R)\to H^\ell(F_x;R)$ are surjective. Thus, we have a commutative square of homomorphisms of graded $R$-algebras, $$ \begin{array}{ccc} \text{Sym}^*_R H^2(E;R) & \xrightarrow{q_{E;R}} & H^*(E;R) \\ \downarrow & & \downarrow \\ \text{Sym}^*_R H^2(F_x;R) & \xrightarrow{q_{F_x;R}} & H^*(F_x;R) \end{array},$$ where the vertical arrows are surjective. If also $q_{E;R}$ is surjective, it follows that $q_{F_x;R}$ is surjective as well.
Conversely, suppose that the spectral sequence degenerates, and assume that both $H^*(B;R)$ and $H^*(F_x;R)$ are $2$-generated. The spectral sequence respects cup product with elements in $H^*(B;R)$. Thus, degeneration of the spectral sequence implies that $H^*(E;R)$ is a free graded $H^*(B;R)$-module, and any subset of $H^*(E;R)$ that maps to a generating set, resp. basis, of $H^*(F_x;R)$ as an $R$-module is a generating set, resp. basis, for $H^*(E;R)$ as an $H^*(B;R)$-module. By hypothesis, a generating set of $H^*(B;R)$ as an $R$-module is contained in the image of $q_{B;R}$, and thus its image in $H^*(E;R)$ is contained in the image of $q_{E;R}$.
By hypothesis, a generating set of $H^*(F_x;R)$ is contained in the image of $q_{F_x;R}$. Since the spectral sequence above degenerates, in particular, there is a short exact sequence, $$0 \to H^2(B;R)\to H^2(E;R)\to H^2(F_x;R)\to 0.$$ Thus, the generating set lifts to a subset of $H^*(E;R)$ that is in the image of $q_{E;R}$. Altogether, a generating set for $H^*(E;R)$ as an $R$-module is contained in the image of $q_{E;R}$. Therefore $q_{E;R}$ is surjective. QED
This suffices to settle the problem for many groups of classical type.
$A_n$ Type Result. For every $n$, in $A_n$-type the homomorphism $q_{G/B;R}$ is surjective and the kernel is generated by the fundamental invariants $g_1=s_2, \dots, g_n = s_{n+1}$, the elementary symmetric polynomials modulo $s_1$.
Proof. For every projective space $P$, the homomorphism $q_{P;R}$ is surjective. For $A_n$-type, since the flag variety is an iterated projective space bundle, by the Leray Lemma and by induction on the dimension, also $q_{G/B;\mathbb{Z}}$ is surjective. Moreover, since the First Fundamental Theorem of Invariant Theory holds on the integral level, the elementary symmetric polynomials $s_1,\dots,s_{n+1}$ are the generators of $I_{\mathbb{Z}}$. Therefore Borel's Theorem holds for every coefficient ring $R$ in $A_n$-type. QED
$C_n$ Type Result. For every $n\geq 1$, in $C_n$-type the homomorphism $q_{G/B;R}$ is surjective and the graded kernel ideal $\text{ker}(q_{G/B;R})$ has the same Poincaré polynomial as $\langle g_1,\dots,g_r\rangle \subset \text{Sym}^*_{\mathbb{Q}} H^2(G/B;\mathbb{Q})$.
Proof. This works in roughly the same way as $A_n$-type. By associating to every Borel the unique fixed point $x$ in $\mathbb{CP}^{2n-1}$, there is a fibration $\pi$ from $G/B$ to $\mathbb{CP}^{2n-1}$. When $n$ equals $1$, so that actually we are in type $C_1=A_1$, this complex projective space is the flag variety and the result holds by the argument for $A_n$-type.
Thus, by way of induction, assume that $n>1$, and assume that the result has been proved for $C_{n-1}$-type. In particular, the fibers $F_x$ of $\pi$ are flag varieties of type $C_{n-1}$. Thus, $H^*(F_x;R)$ is $2$-generated. Moreover, the sum of all Betti numbers for $G/B$ equals the order of the Weyl group (elements of the Weyl group index the Bruhat cells). Since the Weyl group in $C_n$-type is a semidirect product of the symmetric group $\mathfrak{S}_n$ and a free $\mathbb{Z}/2\mathbb{Z}$-module of rank $n$, it follows that the fraction of orders of the Weyl group for $C_n$-type and for $C_{n-1}$-type equals $2n$. This precisely equals the sum of all Betti numbers for $\mathbb{CP}^{2n-1}$ (the Euler characteristic of $\mathbb{CP}^{2n-1}$ equals $2n$). Thus, by the Leray Lemma, $q_{G/B;R}$ is surjective. By induction on $n$, for every flag variety of $C_n$-type, $q_{G/B;R}$ is surjective. QED
I have not checked whether the fundamental invariants generate the ideal $\text{Ker}(q_{G/B;\mathbb{Z}})$.
$B_n$ Type Result. For every $n\geq 2$, in $B_n$-type the homomorphism $q_{G/B;R}$ is surjective provided that $2$ is invertible in $R$.
Proof. This works in a similar way to type $C_n$. The fibration is now over the quadric hypersurface $Q$ of dimension $2n-1$ and degree $2$ in $\mathbb{CP}^{2n}$ parameterizing isotropic points for the symmetric, nondegenerate bilinear form on $\mathbb{C}^{2n+1}$. For $n=1$, we have $B_1=A_1$, and the result holds by the argument for $A_n$-type.
Thus, by way of induction, assume that $n>1$, and assume that the result has been proved for $B_{n-1}$-type. By the Lefschetz Hyperplane Theorem, again $Q$ has positive Betti numbers only in even degree, and the sum of the Betti numbers of $Q$ equals $2n$. However, the cohomology ring is not generated integrally by $c_1(\mathcal{O}(1))$. It is generated by $c_1(\mathcal{O}(1))$ over any ring $R$ in which the integer $2$ is invertible. Thus, assume that $2$ is invertible in $R$.
As in the $C_n$-type, the integer $2n$ equals the fraction between the orders of the Weyl group for $C_n$-type and for $C_{n-1}$-type. Thus, as in the $C_n$-type, the Leray Lemma implies surjectivity of $q_{G/B;R}$. Therefore, by induction on $n$, for every group of $B_n$-type and for every ring $R$ in which $2$ is invertible, the homomorphism $q_{G/B;R}$ is surjective. QED
Strangely, I seem to get a different conclusion than Allen Knutson. The simply connected group of $B_2$-type is isomorphic to the simply connected group of $C_2$-type. Thus, using the $C_2$-type argument above, I conclude that $q_{G/B;\mathbb{Z}}$ is surjective in $B_2$-type. It could well be that $q_{G/B;\mathbb{Z}}$ fails to be surjective in $B_n$-type beginning with $n\geq 3$, i.e., orthogonal groups for odd-dimensional inner product spaces of dimension $\geq 7$.
I have not checked whether the fundamental invariants generate the ideal $\text{Ker}(q_{G/B;\mathbb{Z}})$.
$D_n$ Type. The previous induction argument breaks down. For the corresponding quadric hypersurface of dimension $2n-2$ in $\mathbb{CP}^{2n-1}$, even the rational cohomology ring is not generated in degree $2$; there is an extra primitive cohomology class in the middle degree. However, there is a way to reduce the result for $D_n$-type to the result for $B_n$-type.
Let $(V,\beta:V\xrightarrow{\cong} V^\vee)$ be a symmetric bilinear pairing on a complex vector space $V$ of dimension $2n+1$, so that the corresponding group $G'=\text{Spin}(V,\beta)$ is a simply connected, simple complex Lie group of type $B_n$. The set of nonzero isotropic lines in $V$ form the points of a smooth quadric hypersurface $Q$ in $\mathbb{P}(V)\cong \mathbb{CP}^{2n}$. Inside the dual projective space $\mathbb{P}(V^\vee)$ parameterizing hyperplanes $H=\mathbb{P}(W_{2n})$ in $\mathbb{P}(V)$, there is a dual quadric $Q^\vee$ parameterizing tangent hyperplanes. This is a smooth quadric hypersurface. There is a degree $2$ branched cover $\overline{X}\to \mathbb{P}(V^\vee)$ branched over $Q^\vee$. The open complement $X$ of the branch locus is the universal cover of $\mathbb{P}(V^\vee)\setminus Q^\vee$, whose fundamental group is cyclic of order $2$. The cohomology of $X$ is one of the basic invariants that arises in the theory of vanishing cycles. Either by reviewing that theory (in SGA 7_2, Exposé XII, Table 7, p. 81) or by using the Gysin sequence for the pair $(\overline{X},Q^\vee)$, it follows that $H^*(X;R)$ is a free $R$-module of rank $2$ with one generator in degree $0$, $H^0(X;R)=R$, and with one generator in degree $2n$, $H^{2n}(X;R) \cong R$.
Denote by $F_\beta(1,\dots,n;V)$ the generalized flag variety parameterizing $\beta$-isotropic flags in $V$, say $(U_1\subset \dots \subset U_n\subset V)$. The natural action of $G'$ on $F_\beta(1,\dots,n;V)$ is transitive, and the stabilizers of points are Borel subgroups $B'$ of $G'$. Thus, $G'/B'$ is isomorphic to $F_\beta(1,\dots,n;V)$.
Now define $E\subset F_\beta(1,\dots,n;V)\times (\mathbb{P}(V)^\vee \setminus Q^\vee)$ to be the incidence correspondence parameterizing flags $(U_1\subset \dots \subset U_n \subset W_{2n} \subset V)$ such that $(U_1\subset \dots \subset U_n\subset V)$ is an isotropic flag and such that $\mathbb{P}(W_{2n})\subset \mathbb{P}(V)$ is a hyperplane whose intersection with $Q$ is smooth and contains $\mathbb{P}(U_n)$. There is a forgetful map, $$\rho:E\to F_\beta(1,\dots,n;V).$$ By extending a basis for $U_n$ first to a basis for the orthogonal complement $U_n^\perp$, and then to all of $V$, there exists a system of linear coordinates $(x_1,\dots,x_n,y,z_1,\dots,z_n)$ for $V$ such that $U_{n-\ell}$ equals $\text{Zero}(y,z_1,\dots,z_n,x_n,\dots,x_{n+1-\ell})$, such that $U_n^\perp$ equals $\text{Zero}(z_1,\dots,z_n)$, and such that the quadratic form of $\beta$ equals $x_1z_1+\dots + x_nz_n + y^2$. From this, it is straightforward to compute that $\rho$ is an affine space bundle of relative dimension $n$. In particular, the pullback map on cohomology is an isomorphism, $$H^*(\rho;R):H^*(G'/B';R)\xrightarrow H^*(E;R).$$
Now consider the other projection, to $\mathbb{P}(V)^\vee \setminus Q^\vee$. Since $E$ is simply connected, this morphism factors through the universal cover $X$, $$\pi:E\to X.$$ For each $[W]\in \mathbb{P}(V^\vee)\setminus Q^\vee$, denote by $\beta_W$ the restriction of $\beta$ to $W$. Since $[W]$ is in the complement of $Q^\vee$, this restriction is nondegenerate. The isotropic Grassmannian $F_{\beta_W}(n;W)$ has two connected components, and the fiber over $[W]$ in $X$ is naturally bijective to the set of connected components. Of course $U_n$ is one of these isotropic subspaces, thus it is contained in one of the connected components, and this induces the map $\pi$. For a fixed choice of $[W]$ and connected component, the corresponding fiber $F_W$ of $\pi$ is the generalized flag variety $G/B$ for the simply connected, complex Lie group $G=\text{Spin}(W,\beta_W)$ of type $D_n$.
$D_n$ Type Result. For every $n\geq 4$, in $D_n$-type the homomorphism $q_{G/B;R}$ is surjective provided that $2$ is invertible in $R$.
Proof. The $R$-module $H^*(G'/B';R)$ is a free $R$-module of rank equal to the size of the Weyl group $|W'|$. Thus, the same holds for $H^*(E;R)$. The base $X$ of $\pi$ is a connected, simply connected manifold with $H^*(X;R)$ a free $R$-module of rank $2$. Finally, the fibers $F_W$ of $\pi$ have cohomology $H^*(F_W;R) = H^*(G/B;R)$ a free $R$-module of rank equal to the size of the Weyl group $|W|$. Finally, $|W'|$ equals $2|W|$ for groups $G'$ and $G$ of respective types $B_n$ and $D_n$. Thus, by the Leray Lemma, the spectral sequence associated to $\pi$ degenerates. If $2$ is invertible in $R$, then $H^*(G'/B';R)$ is $2$-generated by the $B_n$-type result. Thus, by the Leray Lemma, also $H^*(F_W;R)$ is $2$-generated, i.e., $H^*(G/B;R)$ is $2$-generated for $G$ of type $D_n$. QED
It is interesting to examine this spectral sequence in relation to the degrees of the fundamental invariants of type $B_n$ and $D_n$. There is an invariant of degree $n$ in type $D_n$ that makes the cohomology in cohomological degree $2n$ of rank $1$ less than the corresponding cohomology in $B_n$-type. Of course, by the spectral sequence, the nonzero generator of $H^{2n}(X;R)$ explains the discrepancy.