From owner-freebsd-questions@freebsd.org Wed Jul 21 21:04:32 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3183966CB42 for ; Wed, 21 Jul 2021 21:04:32 +0000 (UTC) (envelope-from rdbodev@gmail.com) Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GVSkl35Xrz3F2j for ; Wed, 21 Jul 2021 21:04:31 +0000 (UTC) (envelope-from rdbodev@gmail.com) Received: by mail-ed1-x52c.google.com with SMTP id x17so4103246edd.12 for ; Wed, 21 Jul 2021 14:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=vZ+dDI1gpv4VapBkbLgl0KcTEecPnF0neMOBlWhppt4=; b=N4hf+jToF6E4VrRFDGah+JJ84p0lHRCbRlf4yo6ZvWigmpkjsE5j0arId9jR5OyxCQ K4dsiodabe8CLO/grHj7A8iHdOx8rW+Dn5NPTFNNUOr/ltrDDNnQTQrhQE2Joo9ZvB/k XPU18mWqZr+xwbnPixdIl1ko/Xm5FEfPrOt0P4206I3FVoz3B7c5s1a3BBCXQNlT8tBI qLpOstu4GI+uDEJemvsjbfJLizTJL91h0sr9grYG1dvUUzJuTeaQ73ZWz5GF9GWACqcM SqZQ4E9VF6bBxRm+pkGeUyN/QXtmINH6X9WvXvWq6cklur2L/OqylGmWyRkKdYFM2y9s sg8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=vZ+dDI1gpv4VapBkbLgl0KcTEecPnF0neMOBlWhppt4=; b=ATup/X36K6jRcRq+87Hu7T1l/guruaXbVrc6vcfvi2UN0Ov18sFxnY6T/8ysBoO9c3 f8CX2EYsPlEYS0n6NJCod4lKqniCEsLYrQmiEqTDWlMNFsdo+ZR6gkKs6grKsuEAqZSR WWqz+jjBeT9EaLE3OwXv3BJCG+FIz/2/QHGCg4tlDiPJ0+IMQ84y46u+FE8mg5w3Nz9i ewrHGQ20PEK49WNayKgC6EmSAlgMQU/toyudju4tfB8Jr2JN2FoM8aGrg43Dq0t3gIhC 36EXnXEFB8ioEld6L6yEg2EvBuBVSWmQgXlmun9WiibtkP52zZP3lRGZI/Z+bNWdWHTe 7fNQ== X-Gm-Message-State: AOAM532DYTvJ14ZeDdnVE6hzE1NorMPvG1BbfbhufGOCe9b6NYIztSHo hCBh9tTKaWC08AkRbnL8TrmlNzKCI1MMQWGSI9X+Gd21fxOJIg== X-Google-Smtp-Source: ABdhPJypSrWyiqjP7gGcsRWft9FxuB40nKQdaVbMWtmoRd0P6HTOyUZVoOUfnqmGflqgBd3QUolBgVBr8/fFWIAPH2w= X-Received: by 2002:a05:6402:697:: with SMTP id f23mr49529252edy.44.1626901469229; Wed, 21 Jul 2021 14:04:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rdbo Date: Wed, 21 Jul 2021 18:07:38 -0300 Message-ID: Subject: Re: Understanding the behavior of the 32 bit mmap system call To: freebsd-questions@freebsd.org X-Rspamd-Queue-Id: 4GVSkl35Xrz3F2j X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=N4hf+jTo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rdbodev@gmail.com designates 2a00:1450:4864:20::52c as permitted sender) smtp.mailfrom=rdbodev@gmail.com X-Spamd-Result: default: False [-0.94 / 15.00]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::52c:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.80)[0.795]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::52c:from:127.0.2.255]; NEURAL_SPAM_LONG(0.26)[0.262]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::52c:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-questions] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 21:04:32 -0000 By remote process, I meant a tracer. Because apparently the syscall arguments are passed on the stack, I'm gonna have to modify my shellcode a little in order for the syscall injection to work. I thought it was going to be the same way as on Linux, apparently not. I'll report back if I get it working. Em ter., 20 de jul. de 2021 =C3=A0s 09:15, Rdbo escreve= u: > Hi, I'm a hobbyist developer working on a multiplatform, multiarch memory > library, and I chose FreeBSD to be one of the supported operating systems= . > I was playing around with the SYS_mmap system call and I noticed that, fo= r > x86_32, you have to pass a struct containing all the mmap arguments, rath= er > than the arguments themselves. The thing is, this structure is not passed > as a pointer (like on Linux, for example), so I don't see how one would d= o > this syscall from a remote process, as each register is responsible for o= ne > argument of the syscall, and a single register can't store a structure th= is > size. I've tried passing the structure as a pointer, passing each mmap > argument in a separate register (like __NR_mmap2 on Linux), looking for > alternative mmap system calls that do not require the struct parameter. > Unfortunately, these attempts have all failed. > TLDR; how to run a 32 bit SYS_mmap system call from a remote process when > a single register can't fit the whole structure and the structure is not > passed as a pointer? > Regards, rdbo >