chenxiaolong / MSD

Android app for emulating mass storage devices over USB
GNU General Public License v3.0
19 stars 1 forks source link

Permission denied (os error 13) #19

Open ukrbugreporter opened 2 hours ago

ukrbugreporter commented 2 hours ago

I am using Poco X3 Pro (vayu) running crDroid 10.9 based on Android 14 rooted with Kitsune. Configfs, USB Gadget and USB gadget HAL seem to be supported:

vayu:/ # ls /config/usb_gadget/g1
UDC              bDeviceSubClass  bcdUSB     idProduct  strings
bDeviceClass     bMaxPacketSize0  configs    idVendor
bDeviceProtocol  bcdDevice        functions  os_desc
vayu:/ # zcat /proc/config.gz | grep CONFIG_USB_CONFIGFS_MASS_STORAGE
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
vayu:/ # pgrep -f android.hardware.usb.gadget-service
1|vayu:/ # 

I followed the installation instructions but after booting into system and launching MSD I get an error. It is either

Failed to open directory: "/config/usb_gadget/g1/configs/b.1"

Caused by:
    Permission denied (os error 13)

or

Failed to find gadget HAL process: android.hardware.usb.gadget-service*

The content of /data/local/tmp/msd/msd-tool.log file looks like this:

--------- beginning of main
11-01 15:46:30.644  1699  5254 I msd-tool: peer{pid=5174 uid=10477 gid=10477}: msd_tool::daemon: Received connection
11-01 15:46:30.644  1699  5254 W msd-tool: peer{pid=5174 uid=10477 gid=10477}: msd_tool::daemon: Failed to open directory: "/config/usb_gadget/g1/configs/b.1"
11-01 15:46:30.644  1699  5254 W msd-tool: 
11-01 15:46:30.644  1699  5254 W msd-tool: Caused by:
11-01 15:46:30.644  1699  5254 W msd-tool:     Permission denied (os error 13)
11-01 15:50:22.907  1699  6932 I msd-tool: peer{pid=6078 uid=10477 gid=10477}: msd_tool::daemon: Received connection
11-01 15:50:22.907  1699  6932 W msd-tool: peer{pid=6078 uid=10477 gid=10477}: msd_tool::daemon: Failed to open directory: "/config/usb_gadget/g1/configs/b.1"
11-01 15:50:22.907  1699  6932 W msd-tool: 
11-01 15:50:22.907  1699  6932 W msd-tool: Caused by:
11-01 15:50:22.907  1699  6932 W msd-tool:     Permission denied (os error 13)

I checked if the directory /config/usb_gadget/g1/configs/b.1/ actually exists and it does

vayu:/ # ls /config/usb_gadget/g1/configs/b.1/                                    
MaxPower  bmAttributes  f1  strings

Something weird happens on my Sony Xperia XA2 Plus too. It is running LineageOS 21 based on Android 14, again, rooted with Kitsune.

Support for MSD seems to be present:

H4413:/ # ls /config/usb_gadget/g1
UDC              bDeviceSubClass  bcdUSB     idProduct  strings
bDeviceClass     bMaxPacketSize0  configs    idVendor
bDeviceProtocol  bcdDevice        functions  os_desc
H4413:/ # zcat /proc/config.gz | grep CONFIG_USB_CONFIGFS_MASS_STORAGE
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
H4413:/ # pgrep -f android.hardware.usb.gadget-service
1|H4413:/ #

But the app does not even start. It hangs and then crashes. /data/local/tmp/msd/msd-tool.log is empty, /sdcard/Android/com.chiller3.msd/ is non-existent.

ukrbugreporter commented 2 hours ago

Just checked other issues and I did the adb shell su -c 'dmesg | grep denied' > denials.txt

Output

chenxiaolong commented 1 hour ago

Can you zip all of /data/local/tmp/msd/ and upload that? I'll take a look after work today.

Also, can you post the output of:

adb shell su -c 'ls -lZ /config/usb_gadget/g1'

But the app does not even start. It hangs and then crashes. /data/local/tmp/msd/msd-tool.log is empty, /sdcard/Android/com.chiller3.msd/ is non-existent.

Between the two devices, are there any difference on configuration for root hiding modules? This sounds very much like Android itself can't access MSD's apk file.

H4413:/ # pgrep -f android.hardware.usb.gadget-service
1|H4413:/ #

This didn't return any output, so both your devices aren't using the gadget HAL. MSD currently doesn't support this.

The reason MSD talks to the gadget HAL at all is to prevent Android from messing with the USB state while MSD is making its own changes. This might not be necessary on devices that used the old USB configuration mechanism from before Google introduced the gadget HAL.

But let's figure out the permissions issues first.