Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1703862imu; Wed, 21 Nov 2018 00:15:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/UqrQoDYYlFtMGroiuTAIdOupqWxIfjcSvCNxic2UwrFFqtZcnhVN1EUAad06YgWw6EjaWW X-Received: by 2002:a63:77ce:: with SMTP id s197mr5007586pgc.89.1542788129313; Wed, 21 Nov 2018 00:15:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542788129; cv=none; d=google.com; s=arc-20160816; b=q8coqpD7+5C0YT8Rz9Y0GFfmNRqHXnXn+TPbSMS+l6/bc+Ra6MOs2hfrnoOc27Yiu3 i9MmbC3HDxyWHKHVtO3g+uzAFg2gGUn75X2hCqa0ueVBEKBA2pzAKqJv9md9JY4ifYYu TolnbABD1A6Fo/8R+f9/AkdZygF3uE5l3vBMIb/ejOFC3jPNjX/DEt4Dn44w75tap7fO 8O/u8m4VHtF2tl6ix27G7bUslcLVAY7QB8yg1Fro9WMxYM5IGqVoBjRV49FhBx9tq4dG 46V0FF6+NCPcmzYmYPRCxDMJ4CUBrT4TxCRxiU64aSeYQs39s8hbmITjHXbtE1C6xkQ8 9+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0Csz5MsfnG4SIh1SwhYaZUkhF4DjoMpyusmvu6Q8JbA=; b=ZuVZLRMsaoof6/zxKmBjZNXoBgmESqaMu6utu2qHdBd9TIQEZWOHN98ciTLA/zwNmk 7OW6czeyhMd3aKOrjZDGFQjuWzbMb/dBXpYLVJOcBT9Gocla5rmXrGaHwWdmPXohaN+5 hP8uBfbT1+n98WrbcZ9Xhl8ffBomlwREteoDItv/V95PV9xuh9MgT517/uXfEdcIFh0s /t3BHwDnUhiQvph8lOMadECBO3wAIfBChEcPqvN/CvMrUPYH2EX0c8qFfY78HhnXy6R/ AFmWo4yNHXzqrzV34L8WJDVR41p/DYyNEdKpNtQOn+yopjE7+5f/3ZunnxqMaeRuKnJ4 NjFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zCSfKWPB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si33013851pgh.422.2018.11.21.00.15.14; Wed, 21 Nov 2018 00:15:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zCSfKWPB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbeKUSrx (ORCPT + 99 others); Wed, 21 Nov 2018 13:47:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:35396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726195AbeKUSrx (ORCPT ); Wed, 21 Nov 2018 13:47:53 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43BC821479; Wed, 21 Nov 2018 08:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542788061; bh=X3QglRAzDBYNVP78eXCVgCI+KD9FftARxrsJMAZE/r4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zCSfKWPBD1Q6mmUliz23VkAaPAXW8L3a/1syRdqJ6EWuz3R++cII44nMRAPe/FUJT K9ffIOfAHnPfqG9so4TbNeMCE/SrOD7aB78W6Za0xre3yimIF3E4r5LbPjDKJllqev UgsTc3STLuztbHNx0NS2kdhqM4ywqHURW99Cy7CY= Date: Wed, 21 Nov 2018 09:14:18 +0100 From: "gregkh@linuxfoundation.org" To: Ioana Ciornei Cc: Laurentiu Tudor , "linux-kernel@vger.kernel.org" , "netdev-owner@vger.kernel.org" , Ioana Ciocoi Radulescu , Horia Geanta , Leo Li Subject: Re: [PATCH v3 2/4] bus: fsl-mc: add fsl-mc userspace support Message-ID: <20181121081418.GD8162@kroah.com> References: <1542728371-6972-1-git-send-email-ioana.ciornei@nxp.com> <1542728371-6972-3-git-send-email-ioana.ciornei@nxp.com> <20181120164850.GC27531@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 05:59:26PM +0000, Ioana Ciornei wrote: > > > +static int fsl_mc_uapi_send_command(unsigned long arg, > > > + struct fsl_mc_io *mc_io) > > > +{ > > > + struct fsl_mc_command mc_cmd; > > > + int error; > > > + > > > + error = copy_from_user(&mc_cmd, (void __user *)arg, sizeof(mc_cmd)); > > > + if (error) > > > + return -EFAULT; > > > + > > > + error = mc_send_command(mc_io, &mc_cmd); > > > + if (error) > > > + return error; > > > + > > > + error = copy_to_user((void __user *)arg, &mc_cmd, sizeof(mc_cmd)); > > > + if (error) > > > + return -EFAULT; > > > + > > > + return 0; > > > +} > > > > I know you said that "the firmware will properly verify the command" > > already, but given that I used to be a firmware developer a long time ago, I can > > almost guarantee that this will cause problems in the future. > > > > Want to make a friendly bet about this? > > > > What is the odds that your firmware api/interface has been properly fuzzed such > > that all possible combinations of bad commands will really not do horrible things > > to the hardware/system? > > > > Are you all willing to bet the system intregrity on this? If so, ok, it's your systems > > :) > > > > Personally, I think you need to add a "known whitelist" and do some sort of > > sanity checking here. > > > > I can add a whitelist on the command ids that can be received from userspace but > leave the parameter parsing to the firmware to process and interpret depending on the > current system settings. > > Would that be a viable option from your point of view? That might be a good start. Again, how well have you tested this firmware interface can handle invalid data? Are you willing to bet your system integrity on it? :) thanks, greg k-h