Yes, jailbreaking is legal, although in some countries the status of jailbreaking isn't properly defined.