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

WIP: Steam openssl fix #23034

Closed
wants to merge 2 commits into from
Closed

WIP: Steam openssl fix #23034

wants to merge 2 commits into from

Conversation

corngood
Copy link
Contributor

Motivation for this change

This is an alternate fix #20269 which shouldn't cause the knock-on described in #20726.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@corngood, thanks for your PR! By analyzing the history of the files in this pull request, we identified @abbradar, @hrdinka and @the-kenny to be potential reviewers.

@corngood
Copy link
Contributor Author

Doing this with LD_PRELOAD produces spam for 64-bit processes:

ERROR: ld.so: object '/home/david/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.

And presumably impacts child process (i.e. games). I'd love to find a better way, but any modifications to the steam ELF cause it to fail checksum and replace itself at startup.

@corngood
Copy link
Contributor Author

ValveSoftware/steam-for-linux#4619

Describes the root problem: it's statically linked against openssl --no-engine, but the symbols are public, so dynamically loading openssl (e.g. via mesa) does bad things.

@abbradar
Copy link
Member

Maybe we need to preload 64-bit version as well for consistency, too?

@corngood
Copy link
Contributor Author

@abbradar I don't think it's worth it. It would suppress the warning, but the steam client is 32-bit only, and most games these days are 64-bit, so it would be at the expense of an increased chance of the preload causing a problem.

An alternative would be to build /usr/lib/libsteamopensslhack.so and /usr/lib64/libsteamopensslhack.so in the steam FHS. The latter would do nothing, and the former would check it's loaded into the steam client process, and load openssl in it's constructor. You'd set LD_PRELOAD=/usr/$LIB/libsteamopensslhack.so. That should result in no warnings and very little chance of side effects, but is it worth the trouble? The warnings are in the stderr of a GUI app, and I haven't encountered any side effects yet (still needs testing with a few more games).

@abbradar
Copy link
Member

@corngood It won't even supress the warning, actually it will double their number :D The only possible advantage would be to override OpenSSL everywhere so if Steam has a 64-bit part with static OpenSSL it would also be fixed.

About alternative: yes, I wanted to prosose this too but I tried to use it already some time ago when we needed to preload PulseAudio and it turns out $LIB is lib on both 64- and 32-bit versions of ld.so on NixOS. Maybe I just did something the wrong way though...

I'll test it and merge in several days, thanks.

@corngood
Copy link
Contributor Author

@abbradar I was thinking it would suppress the warning if you preloaded from the chroot and used $LIB, but if that requires ld.so changes then it's even less attractive.

I'll push a new version with openssl-steam reverted, since it's unlikely to ever be needed again, and remove WIP.

@corngood
Copy link
Contributor Author

@abbradar A crash was reported with this PR at #20726 (comment). I'm going to investigate that as well before removing WIP.

@corngood corngood changed the title WIP: Steam openssl fix Steam openssl fix Mar 4, 2017
@corngood
Copy link
Contributor Author

corngood commented Mar 4, 2017

@abbradar looks like it may have been a false alarm. Feedback from more users would be nice, but I've removed WIP.

@corngood
Copy link
Contributor Author

corngood commented Mar 4, 2017

I also reverted the commit where openssl-steam was added.

@FRidh FRidh self-assigned this Mar 5, 2017
@ghost
Copy link

ghost commented Mar 26, 2017

Just tested this pull request and can confirm that it fixes the same issue with another game (Dirt Rally).

@corngood
Copy link
Contributor Author

@abbradar thoughts on merging this?

@FRidh
Copy link
Member

FRidh commented Mar 26, 2017

Also seems to work for me.

@ghost
Copy link

ghost commented Mar 29, 2017

@corngood I've done some more testing and it seems that this patch fixes some games, but it appears to break Team Fortress 2. Other Source Engine games (Counter Strike: Global Offensive, Portal 2) work fine.

ExecSteamURL: "steam://rungameid/440"
Game update: AppID 440 "Team Fortress 2", ProcID 30705, IP 0.0.0.0:0
>>> Adding process 30705 for game ID 440
ERROR: ld.so: object '/nix/store/imw06i22k7hd3zpvkxf9vakmhrgzdsg3-openssl-1.0.2k/lib/libcrypto.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/tjg/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/nix/store/imw06i22k7hd3zpvkxf9vakmhrgzdsg3-openssl-1.0.2k/lib/libcrypto.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/tjg/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
pid 30707 != 30706, skipping destruction (fork without exec?)
ERROR: ld.so: object '/nix/store/imw06i22k7hd3zpvkxf9vakmhrgzdsg3-openssl-1.0.2k/lib/libcrypto.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/tjg/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/tjg/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
>>> Adding process 30706 for game ID 440
>>> Adding process 30708 for game ID 440
>>> Adding process 30709 for game ID 440
SDL video target is 'x11'
SDL video target is 'x11'
/run/media/tjg/Scratch/SteamLibrary/steamapps/common/Team Fortress 2/hl2.sh: line 72: 30709 Segmentation fault      ${GAME_DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"
Installing breakpad exception handler for appid(gameoverlayui)/version(20170328000845)
Installing breakpad exception handler for appid(gameoverlayui)/version(1.0)
Installing breakpad exception handler for appid(gameoverlayui)/version(1.0)
Game removed: AppID 440 "Team Fortress 2", ProcID 30709 
No cached sticky mapping in ActivateActionSet.Installing breakpad exception handler for appid(gameoverlayui)/version(1.0)

@corngood corngood changed the title Steam openssl fix WIP: Steam openssl fix Mar 30, 2017
@corngood
Copy link
Contributor Author

@tjg1 that's unfortunate. Are you by any chance using:

steam = pkgs.steam.override {
        newStdcpp = true;
      };

I needed that for mesa, I think, so I've been doing all my testing with it for a while now. I'm just curious if it makes a difference for this. Also, could you post a stack trace if you can get one? At least it's a free game, so I'll be able to test it when I get some time.

@ghost
Copy link

ghost commented Apr 1, 2017

I'm not using newStdcpp. I can post a stack trace if you tell me how to get one.

@baracoder
Copy link
Contributor

Hey nice! This also fixes the error I recently experienced with games ported by Feral Interactive like Deus Ex Mankind Devided, Hitman, MadMax and Tomb Raider, which all have a similar launcher.

...
Steam_SetMinidumpSteamID:  Caching Steam ID:  76561197973402038 [API loaded no]
>>> Adding process 2804 for game ID 234140
Installing breakpad exception handler for appid(gameoverlayui)/version(20170330221952)
Installing breakpad exception handler for appid(gameoverlayui)/version(1.0)
/home/bara/archive/steam/steamapps/common/Mad Max/bin/MadMax: relocation error: /home/bara/archive/steam/steamapps/common/Mad Max/bin/../lib/x86_64/libcurl.so.4: symbol ENGINE_load_builtin_engines, version OPENSSL_1.0.0 not defined in file libcrypto.so.1.0.0 with link time reference
Game removed: AppID 234140 "Mad Max", ProcID 2804 

@abbradar
Copy link
Member

abbradar commented Apr 1, 2017

I completely forgot about this PR and got overwhelmed by other things later, sorry. @tjg1's report that it breaks some games worries me -- I'll try to run Team Fortress 2 with the patch and see what happens.

@corngood
Copy link
Contributor Author

corngood commented Apr 1, 2017

@abbradar yeah I put WIP back on until we sort that out.

@corngood
Copy link
Contributor Author

corngood commented Apr 2, 2017

I was able to reproduce the TF2 crash, and got the stack trace:

#0  0xf7e20a75 in OPENSSL_ia32_cpuid ()
   from /nix/store/92h2cfh4rah4cd2fq98xsb1crnjc3apf-openssl-1.0.2k/lib/libcrypto.so
#1  0xee9ccd31 in OPENSSL_cpuid_setup ()
   from /home/david/.local/share/Steam/steamapps/common/Team Fortress 2/bin/engine.so
#2  0xee21dde8 in _DYNAMIC () from /steamrt/i386/lib/libopenal.so.1
#3  0xee1a5ada in alc_init () from /steamrt/i386/lib/libopenal.so.1
#4  0xf7fe8e81 in call_init.part () from /lib/ld-linux.so.2
#5  0xf7fe8fee in _dl_init () from /lib/ld-linux.so.2
#6  0xf7fed1b7 in dl_open_worker () from /lib/ld-linux.so.2
#7  0xf7ca6324 in _dl_catch_error () from /usr/lib32/libc.so.6
#8  0xf7fec972 in _dl_open () from /lib/ld-linux.so.2
#9  0xf7d5ec37 in dlopen_doit () from /usr/lib32/libdl.so.2
#10 0xf7ca6324 in _dl_catch_error () from /usr/lib32/libc.so.6
#11 0xf7d5f332 in _dlerror_run () from /usr/lib32/libdl.so.2
#12 0xf7d5ecce in dlopen@@GLIBC_2.1 () from /usr/lib32/libdl.so.2
#13 0xf5973729 in ?? ()
   from /home/david/.local/share/Steam/steamapps/common/Team Fortress 2/bin/filesystem_stdio.so
#14 0xf59738bd in ?? ()
   from /home/david/.local/share/Steam/steamapps/common/Team Fortress 2/bin/filesystem_stdio.so
#15 0xf5939563 in ?? ()
   from /home/david/.local/share/Steam/steamapps/common/Team Fortress 2/bin/filesystem_stdio.so
#16 0xf64baf5b in ?? () from bin/launcher.so
#17 0xf64bbbe6 in ?? () from bin/launcher.so
#18 0xf64bbe16 in ?? () from bin/launcher.so
#19 0xf649a150 in ?? () from bin/launcher.so
#20 0xf64bb75e in ?? () from bin/launcher.so
#21 0xf64bba18 in ?? () from bin/launcher.so
#22 0xf64bba30 in ?? () from bin/launcher.so
#23 0xf649b8b4 in LauncherMain () from bin/launcher.so
#24 0x0804877b in main ()

@corngood
Copy link
Contributor Author

corngood commented Apr 2, 2017

Looks like another problem with openssl being statically linked (into engine.so this time) and still calling to symbols from the shared library.

@corngood
Copy link
Contributor Author

corngood commented Apr 2, 2017

I just had a steam client update, so I thought I'd test it again without the LD_PRELOAD hack, and it now seems to be working fine with mesa. It looks like since mesa 17, they have a built-in sha1 implementation, and no longer use openssl (or libnettle, etc).

@abbradar we should probably remove the openssl dependency from mesa, but I'm thinking that should go into staging?

So this change now simply reverts the openssl hacks used to get steam working with mesa.

@baracoder @tjg1 @FRidh if any of you get a chance to test this, it would be appreciated. I've tested:

  • Factorio
  • Broforce
  • The Talos Principle
  • TF2 * no longer crashes, but I don't get a window (possibly a problem with XMonad?)

@ghost
Copy link

ghost commented Apr 2, 2017

Can confirm this fixes TF2 and Awesomenauts (another game that was broken with previous patch). Feral Interactive games (Dirt Rally and Tomb Raider) also work fine.

Awesome work. Thanks.

@benley
Copy link
Member

benley commented Apr 3, 2017

I've been testing #23034 cherry-picked onto nixos-17.03 and it seems to fix the issue. I haven't yet found any new breakage. I'm using an nVidia card with the proprietary drivers.

Tested and confirmed working so far:

  • Life Is Strange
  • Cook, Serve, Delicious
  • The Talos Principle
  • Fez
  • Hyper Light Drifter
  • Snakebird
  • Stardew Valley
  • Stellaris
  • Portal
  • Portal 2

@FRidh
Copy link
Member

FRidh commented Apr 3, 2017

Looks like we can revert this then on both master and 17.03. For me Insurgency and Wargame work.

FRidh pushed a commit that referenced this pull request Apr 3, 2017
No longer necessary. See #23034 (comment)

This reverts commit a120bad.
FRidh pushed a commit that referenced this pull request Apr 3, 2017
FRidh pushed a commit that referenced this pull request Apr 3, 2017
No longer necessary. See #23034 (comment)

This reverts commit a120bad.

(cherry picked from commit 398823d)
FRidh pushed a commit that referenced this pull request Apr 3, 2017
No longer necessary. See #23034 (comment)

This reverts commit a50784b.

(cherry picked from commit 2c006ca)
@FRidh
Copy link
Member

FRidh commented Apr 3, 2017

I've pushed these two commits to master and 17.03.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants