The correction is unclear... Since there are always exceptions, of course it's not the case that "dismissing a permanent employee (正社員) is always illegal". But there's in fact a (somewhat vague but broad) provision in labour law and also precedents that make it very difficult to legally fire a permanent employee in normal circunstances.
Basically you can legally fire a permanent employee in the same sense that a civil servant in most countries can be fired: if the employee does something egregious, like stealing from the company, not showing up for a long period of time with no reason, etc. Certainly not for incompetence, or even if the company has been in the red for several years in a row.
E.g. Japan Airlines went basically bankrupt (technically a restructuring) and even so they had trouble laying off part of the staff.