I don't think that Gregson is some sort of hero and he did some shady stuff with the planted evidence so if it was about Sherlock just tinkering with a case I'd say that Gregson had no place to talk. But Sherlock clearly wasn't upfront with Gregson about why he was back in New York and his personal history and while drug users of course deserve to have jobs again etc, it would've been good to know for his employer because in that line of work and so soon in his rehabilitation (or in the middle of it), it could've impeded his judgement or caused him to relapse and then he'd have been a liability.

But Gregson knew all that and trusted Sherlock enough to consult him and accepted that Sherlock wasn't ready to talk about it and he didn't even push for the subject although Sherlock kind of lied to him about it (by omitting it).

So yeah, neither is perfect and I don't approve of violence or something but for Sherlock to do something like that (torturing and almost murdering someone - I mean that's not even comparable to planting evidence and it wasn't even Gregson who did it although he covered for it) and then have the gall to come back as if nothing happened, knowing that he's kind of indispensable for the NYPD because he's the smartest~ and greatest~, giving Gregson basically no choice while not even apologizing or feeling that what he had done was wrong (as Joan also figured out), I can see why Gregson felt the need to punch him. Logically, Sherlock was of course right but he could've benefitted from some humble pie in that situation.

I don't think it was Sherlock's drug problem that was supposed to be the issue wrt trust, it was the fact that he wasn't honest with Gregson about it until he was pushed to be. Iirc, he even outright lied to him about what he was up to prior to being hired by the NYPD.