Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would we go about verifing this library? #734

Open
dpc opened this issue Jan 28, 2019 · 3 comments
Open

How would we go about verifing this library? #734

dpc opened this issue Jan 28, 2019 · 3 comments
Labels
blocked by rust Blocked on a feature being implemented or bug being fixed in Rust

Comments

@dpc
Copy link

dpc commented Jan 28, 2019

As a part of effort of cargo crev, I wanted to review winapi-i686-pc-windows-gnu, and it turned out it's a 52MB of binary libraries. I realize that they are probably good reason for this, but how should I go about making sure there are no rootkits, viruses etc. in there?

@retep998
Copy link
Owner

You can build them yourself from the .def files. I'm not sure how good MinGW is at reproducible builds, but if you want to work on making them reproducible, have at it.

Ideally though, we'd just have rust-lang/rfcs#2627 and I wouldn't need those import libraries.

@MaulingMonkey
Copy link
Contributor

MaulingMonkey commented Apr 6, 2019

I poked at this some (under the mistaken impression binaries were used in *-msvc builds too) and discovered the .a files might have incorrect ordinals in the 0.3 branch based on the differences in .idata$6 described bellow. Not sure how problematic that is.

What follows is mostly a description of how to generate and diff the binaries reasonably. I have not done an exhaustive check against all binaries - could be automated more, but I haven't. I also haven't checked that e.g. I list everything important using objdump (I probably haven't), making mingw output reproducable builds would probably be a saner approach anyways.

Stuff used:

Archive Differences

  • Modified timestamps differ
  • Object filenames are semi-random (d(random)(t|h|s\d{5}).o)

Archive\1.txt Differences

  • First two symbols are based on absolute paths used with dlltool.
  • Filenames don't match
  • Otherwise, libwinapi_xinput.a\1.txt seems identical between runs (same symbols, same ordering)

Example:

dkxcbt.o    __C__Users_Peter_Code_winapi_rs_x86_64_lib_libwinapi_xinput_a_iname
dkxcbh.o    _head_C__Users_Peter_Code_winapi_rs_x86_64_lib_libwinapi_xinput_a
dkxcbs00007.o    XInputSetState
dkxcbs00007.o    __imp_XInputSetState
dkxcbs00006.o    XInputGetState
dkxcbs00006.o    __imp_XInputGetState
dkxcbs00005.o    XInputGetKeystroke
dkxcbs00005.o    __imp_XInputGetKeystroke
dkxcbs00004.o    XInputGetCapabilities
dkxcbs00004.o    __imp_XInputGetCapabilities
dkxcbs00003.o    XInputGetBatteryInformation
dkxcbs00003.o    __imp_XInputGetBatteryInformation
dkxcbs00002.o    XInputGetAudioDeviceIds
dkxcbs00002.o    __imp_XInputGetAudioDeviceIds
dkxcbs00001.o    XInputEnable
dkxcbs00001.o    __imp_XInputEnable
dkxcbs00000.o    DllMain
dkxcbs00000.o    __imp_DllMain

Archive\*.o Differences

  • We can use objdump -s *.o and other flags to inspect differences. First 0000 is the file offset.
  • .idata$6 section differs!
  • From the 0.3 branch:
    dkxcbs00007.o:     file format pe-x86-64
    ...
    Contents of section .idata$6:
     0000 07005849 6e707574 53657453 74617465  ..XInputSetState
     0010 0000                                 ..
    
    The first two bytes of .idata$6, 0700..., rise numerically, matching the file for all of libwinapi_xinput.a's numbered .o files.
  • From locally rebuilt archives:
    daims00007.o:     file format pe-x86-64
    ...
    Contents of section .idata$6:
     0000 03005849 6e707574 53657453 74617465  ..XInputSetState
     0010 0000         
    
    The first two bytes of .idata$6, 0300..., match the ordinal in the .def files (e.g. XInputSetState @3 from xinput.def:10), for all of libwinapi_xinput.a's numbered .o files.

@MaulingMonkey
Copy link
Contributor

@retep998 retep998 added the blocked by rust Blocked on a feature being implemented or bug being fixed in Rust label Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by rust Blocked on a feature being implemented or bug being fixed in Rust
Projects
None yet
Development

No branches or pull requests

3 participants