If a dog's eyes are rolling back, first, stay calm.
If it's due to a mild seizure, keep the dog in a safe place to prevent it from hurting itself during the episode. Don't try to restrain it forcefully. After the seizure stops, contact a veterinarian immediately to have the dog examined.
If it's because of an eye injury, carefully examine the eye area for any visible wounds or foreign objects. If there's a foreign object, try to gently flush it out with sterile saline solution. But be very careful not to push the object further in.
In case of any sign of illness like a neurological disorder, take the dog to the vet as soon as possible. The vet can conduct proper tests and provide specific treatment such as medications to address the underlying cause of the eye - rolling behavior.