From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0974C43381 for ; Tue, 19 Mar 2019 14:02:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA20C2075E for ; Tue, 19 Mar 2019 14:02:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="e+ZiDxRi"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="w98mG47Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA20C2075E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+tLu1yUsjmRi3NipjZcCIaV6hJ16RlHHilDbC1+sL7E=; b=e+ZiDxRi23JASg mt1upFgnC3xvOuPmwJ9MkxMl498QoLkf4zszgp7CnK9P6G0/66cBUGwWCf2U4aTDDL5X7/7Kgphfu TSK7VKcwBmoMHuLE3awlGzii/Kr8fUpAdgTsFnBodu81+9d702EIaTMHjXYMpwRQyWGmSZbOX0EgJ 9KZPM4WrXwALR7HBT6OJfIPxpzDpRxhGAsqaOIJUgGNjX3GuNuwF6wxldSbMe60D91hBULbhUoxhN y3KhyeNhnZfeXkRSDfJ1CZQ5zCcA7pJI+B8SYuRujcHzOZG1veKIVLXt2l3vJmuASP0F0mMou0BdP JpEISWQWbcU5dFT0YLsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6FJr-0001aC-Lv; Tue, 19 Mar 2019 14:02:19 +0000 Received: from mail-eopbgr800040.outbound.protection.outlook.com ([40.107.80.40] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6FJn-0001Zo-Ur for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2019 14:02:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C1LnOqfUsxY8LbcVF+6OQhU9p3cYpEMi+ZV7T3TVSBk=; b=w98mG47Q7AWA+IUjjHyhlBJ81qdyH9jpuqmkEbHAjwzDMQbvjyIzQez3CSNMS697WHLjHjim3MS7lxFUCbQ7mCOPc1sf3RY2OHhPjRxfwRuPEp/lXyT0kUM+uuP9m+8Z3QrDG5643IFfXQK+X0BlCLLc12Gv2tz1hm+LzyS2e6A= Received: from BL0PR02MB5681.namprd02.prod.outlook.com (20.177.241.92) by BL0PR02MB3761.namprd02.prod.outlook.com (52.132.8.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Tue, 19 Mar 2019 14:02:13 +0000 Received: from BL0PR02MB5681.namprd02.prod.outlook.com ([fe80::dc07:4b0:4a82:392a]) by BL0PR02MB5681.namprd02.prod.outlook.com ([fe80::dc07:4b0:4a82:392a%6]) with mapi id 15.20.1709.015; Tue, 19 Mar 2019 14:02:13 +0000 From: Dragan Cvetic To: Arnd Bergmann Subject: RE: [PATCH 08/12] misc: xilinx_sdfec: Add ability to get/set config Thread-Topic: [PATCH 08/12] misc: xilinx_sdfec: Add ability to get/set config Thread-Index: AQHU3kvwaLYIrJ5fl0ia+cFuErscN6YS7FOAgAALFOA= Date: Tue, 19 Mar 2019 14:02:12 +0000 Message-ID: References: <1552997064-432700-1-git-send-email-dragan.cvetic@xilinx.com> <1552997064-432700-9-git-send-email-dragan.cvetic@xilinx.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=draganc@xilinx.com; x-originating-ip: [149.199.80.133] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3067047c-b5da-4d4c-0b5e-08d6ac737ca1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:BL0PR02MB3761; x-ms-traffictypediagnostic: BL0PR02MB3761: x-microsoft-antispam-prvs: x-forefront-prvs: 0981815F2F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(136003)(396003)(39860400002)(199004)(189003)(13464003)(66066001)(4326008)(105586002)(86362001)(6916009)(5660300002)(54906003)(25786009)(106356001)(6116002)(3846002)(97736004)(71200400001)(71190400001)(7696005)(2906002)(316002)(14444005)(256004)(99286004)(8936002)(229853002)(102836004)(186003)(81166006)(81156014)(76176011)(7736002)(6506007)(74316002)(68736007)(305945005)(9686003)(55016002)(52536014)(14454004)(478600001)(8676002)(486006)(26005)(107886003)(6246003)(53936002)(446003)(11346002)(53546011)(6436002)(33656002)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR02MB3761; H:BL0PR02MB5681.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: xilinx.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Wn/nY7V3HYyZZ+VV4kWB/TRpztmwAChT/3K9wZQFcwgwKCaxl6sO668Z6F6fyiZYDjNTH9QzU1x4kAorx1hkSl+EP2k5JKRzU9/C5Gb0YfP5ulsoj+NBqw6t5eAfz3LdiUaTvREjl6caTtPspoNmh0+10WWJPJABmYhf16j/MkIQX8j1HfMQbZOw2BMvpmLpttV7tAsTP8Wacu9WqQKsnGWvm72Izen/GZvm7S+kQBMBpdbcSdXTkai649768ZbnmjYpI0rTVNA3gIFK1LdeM5+zeDHSbMhzfHrwM+oF7Lhu57FL1SlZTp95QTdVZdM/XhJxxLvC7PSzz6VEW/qUkgXPdmy5GeE8V1RwIA+XOC6K+IHQFdC06AdEHD6aHMXkYoQBtfX1L1w4qhO3vBlC0igR9fu51PnEtEM/70ZFIlU= MIME-Version: 1.0 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3067047c-b5da-4d4c-0b5e-08d6ac737ca1 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2019 14:02:12.9407 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB3761 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_070215_992651_3E71DFEB X-CRM114-Status: GOOD ( 20.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Derek Kiernan , gregkh , Michal Simek , Linux Kernel Mailing List , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Arnd Bergmann [mailto:arnd@arndb.de] > Sent: Tuesday 19 March 2019 13:06 > To: Dragan Cvetic > Cc: gregkh ; Michal Simek ; Linux ARM ; > Linux Kernel Mailing List ; Derek Kiernan > Subject: Re: [PATCH 08/12] misc: xilinx_sdfec: Add ability to get/set config > > On Tue, Mar 19, 2019 at 1:06 PM Dragan Cvetic wrote: > > - Add capability to get SD-FEC config data using ioctl > > XSDFEC_GET_CONFIG. > > > > - Add capability to set SD-FEC data order using ioctl > > SDFEC_SET_ORDER. The order of data blocks can change > > from input to output or to be maintained. > > Commenting here only on the ABI, not the actual behavior of the driver: Will be removed. > > > +static int xsdfec_get_config(struct xsdfec_dev *xsdfec, void __user *arg) > > +{ > > + int err; > > + > > + err = copy_to_user(arg, &xsdfec->config, sizeof(xsdfec->config)); > > + if (err) { > > + dev_err(xsdfec->dev, "%s failed for SDFEC%d", __func__, > > + xsdfec->config.fec_id); > > + err = -EFAULT; > > + } > > Try to avoid printing error messages for things that can be triggered from > user space. Will be removed. > > > static int xsdfec_set_turbo(struct xsdfec_dev *xsdfec, void __user *arg) > > { > > struct xsdfec_turbo turbo; > > @@ -670,6 +683,67 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg) > > return ret; > > } > > > > +static int xsdfec_set_order(struct xsdfec_dev *xsdfec, void __user *arg) > > +{ > > + bool order_invalid; > > + enum xsdfec_order order = *((enum xsdfec_order *)arg); > > Generally speaking, you should never cast between __user pointers > and kernel pointers. It looks like this will actually dereference a > __user pointer, which is a security issue. > > Another problem is that the command is defined as > > #define XSDFEC_SET_ORDER _IOW(XSDFEC_MAGIC, 8, unsigned long *) > > which would indicate an argument of type 'unsigned long __user * __user *', > which is incompatible with 'enum xsdfec_order __user *'. Both enum > and pointer types are variable length and should be avoided in > ioctl commands. Best make this a '__u64 __user *' or '__u32 __user *'. Will be updated as proposed. > > > + */ > > +#define XSDFEC_GET_CONFIG _IOR(XSDFEC_MAGIC, 6, struct xsdfec_config *) > > +/** > > * DOC: XSDFEC_GET_TURBO > > * @Parameters > > * > > @@ -322,4 +335,48 @@ xsdfec_calculate_shared_ldpc_table_entry_size(struct xsdfec_ldpc_params *ldpc, > > * ioctl that returns SD-FEC turbo param values > > */ > > #define XSDFEC_GET_TURBO _IOR(XSDFEC_MAGIC, 7, struct xsdfec_turbo *) > > Also wrong type, the function takes a 'struct xsdfec_turbo __user *', not a > 'struct xsdfec_turbo __user * __user *', Will be updated as proposed > > Arnd Thank you Dragan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel