From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751529AbdILOPV (ORCPT ); Tue, 12 Sep 2017 10:15:21 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:46875 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbdILOPU (ORCPT ); Tue, 12 Sep 2017 10:15:20 -0400 Subject: Re: [PATCH v3 11/13] xen/pvcalls: implement poll command To: Stefano Stabellini References: <1501541855-7354-1-git-send-email-sstabellini@kernel.org> <1501541855-7354-11-git-send-email-sstabellini@kernel.org> <702cfa9c-5f14-07a3-63ba-93648ff66d9b@oracle.com> Cc: xen-devel@lists.xen.org, linux-kernel@vger.kernel.org, jgross@suse.com, Stefano Stabellini From: Boris Ostrovsky Message-ID: <6c9613d8-8219-d06f-9095-fa57474ed518@oracle.com> Date: Tue, 12 Sep 2017 10:14:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> + >>> +unsigned int pvcalls_front_poll(struct file *file, struct socket *sock, >>> + poll_table *wait) >>> +{ >>> + struct pvcalls_bedata *bedata; >>> + struct sock_mapping *map; >>> + >>> + if (!pvcalls_front_dev) >>> + return POLLNVAL; >>> + bedata = dev_get_drvdata(&pvcalls_front_dev->dev); >>> + >>> + map = (struct sock_mapping *) READ_ONCE(sock->sk->sk_send_head); >> I just noticed this --- why is it READ_ONCE? Are you concerned that >> sk_send_head may change? > No, but I wanted to avoid partial reads. A caller could call > pvcalls_front_accept and pvcalls_front_poll on newsock almost at the > same time (it is probably not the correct way to use the API), I wanted > to make sure that "map" is either read correctly, or not read at all. How can you have a partial read on a pointer? -boris