Bug 240432 - Linuxulator: uname (function) reports i686 machine to 32-bit executables on amd64
Summary: Linuxulator: uname (function) reports i686 machine to 32-bit executables on a...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2019-09-09 05:35 UTC by Alex S
Modified: 2020-08-24 13:01 UTC (History)
3 users (show)

See Also:


Attachments
Slightly improved test program (281 bytes, text/plain)
2020-06-12 20:34 UTC, Edward Tomasz Napierala
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex S 2019-09-09 05:35:15 UTC
Consider the following program compiled with -m32 flag:

#include <stdio.h>
#include <sys/utsname.h>

int main() {
  struct utsname name;
  uname(&name);
  printf("machine: %s\n", name.machine);  
  return 0;
}

This prints "machine: i686" under Linuxulator, while Ubuntu 18.04 gives me "machine: x86_64".
Comment 1 Theron Tarigo 2019-09-09 20:21:19 UTC
Which would be the correct behavior?
(1) Always return x86_64 for FreeBSD on amd64 CPU.
(2) Conditionally return x86_64 vs. i686 on whether linux64 module is loaded.
Comment 2 Alex S 2019-09-09 23:23:45 UTC
For reference, my use case is the Linux Steam client, which uses this information to decide whether you are allowed to install 64-bit games. The client itself is 32-bit application.

Of course, I already have a workaround applied (https://github.com/shkhln/linuxulator-steam-utils/blob/5ec9e681e97e0c797202f058210602c71e17e009/src/steamfix.c#L144). I just thought it would be nice to report this. 

(In reply to Theron Tarigo from comment #1)
> Which would be the correct behavior?
> ...
> (2) Conditionally return x86_64 vs. i686
> on whether linux64 module is loaded.
Is there any practical reason not to load linux64 in the first place?
Comment 3 Edward Tomasz Napierala freebsd_committer freebsd_triage 2020-06-12 20:25:52 UTC
Proposed patch: https://reviews.freebsd.org/D25248
Comment 4 Edward Tomasz Napierala freebsd_committer freebsd_triage 2020-06-12 20:34:58 UTC
Created attachment 215495 [details]
Slightly improved test program
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-06-15 20:12:57 UTC
A commit references this bug:

Author: trasz
Date: Mon Jun 15 20:12:11 UTC 2020
New revision: 362205
URL: https://svnweb.freebsd.org/changeset/base/362205

Log:
  Make Linux uname(2) return x86_64 to 32-bit apps.  This helps Steam.

  PR:		kern/240432
  Analyzed by by:	Alex S <iwtcex@gmail.com>
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D25248

Changes:
  head/sys/compat/linux/linux_misc.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-08-24 12:54:36 UTC
A commit references this bug:

Author: trasz
Date: Mon Aug 24 12:54:20 UTC 2020
New revision: 364668
URL: https://svnweb.freebsd.org/changeset/base/364668

Log:
  MFC r362205:

  Make Linux uname(2) return x86_64 to 32-bit apps.  This helps Steam.

  PR:		kern/240432
  Analyzed by:	Alex S <iwtcex@gmail.com>
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/12/
  stable/12/sys/compat/linux/linux_misc.c