"Tricky one. The obligation to render aid to survivors has to be balanced with the risk to ones own crew.
What exactly is the risk to an SSN's crew off Sri Lanka, from Iranian forces back in the motherland ?"
Well you can can hardy take them all on board - numbers for a start - and they're not going to be happy - in fact they will be mad as hell. You could signal the sinking immediately to all vessels and hang around until someone turned up but you might be worried about just who that someone might be.
I'm afraid we finish up with the same issues as the "Lusitania" sinking in WW1. Submarines are different