Anyone convicted of any sex crime involving children is the lowest of the low in prison. The other criminals need to feel they're better than someone. Possession of child pornography or other lesser crimes doesn't make a difference; everyone goes in the single category of "pedos".
It is impossible to keep the other prisoners from knowing, because the guards have access to that information, and they'll tell. Though there are good eggs among the guards, others will harass the sex offender.
If one's safety is at risk, you can be put in the Special Housing Unit, which is somewhat more safe. But it comes with a significant loss of privileges - no library for example. And it's not total security.
On the other hand drugs, especially opiates and weed, are easier to get than the public realizes, though they cost ,ore than on the street. Guards and staff, who are not searched, bring them in.