mailing list of musl libc
 help / color / mirror / code / Atom feed
From: ca0 <ca0@protonmail.ch>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: [musl] socketcall syscall on x32 ABI producing incorrect results
Date: Sun, 26 Mar 2023 21:12:41 +0000	[thread overview]
Message-ID: <RVjBr0Pxqg5uJL0_Sh1AEYZ8LsOUXKnYP3JJb11MQWe_PgjBn3jhM7BG5ih11jrtgBFClxHX-7AKBNh2dNaFAOGkuToDv1BfHZvpW-Zs_60=@protonmail.ch> (raw)

I am running busybox with musl-1.2.3 on x32 linux with gcc-12.2.0.

The syscall returns bad address in the case of the bind call. I have traced this down to the pointer being 0xf...... in 32bits being sign extended to 32bits in the syscall.

Here is the code:
0xf7f687ec	65		else r = __syscall(sys, a, b, c, d, e, f);
0xf7f687e9 <__alt_socketcall+178>:	48 63 d0           	movslq %eax,%rdx

I can see the address being sign extended as intended by the movslq instruction.

If I change the bind implementation to cast this address I do not see this issue, but other issues arise with the soecket call

ie. in bind 
int bind(int fd, const struct sockaddr *addr, socklen_t len)
{
    long b = ((unsigned long)(addr)  & 0xffffffff);
    freturn socketcall(bind, fd, b, len, 0, 0, 0);
}

Is this a known issue as x32 is marked as experimental.

Sent with Proton Mail secure email.

             reply	other threads:[~2023-03-26 21:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26 21:12 ca0 [this message]
2023-03-26 21:16 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='RVjBr0Pxqg5uJL0_Sh1AEYZ8LsOUXKnYP3JJb11MQWe_PgjBn3jhM7BG5ih11jrtgBFClxHX-7AKBNh2dNaFAOGkuToDv1BfHZvpW-Zs_60=@protonmail.ch' \
    --to=ca0@protonmail.ch \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).