qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Cc: Bandan Das <bsd@redhat.com>
Subject: Re: [Qemu-devel] [PULL 4/5] usb-mtp: Introduce write support for MTP objects
Date: Tue, 20 Feb 2018 14:47:33 -0600	[thread overview]
Message-ID: <869a9977-cc4d-1638-53f7-5966f6e3be52@redhat.com> (raw)
In-Reply-To: <20180220152843.26464-5-kraxel@redhat.com>

On 02/20/2018 09:28 AM, Gerd Hoffmann wrote:
> From: Bandan Das <bsd@redhat.com>
> 
> Allow write operations on behalf of the initiator. The
> precursor to write is the sending of the write metadata
> that consists of the ObjectInfo dataset. This patch introduces
> a flag that is set when the responder is ready to receive
> write data based on a previous SendObjectInfo operation by
> the initiator (The SendObjectInfo implementation is in a
> later patch)
> 
> Signed-off-by: Bandan Das <bsd@redhat.com>
> Message-id: 20180215231129.14710-5-bsd@redhat.com
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   hw/usb/dev-mtp.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 157 insertions(+), 2 deletions(-)
> 

> @@ -1472,12 +1492,133 @@ static void usb_mtp_cancel_packet(USBDevice *dev, USBPacket *p)
>       fprintf(stderr, "%s\n", __func__);
>   }
>   
> +mode_t getumask(void)
> +{
> +    mode_t mask = umask(0);
> +    umask(mask);
> +    return mask;
> +}

This is dangerous.  'man getumask' on my Fedora machine states:

CONFORMING TO
        This is a vaporware GNU extension.

NOTES
        This  function is documented in the glibc manual, but, as at 
glibc ver‐
        sion 2.24, it is not implemented on Linux.  (See umask(2) for a 
thread-
        safe method of discovering a process's umask.)


and 'man 2 umask' concurs:

        It  is  impossible to use umask() to fetch a process's umask 
without at
        the same time changing it.  A second call  to  umask()  would 
then  be
        needed  to restore the umask.  The nonatomicity of these two 
steps pro‐
        vides the potential for races in multithreaded programs.

It is ONLY safe to grab umask() prior to spawning threads, cache that 
value, and refer to the cache at all later points.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-02-20 20:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 15:28 [Qemu-devel] [PULL 0/5] Usb 20180220 patches Gerd Hoffmann
2018-02-20 15:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: Add one more argument when building results Gerd Hoffmann
2018-02-20 15:28 ` [Qemu-devel] [PULL 2/5] usb-mtp: print parent path in IN_IGNORED trace fn Gerd Hoffmann
2018-02-20 15:28 ` [Qemu-devel] [PULL 3/5] usb-mtp: Support delete of mtp objects Gerd Hoffmann
2018-02-20 15:28 ` [Qemu-devel] [PULL 4/5] usb-mtp: Introduce write support for MTP objects Gerd Hoffmann
2018-02-20 20:47   ` Eric Blake [this message]
2018-02-20 21:27     ` Bandan Das
2018-02-20 15:28 ` [Qemu-devel] [PULL 5/5] usb-mtp: Advertise SendObjectInfo for write support Gerd Hoffmann
2018-02-20 17:03 ` [Qemu-devel] [PULL 0/5] Usb 20180220 patches Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2018-02-27  8:39 [Qemu-devel] [PULL 0/5] Usb 20180227 patches Gerd Hoffmann
2018-02-27  8:39 ` [Qemu-devel] [PULL 4/5] usb-mtp: Introduce write support for MTP objects Gerd Hoffmann
2018-04-27 13:38   ` Peter Maydell
2018-04-30 17:56     ` Bandan Das

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=869a9977-cc4d-1638-53f7-5966f6e3be52@redhat.com \
    --to=eblake@redhat.com \
    --cc=bsd@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).