* [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0)
@ 2017-09-10 23:29 Zhuowei Zhang
2018-09-07 10:56 ` [Qemu-devel] [Bug 1716292] " Tony Garnock-Jones
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Zhuowei Zhang @ 2017-09-10 23:29 UTC (permalink / raw)
To: qemu-devel
Public bug reported:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with zero
length and a null pointer correctly: on Linux this returns 0, but in
emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
** Affects: qemu
Importance: Undecided
Status: New
** Description changed:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
- OS version: Ubuntu 14.04.3
+ OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with zero
length and a null pointer correctly: on Linux this returns 0, but in
emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
- ssize_t ret = write(STDOUT_FILENO, NULL, 0);
- fprintf(stderr, "write returned %ld\n", ret);
- return 0;
+ ssize_t ret = write(STDOUT_FILENO, NULL, 0);
+ fprintf(stderr, "write returned %ld\n", ret);
+ return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
- zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
- write returned 0
+ zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
+ write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1716292
Title:
User mode emulation returns wrong value for write(fd, NULL, 0)
Status in QEMU:
New
Bug description:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with
zero length and a null pointer correctly: on Linux this returns 0, but
in emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1716292/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1716292] Re: User mode emulation returns wrong value for write(fd, NULL, 0)
2017-09-10 23:29 [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0) Zhuowei Zhang
@ 2018-09-07 10:56 ` Tony Garnock-Jones
2018-09-07 11:51 ` Tony Garnock-Jones
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Tony Garnock-Jones @ 2018-09-07 10:56 UTC (permalink / raw)
To: qemu-devel
This happens for me also, with qemu version 2.12.0 (Debian
1:2.12+dfsg-3).
An initial patch was proposed here: https://lists.gnu.org/archive/html
/qemu-devel/2017-09/msg08073.html
Discussion pointed out some problems, and the patch languished and was
not accepted.
Here is a summary of the changes needed for it to be more likely for the
patch to be accepted: https://lists.gnu.org/archive/html/qemu-
devel/2018-02/msg03964.html
- change from "ret = 0" to something like "ret = get_errno(safe_write(arg1, NULL, 0))"
- change TARGET_NR_read to do the same, instead of its current short-circuit behaviour for count==0
- check pread64/pwrite64 to see if they need a similar change as well
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1716292
Title:
User mode emulation returns wrong value for write(fd, NULL, 0)
Status in QEMU:
New
Bug description:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with
zero length and a null pointer correctly: on Linux this returns 0, but
in emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1716292/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1716292] Re: User mode emulation returns wrong value for write(fd, NULL, 0)
2017-09-10 23:29 [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0) Zhuowei Zhang
2018-09-07 10:56 ` [Qemu-devel] [Bug 1716292] " Tony Garnock-Jones
@ 2018-09-07 11:51 ` Tony Garnock-Jones
2018-09-07 13:59 ` Eric Blake
2018-10-04 12:37 ` Thomas Huth
2018-12-12 9:21 ` Thomas Huth
3 siblings, 1 reply; 6+ messages in thread
From: Tony Garnock-Jones @ 2018-09-07 11:51 UTC (permalink / raw)
To: qemu-devel
** Patch added: "0001-Bring-linux-user-write-2-handling-into-line-with-lin.patch"
https://bugs.launchpad.net/qemu/+bug/1716292/+attachment/5186008/+files/0001-Bring-linux-user-write-2-handling-into-line-with-lin.patch
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1716292
Title:
User mode emulation returns wrong value for write(fd, NULL, 0)
Status in QEMU:
New
Bug description:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with
zero length and a null pointer correctly: on Linux this returns 0, but
in emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1716292/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Bug 1716292] Re: User mode emulation returns wrong value for write(fd, NULL, 0)
2018-09-07 11:51 ` Tony Garnock-Jones
@ 2018-09-07 13:59 ` Eric Blake
0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2018-09-07 13:59 UTC (permalink / raw)
To: Bug 1716292, qemu-devel
On 09/07/2018 06:51 AM, Tony Garnock-Jones wrote:
> ** Patch added: "0001-Bring-linux-user-write-2-handling-into-line-with-lin.patch"
> https://bugs.launchpad.net/qemu/+bug/1716292/+attachment/5186008/+files/0001-Bring-linux-user-write-2-handling-into-line-with-lin.patch
While a developer can chase a URL, our CI tools can't. Can you please
also send that patch directly to qemu-devel@nongnu.org, so that it gets
the same level of review as other patches?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1716292] Re: User mode emulation returns wrong value for write(fd, NULL, 0)
2017-09-10 23:29 [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0) Zhuowei Zhang
2018-09-07 10:56 ` [Qemu-devel] [Bug 1716292] " Tony Garnock-Jones
2018-09-07 11:51 ` Tony Garnock-Jones
@ 2018-10-04 12:37 ` Thomas Huth
2018-12-12 9:21 ` Thomas Huth
3 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2018-10-04 12:37 UTC (permalink / raw)
To: qemu-devel
Fix has been committed here:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=58cfa6c2e6eb51b23cc98
** Changed in: qemu
Status: New => Fix Committed
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1716292
Title:
User mode emulation returns wrong value for write(fd, NULL, 0)
Status in QEMU:
Fix Committed
Bug description:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with
zero length and a null pointer correctly: on Linux this returns 0, but
in emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1716292/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1716292] Re: User mode emulation returns wrong value for write(fd, NULL, 0)
2017-09-10 23:29 [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0) Zhuowei Zhang
` (2 preceding siblings ...)
2018-10-04 12:37 ` Thomas Huth
@ 2018-12-12 9:21 ` Thomas Huth
3 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2018-12-12 9:21 UTC (permalink / raw)
To: qemu-devel
** Changed in: qemu
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1716292
Title:
User mode emulation returns wrong value for write(fd, NULL, 0)
Status in QEMU:
Fix Released
Bug description:
QEMU version: latest master (fcea73709b966a7ded9efa7b106ea50c7fe9025c)
OS version: Ubuntu 14.04.5
Configured with: ../configure --target-list=x86_64-linux-user
QEMU Linux usermode emulation does not handle write() syscalls with
zero length and a null pointer correctly: on Linux this returns 0, but
in emulation this returns -1.
I ran into this while using an aarch64 abuild-tar from Alpine Linux in
user-mode emulation; here's the minimized reproduction test case:
zhuowei@zhuowei-tablet:/tmp$ cat writezerobytes.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
ssize_t ret = write(STDOUT_FILENO, NULL, 0);
fprintf(stderr, "write returned %ld\n", ret);
return 0;
}
zhuowei@zhuowei-tablet:/tmp$ gcc -o writezerobytes writezerobytes.c
zhuowei@zhuowei-tablet:/tmp$ uname -a
Linux zhuowei-tablet 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
zhuowei@zhuowei-tablet:/tmp$ ./writezerobytes
write returned 0
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 ./writezerobytes
write returned -1
zhuowei@zhuowei-tablet:/tmp$ /media/zhuowei/redhd/docs/repos/qemu/build4/x86_64-linux-user/qemu-x86_64 --version
qemu-x86_64 version 2.10.50 (v2.10.0-471-gfcea737-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1716292/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-12 9:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-10 23:29 [Qemu-devel] [Bug 1716292] [NEW] User mode emulation returns wrong value for write(fd, NULL, 0) Zhuowei Zhang
2018-09-07 10:56 ` [Qemu-devel] [Bug 1716292] " Tony Garnock-Jones
2018-09-07 11:51 ` Tony Garnock-Jones
2018-09-07 13:59 ` Eric Blake
2018-10-04 12:37 ` Thomas Huth
2018-12-12 9:21 ` Thomas Huth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.