Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7880016pxb; Fri, 19 Feb 2021 01:29:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYRG9zgh4fMNPiEyPU3Xw3dI+CptqKALaXng2X7WUC3qIJNZWHwn/G0JJ3loeGs3dfE2ku X-Received: by 2002:a05:6402:3582:: with SMTP id y2mr8269052edc.345.1613726992694; Fri, 19 Feb 2021 01:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613726992; cv=none; d=google.com; s=arc-20160816; b=vT7FR20P8zajLuqEqMtLyPpv/z82pd5sKuz+Gn0gdZX6YRcyI3tl50Ieo1cOvWwWyj DeQNN11hmQLOib3FOe2X4ydPpIgv0OTSvtCSWCPioqdpl1Aeq+jhHkfXxuOGJfEAS425 Q2D6EvpNJ5k37OgGpgZb+KytUz5YE1CwNyXfHIJTvo77reX7iXJ4JSeySj4+h7YMM+zA IyLPMwjS2eZOshrdbnx5mUYiBDtPnu5huzLkxjfT1Z1KzeAo7O3+0yatef/BKrSYfH2B 28Tihqr+tCuhJhjsBUUpfvJXFeSgIKZBCXq/wM8SUmELS6Uen4hCWqf458FrxZ4pjxoa hMvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+jSkHsONTkTAseVQX+sbaAc6sHzUxCQX5x/sMxZIGnw=; b=Sk31LbONiLSMmU87ncU5l2fhVn0IytAM6As8kGTYwynqESbO9wlFXscQRY6L1j87u+ dlRzoZikHHHrEmREHuoNwsqK7Cs1MaYhriKN4Pac3lRNxO/2ZJRQOaPOItlp2BwubOQQ NQnbS2iY30bMRiluZJgYZK8xJIaeUtaja9mcaeL4qMnbkiEftt/th06mBlBY33KEPObO WJFgSXquuFF8+bVn2Umr7z2SynSf4PDI1xClb0kJb/I9YVtkxDx09uNno58jyvq2OH+C KY1AjeG03oEPhRrvji6pReK+YCBgCmKejmrJES+JtcekDOhwGWNwhwCsT/7E8uTAgRI7 1LCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=VWWO5tkc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s14si5712033edr.75.2021.02.19.01.29.28; Fri, 19 Feb 2021 01:29:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=VWWO5tkc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbhBSJ1c (ORCPT + 99 others); Fri, 19 Feb 2021 04:27:32 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:36504 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbhBSJ13 (ORCPT ); Fri, 19 Feb 2021 04:27:29 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11J9OqRU022352; Fri, 19 Feb 2021 09:26:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=+jSkHsONTkTAseVQX+sbaAc6sHzUxCQX5x/sMxZIGnw=; b=VWWO5tkc6ARoeLA2pZ2HJX/Cx2EZlcWKG94D1ZVPy5oY2slSwJQDd3DcGSq3gaQfdh8Q QeoFEOPKQtEacgT1TPVKpHYXV9CaZljb2iGe7+RNzQL4lljkGVbKgjWA474ccJ3APoZQ FUKiXCh8qPWm9AyBfRvX2wd1CQ6R58lZ7PFb4Gkl6KcYslQdTh2KI8lVclm4HctnGaE9 fuCBAXhczlwXtJ9OWbhoyjbVL68aPu+buKitrHX4chhXarzuhyS8yXnsehhaemqlMOYY 1zKA4IM7vAJkkNJl7YylOqINM2DyLuL+HQn5hWIdQsb4tNalFBgJurhd8ghM9dWQAUSd sA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 36p49bgxhu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:26:38 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11J9KVhH115387; Fri, 19 Feb 2021 09:26:36 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 36prbrxcvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:26:36 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 11J9QX7b022082; Fri, 19 Feb 2021 09:26:33 GMT Received: from kadam (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Feb 2021 01:26:32 -0800 Date: Fri, 19 Feb 2021 12:26:21 +0300 From: Dan Carpenter To: David Laight Cc: "'Ian Abbott'" , Greg KH , Atul Gopinathan , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] staging: comedi: cast to (unsigned int *) Message-ID: <20210219092621.GU2087@kadam> References: <20210217165907.9777-1-atulgopinathan@gmail.com> <20210217181000.GB10124@atulu-ubuntu> <3cfef23d-8d4a-205c-61e8-cbe8c9a0c0f4@mev.co.uk> <21a953261eb44e7ba302cfe74d8efa2d@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21a953261eb44e7ba302cfe74d8efa2d@AcuMS.aculab.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9899 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9899 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 phishscore=0 clxscore=1011 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190073 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 19, 2021 at 09:03:59AM +0000, David Laight wrote: > > It's kind of moot anyway because the patch is outdated. But the reason > > for the ___force is that the same `struct comedi_cmd` is used in both > > user and kernel contexts. In user contexts, the `chanlist` member > > points to user memory and in kernel contexts it points to kernel memory > > (copied from userspace). > > Can't you use a union of the user and kernel pointers? > (Possibly even anonymous?) > Although, ideally, keeping them in separate fields is better. > 8 bytes for a pointer isn't going make a fat lot of difference. > Creating a union is worse than adding casts. With the casts, at least you know that you're doing something dangerous. It's good that it looks scary because it is scary. Keeping them in separate fields is a good idea, but this is part of the user space API so it's not possible. The best we can do is adding some more comments so people know why we are doing the scary casts. regards, dan carpenter