The rules of war would have identified Khalid Sheikh Mohammad as an enemy soldier out of uniform and he would have been shot at sunrise instead of consuming free meals and free legal advice for the past 23 years.
“Terrorism” is not a legal problem. It is an act of war and should be treated as such.
The traditional laws of war permitted those who took up arms out of uniform to be summarily executed as terrorists. After WW II, those rules were revised in updates to the Geneva Convention and US law as a way to prohibit the barbarism of the Nazis against resistant civilians in occupied Europe. As for the cozy treatment of terrorists in Gitmo, Congress can and should change that through legislation.