Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbdFSQPV (ORCPT ); Mon, 19 Jun 2017 12:15:21 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56796 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbdFSQPS (ORCPT ); Mon, 19 Jun 2017 12:15:18 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CA44C60925 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org Date: Mon, 19 Jun 2017 10:15:09 -0600 From: Jordan Crouse To: linux-sparse@vger.kernel.org Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: __user with scalar data types Message-ID: <20170619161509.GA25997@jcrouse-lnx.qualcomm.com> Mail-Followup-To: linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1190 Lines: 42 A number of us over in DRM land have been using __u64 scalar types to store pointers for uapi structures in accordance with Daniel Vetter's now classic treatise on ioctls: http://blog.ffwll.ch/2013/11/botching-up-ioctls.html A smaller number of us have further been marking the __u64 with __user, to wit: struct uapistruct { ... __u64 __user myptr; --- }; And then converting it for use in the kernel as such: { void __user *userptr = (void __user *)(uintptr_t)args->myptr; copy_from_user(local, userptr, size); ... } The problem is that sparse doesn't like the momentary switch to uintptr_t: warning: dereference of noderef expression Which raised a bikeshed debate over whether it is appropriate to mark a scalar type as __user. My opinion is that it is appropriate because __user should mark user memory regardless of the container. I'm looking for opinions or semi-authoritative edicts to determine if we should either start changing our uapi headers or go off and try to figure out how to make sparse understand this particular usage. Thanks! Jordan -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project