From owner-freebsd-bugs@freebsd.org Thu Jul 23 19:05:51 2020 Return-Path: Delivered-To: freebsd-bugs@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 36C733604DA for ; Thu, 23 Jul 2020 19:05:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BCMHM0kv2z41Ph for ; Thu, 23 Jul 2020 19:05:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 178AC36054D; Thu, 23 Jul 2020 19:05:51 +0000 (UTC) Delivered-To: bugs@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 1751E3601E8 for ; Thu, 23 Jul 2020 19:05:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BCMHL70Bvz41VT for ; Thu, 23 Jul 2020 19:05:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF6581DA33 for ; Thu, 23 Jul 2020 19:05:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 06NJ5o27068120 for ; Thu, 23 Jul 2020 19:05:50 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 06NJ5o40068119 for bugs@FreeBSD.org; Thu, 23 Jul 2020 19:05:50 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248223] Linuxulator: pread behavior differences Date: Thu, 23 Jul 2020 19:05:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: iwtcex@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2020 19:05:51 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248223 Bug ID: 248223 Summary: Linuxulator: pread behavior differences Product: Base System Version: 12.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: iwtcex@gmail.com % cat pread.c #define _GNU_SOURCE #include #include #include #include #include #include #include void pread_v(int fd, void* buf, size_t nbytes, off64_t offset) { printf("pread(_, _, 0x%lx, _) -> ", nbytes); int ret =3D pread(fd, buf, nbytes, offset); if (ret !=3D -1) { printf("0x%x\n", ret); } else { printf("%s\n", strerror(errno)); } } int main() { int mem =3D open("/proc/self/mem", O_RDONLY); assert(mem !=3D -1); char buf[0x4000]; pread_v(mem, buf, 0x1000, 0); // should be EIO printf("---\n"); void* p1 =3D mmap(NULL, 0x2000, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); void* p2 =3D mmap(p1 + 0x1000, 0x1000, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); assert(p1 !=3D MAP_FAILED); assert(p2 =3D=3D p1 + 0x1000); assert(munmap(p2, 0x1000) =3D=3D 0); for (int n =3D sizeof(buf); n >=3D 0x1000; n /=3D 2) { pread_v(mem, buf, n, (off64_t)p1); // should return 0x1000 } return 0; } % /compat/linux/bin/gcc -std=3Dc99 -Wall pread.c -o pread % ./pread pread(_, _, 0x1000, _) -> Bad address --- pread(_, _, 0x4000, _) -> Bad address pread(_, _, 0x2000, _) -> Bad address pread(_, _, 0x1000, _) -> 0x1000 On the other hand, Linux (Xubuntu 18.04.3) prints Input/Output errors and 0x1000, 0x1000, 0x1000 there. --=20 You are receiving this mail because: You are the assignee for the bug.=