Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
wine fails mprotect for READ+EXECUTE when launching programs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Sun Nov 10, 2024 10:23 pm    Post subject: wine fails mprotect for READ+EXECUTE when launching programs Reply with quote

as said in title, wine fails to launch any windows programs.

here is the trace from one:
Code:

002c:err:winediag:getaddrinfo Failed to resolve your host name IP
0054:err:virtual:map_image_into_view failed to set 60000060 protection on L"\\??\\C:\\windows\\system32\\drivers\\mountmgr.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE7688D0 at address 00006FFFFE7688D0 (thread 0054), starting debugger...
007c:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winex11.drv" section .text, noexec filesystem?
0084:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winex11.drv" section .text, noexec filesystem?
007c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
007c:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
007c:err:systray:initialize_systray Could not create tray window
007c:err:ole:start_rpcss Failed to start RpcSs service
0084:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0084:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0084:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
0084:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
0084:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
0084:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80070578
0084:err:ole:CoMarshalInterface Failed to marshal the interface {<UUID REDACTED>}, hr 0x80070578
0084:err:ole:apartment_get_local_server_stream Failed: 0x80070578
0084:err:ole:start_rpcss Failed to start RpcSs service
0074:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0074:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
006c:fixme:dbghelp:elf_search_auxv can't find symbol in module
006c:fixme:dbghelp:elf_search_auxv can't find symbol in module
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"mountmgr.sys"
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
006c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"MountMgr" failed to start: 1053
00ac:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\wineusb.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFEA02510 at address 00006FFFFEA02510 (thread 00ac), starting debugger...
00c4:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
00c4:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
00bc:fixme:dbghelp:elf_search_auxv can't find symbol in module
00bc:fixme:dbghelp:elf_search_auxv can't find symbol in module
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"wineusb.sys"
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
00bc:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"wineusb" failed to start: 1053
003c:err:service:process_send_start_message pipe connect failed
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"winebus" failed to start: 1053
00f0:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\nsiproxy.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE9C2050 at address 00006FFFFE9C2050 (thread 00f0), starting debugger...
011c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
011c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0114:fixme:dbghelp:elf_search_auxv can't find symbol in module
0114:fixme:dbghelp:elf_search_auxv can't find symbol in module
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"nsiproxy.sys"
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
0114:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"nsiproxy" failed to start: 1053
003c:err:service:process_send_start_message pipe connect failed
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"NDIS" failed to start: 1053
002c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
002c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
012c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
012c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0140:err:virtual:map_image_into_view failed to set 60000060 protection on L"\\??\\C:\\windows\\system32\\drivers\\mountmgr.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE9B88D0 at address 00006FFFFE9B88D0 (thread 0140), starting debugger...
0158:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0158:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0150:fixme:dbghelp:elf_search_auxv can't find symbol in module
0150:fixme:dbghelp:elf_search_auxv can't find symbol in module
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"mountmgr.sys"
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
0150:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
0050:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
0164:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0164:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
^C^C^C^C^C0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\imaadp32.acm" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\msadp32.acm" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\msg711.acm" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\l3codeca.acm" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\msgsm32.acm" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winspool.drv" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\l3codecx.ax" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\spool\\prtprocs\\x64\\wineps.drv" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winspool.drv" section .text, noexec filesystem?
0164:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winspool.drv" section .text, noexec filesystem?
0188:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\ndis.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE363340 at address 00006FFFFE363340 (thread 0188), starting debugger...
01a0:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
01a0:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0198:fixme:dbghelp:elf_search_auxv can't find symbol in module
0198:fixme:dbghelp:elf_search_auxv can't find symbol in module
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ndis.sys"
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
0198:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
0174:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
01b4:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\nsiproxy.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE372050 at address 00006FFFFE372050 (thread 01b4), starting debugger...
01cc:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
01cc:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
01c4:fixme:dbghelp:elf_search_auxv can't find symbol in module
01c4:fixme:dbghelp:elf_search_auxv can't find symbol in module
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"nsiproxy.sys"
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
01c4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
0174:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
01d8:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
01d8:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\imaadp32.acm" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\msadp32.acm" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\msg711.acm" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\l3codeca.acm" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\msgsm32.acm" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\winspool.drv" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\l3codecx.ax" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\spool\\prtprocs\\w32x86\\wineps.drv" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\winspool.drv" section .text, noexec filesystem?
01d8:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\syswow64\\winspool.drv" section .text, noexec filesystem?
01e4:fixme:console:default_ctrl_handler Terminating process 20 on event 0


here's the FS mount options:
Code:

/dev/mapper/vg0-root on / type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=261,subvol=/@root)
/dev/mapper/vg0-root on /etc type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=266,subvol=/@etc)
/dev/mapper/vg0-root on /usr type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=264,subvol=/@usr)
sysfs on /sys type sysfs (rw,relatime,seclabel)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,nosuid,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,size=6555888k,nr_inodes=819200,mode=755,inode64)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime,seclabel)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
none on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,seclabel,nsdelegate)
dev on /dev type devtmpfs (rw,nosuid,noexec,relatime,seclabel,size=10240k,nr_inodes=4093679,mode=755,inode64)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,inode64)
/dev/mapper/boot on /boot type ext2 (rw,noatime,seclabel,errors=continue,user_xattr,acl)
/dev/sdb3 on /boot/efi type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/mapper/vg0-root on /home type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=262,subvol=/@home)
/dev/mapper/vg0-root on /var type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=263,subvol=/@var)
/dev/mapper/vg0-root on /etc type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=266,subvol=/@etc)
/dev/mapper/vg0-root on /usr type btrfs (rw,noatime,seclabel,compress=zstd:15,ssd,space_cache=v2,autodefrag,subvolid=264,subvol=/@usr)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=3277940k,nr_inodes=819485,mode=700,uid=1000,gid=1000,inode64)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
/dev/mapper/luks-{REDACTED UUID} on /run/media/{REDACTED USERNAME}/{REDACTED UUID} type btrfs (rw,nosuid,nodev,relatime,seclabel,space_cache=v2,subvolid=5,subvol=/,uhelper=udisks2)


i'm not sure why it's complaining about a "noexec filesystem", nor how to fix this (i've tried both wine, and wine-proton, both with similar results.)

help is appreciated


Last edited by Shadow_Fury on Mon Nov 18, 2024 7:17 pm; edited 5 times in total
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2856

PostPosted: Mon Nov 11, 2024 12:21 am    Post subject: Reply with quote

Afaik the"noexec" bit is just an assumption that wine makes (thus the question mark) and it can be blocked by something else. In this case I'd suspect selinux, but I never used it nor know much about so I can't really help with that.
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 11, 2024 12:27 am    Post subject: Reply with quote

Ionen wrote:
Afaik the"noexec" bit is just an assumption that wine makes (thus the question mark) and it can be blocked by something else. In this case I'd suspect selinux, but I never used it nor know much about so I can't really help with that.


whilst SElinux is installed, it is currently in permissive mode (fresh install), so i don't think that it's causing the problem
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Tue Nov 12, 2024 12:21 am    Post subject: Reply with quote

Ok, double checked, definitely not SElinux. re-compiled a kernel with none of the major LSMs (SElinux, SMACK, TOMOYO, APPARMOUR etc). same error.
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 5:53 pm    Post subject: Reply with quote

did some digging around the wine source code (relevant file). the thing generating the error is:
Code:

        if (!set_vprot( view, ptr + sec->VirtualAddress, size, vprot ) && (vprot & VPROT_EXEC))
            ERR( "failed to set %08x protection on %s section %.8s, noexec filesystem?\n",
                 (int)sec->Characteristics, debugstr_w(filename), sec->Name );


which calls set_vprot:
Code:

/***********************************************************************
 *           set_vprot
 *
 * Change the protection of a range of pages.
 */
static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vprot )
{
    if (view->protect & VPROT_WRITEWATCH)
    {
        /* each page may need different protections depending on write watch flag */
        set_page_vprot_bits( base, size, vprot & ~VPROT_WRITEWATCH, ~vprot & ~VPROT_WRITEWATCH );
        mprotect_range( base, size, 0, 0 );
        return TRUE;
    }
    if (enable_write_exceptions && is_vprot_exec_write( vprot )) vprot |= VPROT_WRITEWATCH;
    if (mprotect_exec( base, size, get_unix_prot(vprot) )) return FALSE;
    set_page_vprot( base, size, vprot );
    return TRUE;
}


the only thing in here that returns FALSE (thus tripping the error message is mprotect_exec:
Code:

static inline int mprotect_exec( void *base, size_t size, int unix_prot )
{
    if (force_exec_prot && (unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC))
    {
        TRACE( "forcing exec permission on %p-%p\n", base, (char *)base + size - 1 );
        if (!mprotect( base, size, unix_prot | PROT_EXEC )) return 0;
        /* exec + write may legitimately fail, in that case fall back to write only */
        if (!(unix_prot & PROT_WRITE)) return -1;
    }

    return mprotect( base, size, unix_prot );
}


which is calling mprotect.

60000020 protection corresponds to (as taken from winnt.h):
Code:

IMAGE_SCN_CNT_CODE         0x00000020
IMAGE_SCN_MEM_EXECUTE      0x20000000
IMAGE_SCN_MEM_READ         0x40000000


based on the get_unix_prot function, the corresponding flags for mprotect are READ and EXECUTE
this fails for some reason.

any help figuring this out is appreciated (and sorely needed)
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22684

PostPosted: Mon Nov 18, 2024 5:58 pm    Post subject: Reply with quote

If you make a simple C program (or Python script, via ctypes) that opens and attempts to map that file as write+execute, does that fail too? That would let us rule out anything Wine is doing, and would make for a much simpler test case. What are the file permissions on the offending file? What are the mount options on the containing filesystem? Your above list of all mounts is not directly usable here, since we don't know definitively which Linux filesystem holds the Windows path that Wine is failing on.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2856

PostPosted: Mon Nov 18, 2024 6:08 pm    Post subject: Reply with quote

fwiw does it work if you create the wine prefix on an entirely different filesystem?

e.g. tmpfs rather than btrfs, preferably without any special flags -- even seclabel just in case unless that's forced (hardly know selinux), and esp. not noexec so don't use /dev/shm as your trial tmpfs

btrfs in itself shouldn't cause issues for wine but I do suspect there's some configuration being set somewhere that's causing problems, maybe even some protection setting set at filesystem creation? I don't know the things that btrfs can do well. If tmpfs fails too, then could at least rule out that it's specific to that btrfs filesystem (assuming it's even what was being used like Hu pointed)
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 6:18 pm    Post subject: Reply with quote

Hu wrote:
If you make a simple C program (or Python script, via ctypes) that opens and attempts to map that file as write+execute, does that fail too? That would let us rule out anything Wine is doing, and would make for a much simpler test case. What are the file permissions on the offending file? What are the mount options on the containing filesystem? Your above list of all mounts is not directly usable here, since we don't know definitively which Linux filesystem holds the Windows path that Wine is failing on.


just tried this based on code from here

modified as such:
Code:

-if (mprotect(buffer + pagesize * 2, pagesize, PROT_READ) == -1) handle_error("mprotect");
+if (mprotect(buffer + pagesize * 2, pagesize, PROT_READ | PROT_EXEC) == -1) handle_error("mprotect");


the program does not raise any error about mprotect, so it seems to be working.

the file permissions for the above mentioned mountmgr.sys (in the relevant prefix) are "-rw-r--r--". i've tried adding execute permissions, it doesn't help.
the prefix is located on the btrfs @home subvolume, so i assume those are the relevant mount options

will try to map the specific wine file next, and see if that still fails
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 7:00 pm    Post subject: Reply with quote

Hu wrote:
If you make a simple C program (or Python script, via ctypes) that opens and attempts to map that file as write+execute, does that fail too? That would let us rule out anything Wine is doing, and would make for a much simpler test case. What are the file permissions on the offending file? What are the mount options on the containing filesystem? Your above list of all mounts is not directly usable here, since we don't know definitively which Linux filesystem holds the Windows path that Wine is failing on.


ok, wrote this short program. loading the file, and doing mprotect on it seems to succeed just fine (if i've written the program wrong, let me know)
Code:

#include <malloc.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

#define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0)


static char *buffer;

int main(int argc, char ** argv)
{
    int pagesize;

    if (argc !=2)
    {
            printf("use: test [FILENAME]\n");
            exit(EXIT_FAILURE);
    }

    FILE *f = fopen(argv[1], "rb");
    fseek(f, 0, SEEK_END);
    long fsize = ftell(f);
    rewind(f);

    pagesize = sysconf(_SC_PAGE_SIZE);
    if (pagesize == -1)
        handle_error("sysconf");

    long file_pages = fsize/pagesize + (fsize % pagesize != 0); //round file pages up to closest integer

    buffer = memalign(pagesize, file_pages * pagesize);
    if (buffer == NULL)
        handle_error("memalign");

    printf("Start of region:        %p\n", buffer);
    fread(buffer, fsize, 1, f);

    if (mprotect(buffer + pagesize * 2, pagesize,
        PROT_READ | PROT_EXEC) == -1)
        handle_error("mprotect");

    printf("file mprotect succeeded!\n");
    exit(EXIT_SUCCESS);
}


ran it with:
Code:

./test /home/{USER REDACTED}/Downloads/npp.8.2.portable.x64/pfx/drive_c/windows/system32/drivers/mountmgr.sys

(i'm using notepad++ as a test application), this location is on the BTRFS @home subvolume)
one note: wine seems to be mprotecting just the .text sections of the file, not the whole file (based on the error message that wine gives). not sure if that matters

edit note: mapping as write+exec works too (though wine maps as read+exec)


Last edited by Shadow_Fury on Mon Nov 18, 2024 7:37 pm; edited 2 times in total
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 7:16 pm    Post subject: Reply with quote

Ionen wrote:
fwiw does it work if you create the wine prefix on an entirely different filesystem?

e.g. tmpfs rather than btrfs, preferably without any special flags -- even seclabel just in case unless that's forced (hardly know selinux), and esp. not noexec so don't use /dev/shm as your trial tmpfs

btrfs in itself shouldn't cause issues for wine but I do suspect there's some configuration being set somewhere that's causing problems, maybe even some protection setting set at filesystem creation? I don't know the things that btrfs can do well. If tmpfs fails too, then could at least rule out that it's specific to that btrfs filesystem (assuming it's even what was being used like Hu pointed)


tried it on a USB formatted to ext4, with following mount options:
Code:

/dev/sdd1 on /mnt type ext4 (rw,relatime,seclabel)

(seclabel is forced, but it doesn't seem to do anything:
"seclabel is an indicator added by the selinux code, that the filesystem is using xattrs for labels and that it supports label changes by setting the xattrs. (see here))

here is the trace from that:
Code:

002c:err:winediag:getaddrinfo Failed to resolve your host name IP
0054:err:virtual:map_image_into_view failed to set 60000060 protection on L"\\??\\C:\\windows\\system32\\drivers\\mountmgr.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE7688D0 at address 00006FFFFE7688D0 (thread 0054), starting debugger...
0074:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winex11.drv" section .text, noexec filesystem?
007c:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winex11.drv" section .text, noexec filesystem?
0074:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0074:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0074:err:systray:initialize_systray Could not create tray window
0074:err:ole:start_rpcss Failed to start RpcSs service
007c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
007c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
007c:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
007c:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
007c:err:ole:apartment_createwindowifneeded CreateWindow failed with error 1400
007c:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80070578
007c:err:ole:CoMarshalInterface Failed to marshal the interface {<UUDI REDACTED>}, hr 0x80070578
007c:err:ole:apartment_get_local_server_stream Failed: 0x80070578
007c:err:ole:start_rpcss Failed to start RpcSs service
006c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
006c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0064:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0064:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
0064:fixme:dbghelp:elf_search_auxv can't find symbol in module
0064:fixme:dbghelp:elf_search_auxv can't find symbol in module
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"mountmgr.sys"
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
0064:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"MountMgr" failed to start: 1053
00a4:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\wineusb.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFEA02510 at address 00006FFFFEA02510 (thread 00a4), starting debugger...
00bc:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
00bc:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
00b4:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
00b4:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
00b4:fixme:dbghelp:elf_search_auxv can't find symbol in module
00b4:fixme:dbghelp:elf_search_auxv can't find symbol in module
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"wineusb.sys"
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
00b4:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"wineusb" failed to start: 1053
003c:err:service:process_send_start_message pipe connect failed
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"winebus" failed to start: 1053
00fc:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\drivers\\nsiproxy.sys" section .text, noexec filesystem?
wine: Unhandled page fault on execute access to 00006FFFFE9E2050 at address 00006FFFFE9E2050 (thread 00fc), starting debugger...
0114:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0114:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
010c:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
010c:err:winediag:nodrv_CreateWindow L"Unknown error (998)."
010c:fixme:dbghelp:elf_search_auxv can't find symbol in module
010c:fixme:dbghelp:elf_search_auxv can't find symbol in module
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"nsiproxy.sys"
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntoskrnl"
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"winedevice"
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"sechost"
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"kernel32"
010c:err:dbghelp:pe_load_msc_debug_info -Debug info stripped, but no .DBG file in module L"ntdll"
003c:err:service:process_send_command service protocol error - failed to read pipe r = 0  count = 0!
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"nsiproxy" failed to start: 1053
003c:err:service:process_send_start_message pipe connect failed
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"NDIS" failed to start: 1053
012c:err:virtual:map_image_into_view failed to set 60000020 protection on L"\\??\\C:\\windows\\system32\\winspool.drv" section .text, noexec filesystem?
012c:err:module:loader_init "winspool.drv" failed to initialize, aborting
012c:err:module:loader_init Initializing dlls for L"Z:\\mnt\\npp.8.7.portable.x64\\notepad++.exe" failed, status c0000005
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2856

PostPosted: Mon Nov 18, 2024 7:37 pm    Post subject: Reply with quote

I see, odd...

If I create a wineprefix on an actual noexec filesystem, the errors I get are a bit different (none of the "section" stuff):
Code:
00f8:err:virtual:map_file_into_view failed to set PROT_EXEC on file map, noexec filesystem?
Still no real idea why it's reaching that other error for you.

I don't think we've seen emerge --info yet? Is it a typical wine build with gcc + "-march=native -O2" or is there some special *FLAGS, clang/lld, or such involved? Given selinux I'm gonna guess it's a hardened profile that sets extras, but if hardened profiles broke wine I think we'd know by now (not that I tried).


Last edited by Ionen on Mon Nov 18, 2024 7:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22684

PostPosted: Mon Nov 18, 2024 7:41 pm    Post subject: Reply with quote

I think that test program is incorrect. You open and read the file, but then memalign allocates heap memory, and you adjust the permissions on that heap memory. This tells us nothing about whether you could change the protection of the mapping of the file. I think you need to open the file with open, map some or all of it with mmap, then use mprotect to change the protection on the mapping from mmap.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2856

PostPosted: Mon Nov 18, 2024 7:48 pm    Post subject: Reply with quote

Shadow_Fury wrote:
Ok, double checked, definitely not SElinux. re-compiled a kernel with none of the major LSMs (SElinux, SMACK, TOMOYO, APPARMOUR etc). same error.
On that note, maybe try gentoo-kernel-bin if haven't yet -- maybe not related to these but maybe you're missing an option if it's a custom/minimalist kernel, or it's something else set that just haven't been suspecting.

Edit: given the list, does sound like your kernel has a lot going on
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 8:03 pm    Post subject: Reply with quote

Hu wrote:
I think that test program is incorrect. You open and read the file, but then memalign allocates heap memory, and you adjust the permissions on that heap memory. This tells us nothing about whether you could change the protection of the mapping of the file. I think you need to open the file with open, map some or all of it with mmap, then use mprotect to change the protection on the mapping from mmap.


new test program (based on this):
Code:

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0)

    int
    main(int argc, char *argv[])
    {
        int          fd;
        char         *addr;
        off_t        offset, pa_offset;
        size_t       length;
        ssize_t      s;
        struct stat  sb;

        if (argc < 3 || argc > 4) {
            fprintf(stderr, "%s file offset [length]\n", argv[0]);
            exit(EXIT_FAILURE);
        }

        fd = open(argv[1], O_RDONLY);
        if (fd == -1)
            handle_error("open");

        if (fstat(fd, &sb) == -1)           /* To obtain file size */
            handle_error("fstat");

        offset = atoi(argv[2]);
        pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
        /* offset for mmap() must be page aligned */

        if (offset >= sb.st_size) {
            fprintf(stderr, "offset is past end of file\n");
            exit(EXIT_FAILURE);
        }

        if (argc == 4) {
            length = atoi(argv[3]);
            if (offset + length > sb.st_size)
                length = sb.st_size - offset;
            /* Can't display bytes past end of file */

        } else {    /* No length arg ==> display to end of file */
            length = sb.st_size - offset;
        }

        addr = mmap(NULL, length + offset - pa_offset, PROT_READ,
                    MAP_PRIVATE, fd, pa_offset);
        if (addr == MAP_FAILED)
            handle_error("mmap");


        if (mprotect(addr, length + offset - pa_offset,
            PROT_WRITE | PROT_EXEC) == -1)
            handle_error("mprotect");
        else printf("mprotect success!\n");


        s = write(STDOUT_FILENO, addr + offset - pa_offset, length);
        if (s != length) {
            if (s == -1)
                handle_error("write");

            fprintf(stderr, "partial write");
            exit(EXIT_FAILURE);
        }


        munmap(addr, length + offset - pa_offset);
        close(fd);

        exit(EXIT_SUCCESS);
    }



everything works fine. mprotect executes and returns without erroring.

executed as:
Code:

./test_mmap ~/Downloads/npp.8.7.portable.x64/pfx/drive_c/windows/system32/drivers/mountmgr.sys 0
Back to top
View user's profile Send private message
Shadow_Fury
Apprentice
Apprentice


Joined: 20 Apr 2021
Posts: 194
Location: 11.435765792823453, 143.05926743686274

PostPosted: Mon Nov 18, 2024 8:22 pm    Post subject: Reply with quote

Ionen wrote:
Shadow_Fury wrote:
Ok, double checked, definitely not SElinux. re-compiled a kernel with none of the major LSMs (SElinux, SMACK, TOMOYO, APPARMOUR etc). same error.
On that note, maybe try gentoo-kernel-bin if haven't yet -- maybe not related to these but maybe you're missing an option if it's a custom/minimalist kernel, or it's something else set that just haven't been suspecting.

Edit: given the list, does sound like your kernel has a lot going on


i can't seem to install my video drivers (nvidia-drivers) when using a dist kernel. would chrooting from a liveUSB be an adequate substitute for this test? (i'm also happy to post the .config file, if that would help)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum