qga umask fix addenda
v2 cover qga umask fix addenda
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that qemu_set_cloexec() never fails internally. This should be a reasonable assumption when the input fd is valid.)
Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file if fchmod() or fdopen() fails on
it
qga/commands-posix.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-)
PATCH v2 1/2 qga: distinguish binary modes in "guest_file_open_modes" map
In Windows guests this may make a difference.
Since the original patch (commit c689b4f1) sought to be pedantic and to consider theoretical corner cases of portability, we should fix it up where it failed to come through in that pursuit.
--- qga/commands-posix.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-)
qga/commands-posix.c +16 -6
@@ -242,17 +242,27 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)typedef const char *const ccpc ; +#ifndef O_BINARY +#define O_BINARY 0 +#endif +/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */ static const struct {ccpc *forms;int oflag_base; } guest_file_open_modes[] = { - { (ccpc []){"r" ,"rb" ,NULL },O_RDONLY }, - { (ccpc []){"w" ,"wb" ,NULL },O_WRONLY |O_CREAT |O_TRUNC }, - { (ccpc []){"a" ,"ab" ,NULL },O_WRONLY |O_CREAT |O_APPEND }, - { (ccpc []){"r+" ,"rb+" ,"r+b" ,NULL },O_RDWR }, - { (ccpc []){"w+" ,"wb+" ,"w+b" ,NULL },O_RDWR |O_CREAT |O_TRUNC }, - { (ccpc []){"a+" ,"ab+" ,"a+b" ,NULL },O_RDWR |O_CREAT |O_APPEND } + { (ccpc []){"r" ,NULL },O_RDONLY }, + { (ccpc []){"rb" ,NULL },O_RDONLY |O_BINARY }, + { (ccpc []){"w" ,NULL },O_WRONLY |O_CREAT |O_TRUNC }, + { (ccpc []){"wb" ,NULL },O_WRONLY |O_CREAT |O_TRUNC |O_BINARY }, + { (ccpc []){"a" ,NULL },O_WRONLY |O_CREAT |O_APPEND }, + { (ccpc []){"ab" ,NULL },O_WRONLY |O_CREAT |O_APPEND |O_BINARY }, + { (ccpc []){"r+" ,NULL },O_RDWR }, + { (ccpc []){"rb+" ,"r+b" ,NULL },O_RDWR |O_BINARY }, + { (ccpc []){"w+" ,NULL },O_RDWR |O_CREAT |O_TRUNC }, + { (ccpc []){"wb+" ,"w+b" ,NULL },O_RDWR |O_CREAT |O_TRUNC |O_BINARY }, + { (ccpc []){"a+" ,NULL },O_RDWR |O_CREAT |O_APPEND }, + { (ccpc []){"ab+" ,"a+b" ,NULL },O_RDWR |O_CREAT |O_APPEND |O_BINARY } }; static int
Signature · 1 line
1.7.1
PATCH v2 2/2 qga: unlink just created guest-file if fchmod() or fdopen() fails on it
In reply to Laszlo ErsekWe shouldn't allow guest filesystem pollution on error paths.
--- qga/commands-posix.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
qga/commands-posix.c +3 -0
@@ -355,6 +355,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err) }close (fd); +if (oflag &O_CREAT ) { +unlink (path); + } } }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 2/2] qga: unlink just created guest-file if fchmod() or fdopen() fails on it
Quoted 7 lines · Laszlo Ersek
We shouldn't allow guest filesystem pollution on error paths.
Suggested-by Eric Blake <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>--- qga/commands-posix.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 16 lines
qga/commands-posix.c +3
-0@@ -355,6 +355,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err) }close (fd); +if (oflag &O_CREAT ) { +unlink (path); + } } }
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · On Wed, 8 May 2013 17:31:34 +0200 Laszlo Ersek <[email protected]> wrote:
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)
Series:
Quoted 10 lines
Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
itqga/commands-posix.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-)
mdroth
AppliedQuoted 11 lines · Laszlo Ersek
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
it
Thanks, applied to qga branch:
https://github.com/mdroth/qemu/commits/qga
Quoted 4 lines
qga/commands-posix.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-)
Quoted 8 lines · mdroth
Quoted 7 lines · Laszlo Ersek
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)
Quoted 8 lines
Quoted 4 lines
Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
itThanks, applied to qga branch:
Thanks!
Can you reword the second commit to include Eric's R-b?
<http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg01179.html>
Thanks!
Laszlo
Quoted 14 lines · Laszlo Ersek
Quoted 13 lines · mdroth
Quoted 11 lines · Laszlo Ersek
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
it
Quoted 8 lines
Quoted 3 lines
Thanks, applied to qga branch:
Thanks!
Can you reword the second commit to include Eric's R-b?
<http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg01179.html>
Sure, missed that one. Should be fixed in tree now.
Quoted 4 lines
Thanks!
Laszlo
Am 10.05.2013 22:09, schrieb mdroth:
Quoted 17 lines · Laszlo Ersek
Quoted 16 lines · mdroth
Quoted 15 lines · Laszlo Ersek
Quoted 11 lines
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
itThanks, applied to qga branch:
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Thanks!
Can you reword the second commit to include Eric's R-b?
<http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg01179.html>Sure, missed that one. Should be fixed in tree now.
Shouldn't at least the unlinking be backported to stable as well?
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 20 lines · Andreas Färber
Am 10.05.2013 22:09, schrieb mdroth:
Quoted 19 lines · Laszlo Ersek
Quoted 18 lines · mdroth
Quoted 16 lines · Laszlo Ersek
Quoted 11 lines
I should have paid more attention to portability and error path cleanup in the CVE-2013-2007 fix.
(We continue to assume, like the rest of qemu code, that
qemu_set_cloexec()never fails internally. This should be a reasonable assumption when the input fd is valid.)Laszlo Ersek (2):
qga: distinguish binary modes in "guest_file_open_modes" map
qga: unlink just created guest-file iffchmod()orfdopen()fails on
itThanks, applied to qga branch:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Thanks!
Can you reword the second commit to include Eric's R-b?
<http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg01179.html>Sure, missed that one. Should be fixed in tree now.
Shouldn't at least the unlinking be backported to stable as well?
Yes, these are basically updates to the CVE fix, so I think they should all be applied to stable. I'll send PULL today so hopefully we can get them into 1.5 prior to patch freeze for 1.4.2. Otherwise I'll backport from the qga tree.
Quoted 7 lines
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg