From: Eric Blake <eblake@redhat.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: anthony.perard@citrix.com, xen-devel@lists.xensource.com,
aneesh.kumar@linux.vnet.ibm.com, qemu-devel@nongnu.org,
groug@kaod.org
Subject: Re: [Qemu-devel] [PATCH] Fix issues affecting Xen 9pfs discovered by Coverity
Date: Mon, 8 May 2017 17:05:01 -0500 [thread overview]
Message-ID: <356752db-bd70-a908-141e-eec99f4c15e2@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1705081459030.24729@sstabellini-ThinkPad-X260>
[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]
On 05/08/2017 05:00 PM, Stefano Stabellini wrote:
>>> Directly calling fcntl(F_SETFD) without first reading fcntl(F_GETFD) is
>>> (theoretically) incorrect. Better might be using qemu_set_cloexec()
>>> instead of open-coding something.
>>
>> Makes sense but the unchecked return of fcntl, discovered by Coverity,
>> would remain unfixed by calling qemu_set_cloexec here. I don't think I
>> am up for fixing all the call sites of qemu_set_cloexec.
>>
>> I am going to drop this change, and resend this patch was only the other
>> two fixes, fixing 1374836 only.
>
> Unless you would be fine with:
>
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 4d9189e..16894ad 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -182,7 +182,9 @@ void qemu_set_cloexec(int fd)
> {
> int f;
> f = fcntl(fd, F_GETFD);
> - fcntl(fd, F_SETFD, f | FD_CLOEXEC);
> + assert(f != -1);
> + f = fcntl(fd, F_SETFD, f | FD_CLOEXEC);
> + assert(f != -1);
Seems reasonable to me, but I don't know if anyone else would object.
Changes semantics if someone ever calls qemu_set_cloexec(-1) (previously
it would ignore the EBADF failures, now it will abort) - such callers
are arguably broken, so that's okay by me.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2017-05-08 22:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 20:45 [Qemu-devel] [PATCH] Fix issues affecting Xen 9pfs discovered by Coverity Stefano Stabellini
2017-05-08 21:11 ` Eric Blake
2017-05-08 21:57 ` Stefano Stabellini
2017-05-08 22:00 ` Stefano Stabellini
2017-05-08 22:05 ` Eric Blake [this message]
2017-05-09 12:28 ` Greg Kurz
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=356752db-bd70-a908-141e-eec99f4c15e2@redhat.com \
--to=eblake@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=anthony.perard@citrix.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xensource.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.
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).