In 1 Cor. 9:27, Paul mentions THE BODY, NOT THE SPIRIT. He is not writing about Salvation.
The Greek word translated ‘castaway’ is ‘adokimos’ and means ‘not standing the test, not approved’.
The only test for salvation by Jesus’ own words is belief (John 3:16, 6:28-29, 6:37-40) and the only way to be disqualified is to refuse to believe on Christ (John 3:18) .
In 1 Cor. 9, Paul compared a believer’s life to an athlete’s attempts to achieve victory in a race. Both involve bringing one’s body into subjection. This is not a precondition for salvation, but a way to achieve victory OVER THE FLESH (wrong beliefs in THE MIND) AFTER we’ve been saved.
So, this verse is not about salvation, but about living right outwardly. It in no way teaches against the eternal security of a believer.