6. Let the polynomial $a_{0} x^{n}+a_{1} x^{n-1}+a_{2} x^{n-2}+\cdots+a_{n-1} x+a_{n}$ have all real roots, where $a_{i}=1$ or -1, $i=0,1, \cdots, n$, find all polynomials with this property.
6. Let's first consider $a_{0}=1$, and suppose its $n$ real roots are $x_{1}, x_{2}, \cdots, x_{n}$, then
$$
\begin{array}{c}
x_{1}+x_{2}+\cdots+x_{n}=-a_{1}, \\
x_{1} x_{2}+x_{1} x_{3}+\cdots+x_{n-1} x_{n}=a_{2}, \\
x_{1} x_{2} \cdots x_{n}=(-1)^{n} a_{n} .
\end{array}
$$

Thus, $x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}=\left(-a_{1}\right)^{2}-2 a_{2}=1-2 a_{2} \geqslant 0$, so $a_{2} \leqslant \frac{1}{2}$, hence $a_{2}=-1$.
Thus, $x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}=3$.
Also, $x_{1}^{2} \cdot x_{2}^{2} \cdots x_{n}^{2}=1$, by the AM-GM inequality we get: $3 \geqslant n \sqrt[n]{x_{1}^{2} \cdot x_{2}^{2} \cdots x_{n}^{2}}=n$, so $n=1,2,3$. Therefore, the polynomials that meet the requirements are as follows: $\pm(x-1), \pm(x+1), \pm\left(x^{2}+x-1\right), \pm\left(x^{2}-x+1\right), \pm\left(x^{3}+\right.$
$$
\left.x^{2}-x-1\right), \pm\left(x^{3}-x^{2}-x+1\right) .
$$