SOLVED: It was a permissions issue, solved by adding a rule
/etc/udev/rules.d/45-usb-stlink-v2.rules
(number and name can be whatever you want)
and pasting inside it the following:
#FT232
ATTRS{idProduct}=="6014", ATTRS{idVendor}=="0403", MODE="666", GROUP="plugdev"
#FT2232
ATTRS{idProduct}=="6010", ATTRS{idVendor}=="0403", MODE="666", GROUP="plugdev"
#FT230X
ATTRS{idProduct}=="6015", ATTRS{idVendor}=="0403", MODE="666", GROUP="plugdev"
#STLINK V1
ATTRS{idProduct}=="3744", ATTRS{idVendor}=="0483", MODE="666", GROUP="plugdev"
#STLINK V2
ATTRS{idProduct}=="3748", ATTRS{idVendor}=="0483", MODE="666", GROUP="plugdev"
After that you can reboot or try
sudo service udev restart
and everything should be ok.
Sources:
http://embeddedprogrammer.blogspot.co.uk/2012/09/stm32f4discovery-development-with-gcc.html
http://www.wolinlabs.com/blog/linux.stm32.discovery.gcc.html