AFAIK, it's still generally safe. But a stock engine is not designed to that kind of stress (revving past 5K) if you do it all the time. Revving up to the redline is done only in emergency cases (e.g. extreme overtaking). It won't hurt the engine big time if only do it once in a while but like what archie123456789 said, it would accelerate normal wear and tear.

Notice weird vibrations on the 5K++ rpm band? A stock car is generally designed to run only 60-70% of it's maximum speed.