permission denied on files created via adb in recovery
For some strange reason (even on my AOSP 6 Xperia S) actual "fully booted system" reported permissions are a lie. 

I eventually ran ls -l from recovery, and discovered not only they were different, but also owner was another one (in this case root, instead of media_rw). 

chown 1023.1023 and chmod 770 did the work and made the file "normal".