Friendly Fire: can troops defend themselves?

Are UK / US troops allowed to defend themselves when they are targeted by their own side?

Would you have to wait to be fired upon, or would a fighter pilot who became aware that a “friendly” anti-aircraft position had a lock on her be permitted to fire pre-emptively to defend herself?

Is there a difference between air and land forces?

I was a Stinger antiaircraft missile officer. If a friendly aircraft bomb or stafed a friendly position, I would not fire a revenge shot. If that aircraft turned again into an aggressive approach, I could have taken it out.

The Right of Self Defense is NEVER denied.

Last week an F-16 took out a Patriot battery that had locked onto it. No one was hurt. I believe it occurred just a day or two after that Tornado was hit by a Patriot. Cite