And what the hale is "extra-legal punishment"? I don't even know what that means since you just made it up.
One doesn't get "caught up" in the criminal justice system like a cold you "caught" from a co-worker. You have to commit a crime, like trying to murder a cop.
Whatever else happens in prison has nothing to do with the legal system. It has to do with the reality of being in prison.
Doing time for criminal conviction is supposed to be bad by definition. It's not supposed to feel good.
What happens in prison is the responsibility of those who control the prisons. They are supposed to keep prisoners reasonably safe and free from harm by other prisoners.
All too often, the management of prisons is effectively turned over to prisoners, or the prison management effectively use some prisoners to inflict extra-legal punishment on other prisoners.
If you ever saw the movie “The Shankshaw Redemption” it is a vision of an extreme extra-legal prison system run for the benefit of the Warden and guards. It was fiction; but many real world prisons, especially in third world h@ll-holes, are run in similar fashion. Our system is supposed to be ruled by law.
Extra-legal punishment is punishment outside of the law.
https://www.quora.com/What-is-extralegal-punishment