Hint. The gravitational force on mass $m$ at distance $x$ from the centre of earth, towards the center, is $$\frac{G(M(x/R)^3)m}{x^2}=\frac{GMmx}{R^3}$$ (the earth attracts a point inside it with a force proportional to its distance from the centre).
Hence the motion of the mass obeys the linear differential equation $$mx''=-\frac{GMmx}{R^3}$$ that is $$x''+\frac{GM}{R^3}\cdot x=0.$$ By solving it, we obtain that the solution is periodic with a period given by $$T=2\pi\sqrt{\frac{R^{3}}{{GM}}}=2\pi\sqrt{\frac{R}{g}}\approx 6.28\sqrt{\frac{6400\cdot 10^3}{9.81}}\approx 5072\, sec.$$ Note that $T$ does not depend on where the tunnel is located (its distance from the center of the earth).