Can I upgrade MariaDB replication infrastructure gradually?
A MariaDB replica can replicate from an older master. The other way around won't work.
You should add a step 2.5: stop replicating from M1 to M2 (even if it's just a standby master). After step 4, M1 can replicate from M2 again.