The scholars have stated that gheebah is permitted in certain situations:
1- Complaining. It is permissible for the one who has been wronged to complain to the ruler or judge and others who have the authority or ability to settle the score with the one who wronged him.
2- Seeking help to change evil and bring the sinner back to the right path, so he may say to the one who he hopes is able to do something: “So and so is doing such and such; tell him not to do it.”
3- Seeking advice or a fatwa (religious ruling), by saying to the mufti (scholar), “So and so/my father/my brother has wronged me by doing such and such, does he have the right to do that? How can I solve this problem and ward off his harm from me?”
4- Warning the Muslims of someone’s evil, such as highlighting the weakness of some reporters or witnesses or authors. That also includes seeing someone buying faulty goods, or someone keeping company with one who is a thief or adulterer, or giving a female relative of his to such a man in marriage, and the like. You should tell them about that by way of sincere advice, not with the aim of causing harm and spreading mischief.
5- If a person openly commits evil or follows bid’ah (innovation), such as drinking alcohol and seizing people’s wealth unlawfully, it is permissible to speak of what he is doing openly, but it is not permissible to speak against him any other way, unless it is for another reason.
6- For identification, if someone is known by a nickname such as the dim-sighted one, or the blind man or the one-eyed or the lame one, it is permissible to identify him as such, but it is haraam (impermissible) to mention that by way of belittling him, and if it is possible to identify him in some other way, that is better.
It says in Fatawa al-Lajnah al-Daimah li’l-Ifta: Speaking about a person in his absence is permissible in certain situations as indicated by shar’I Islamic legal) evidence, if there is a need for that, such as if someone consults you about arranging a marriage to him, or entering into a business partnership with him, or if someone complains to the authorities to put a stop to his wrongdoing. In that case there is nothing wrong with saying things about him that he may not like to be said, because there is an interest to be served by that. One of the scholars summed up in two lines of poetry the situations in which it is permissible to talk about a person in his absence, and said:
Criticizing is not gheebah in six (cases) – complaining, identifying, warning,
When the person is committing evil openly, when advice is sought, and when one is asking for help in removing an evil.
Source : Islamqa