How to Root Xperia M2 (JB 4.3 Only!)
You can use geohot's Towel Root to gain root access on your stock M2's (D2303 and D2305 tested) on both locked and unlocked bootloaders.
1. On your device navigate to settings > security and check "Unknown Sources"
2. Using your favorite browser navigate to
www.towelroot.com and click the lambda symbol
3. Install the APK file and tap "Make it Rain"
4. Reboot your device and install SuperSU from the
Play Store
5. Congratulations your device has now root access
I tested this on my own Xperia M2 D2303 and works perfectly. I also got confirmation that it works on D2305 (both locked bootloaders) and the only downside is that you can't update the Super SU binary for now. That will probably get fixed as well.
Big thanks to geohot for making all this possible. Visit the original Towel Root XDA threat.
Enjoy
How to get the latest SuperSU to avoid the update prompt
First uninstall the SuperSU downloaded from the PlayStore.
1. Visit Chainfire's SuperSU threat here on XDA
2. Scroll down and find the "CWM / TWRP / MobileODIN installable ZIP" download link
3. Download the file and extract it to your phone/PC
4. Once extracted, you will find the latest "superuser.apk" inside the "Common" direcroty
5. Transfer and install the APK file on your phone
Source