Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4565162pxj; Tue, 22 Jun 2021 03:13:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQLc3Uv7xuZpOCVIMox9nmcDaoQeUNC02/Cw4hidcToRPG9MLwCiDWpAZF5xyi6PZVgEEL X-Received: by 2002:a5d:94ce:: with SMTP id y14mr2326217ior.67.1624356821481; Tue, 22 Jun 2021 03:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624356821; cv=none; d=google.com; s=arc-20160816; b=ItskBu5L6E/p6ERnBgPmO6ilCUy84bTiPQjz04T8JngYEoOmRFbuDpqFcHui+h4IVt 433AYQGMAWfPS+DkUFTPMSeSWsLllW5I81HDFWQbkFFSW2WunYfrQQzWAHS2TfRkLoKs 3dAHLq9sZolBQo6hN0vfxFKnz7laMZewTFXUncL86j1Wx8EUCo0dof4ZbcIa7TVqeNA4 1s+JkGSOTKpd1ouq+ehH54KvrNnFmEQcUY2Z0V1mmFUqh+4fiPsNmADNJg0zi0rOVbwu TvwkQkIIgJ7Tu3+M3MgZx2bfmnZN/i/iHr3TSw1+vyZZ83hNhgHPfQkWy2PrHTTMyjCJ Z1vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=pQtzM1DqFDdfzJczHbE0hVR7RaJ+DVrWztT+rRlCQh0=; b=JkMuEVCg7IFzB73DP/Go0VFgUInxeR+p+85mNBHaHRIjR8t/7h++HnAjmI5KQtImXD bwF9Mm9/KXJB/rv3qBZABPfAUCTUPqb/ydbKq9GjOUgkPei0Pe9/KhzxrIZGFg+mgqKq yhO+Aacc2JnX/t1lX/LBLyao5KGNTqmDZTGZ3u3KiAUp7DZ57eG+VbUwRuCj/O0qxpoz 0K8QolMs4XA++w/pDexkj/60fzT4GnSv+2SCZJduvdLimrVGJhOGoxky44VXHPL3GD+s s7GkHDVdGLOTLCBzJWOE9mEdv9bsdH4yk43jHdmvyB5cAoU6HnR+5y4+SzJXBo60rT9O shiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm1 header.b=YzHFOu2S; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=kSixDL1B; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si17063482jap.126.2021.06.22.03.13.28; Tue, 22 Jun 2021 03:13:41 -0700 (PDT) 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=@kroah.com header.s=fm1 header.b=YzHFOu2S; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=kSixDL1B; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbhFVKPJ (ORCPT + 99 others); Tue, 22 Jun 2021 06:15:09 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:57793 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbhFVKPI (ORCPT ); Tue, 22 Jun 2021 06:15:08 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 947F35806DB; Tue, 22 Jun 2021 06:12:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 22 Jun 2021 06:12:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=pQtzM1DqFDdfzJczHbE0hVR7RaJ +DVrWztT+rRlCQh0=; b=YzHFOu2SxOl0BCAJy9jZozNGYJZ0wrl8O0jKdRapOvb KT3zjqk39Ymny9tI2CDMukLxeWkDtCcJqlcRTDTcGeVr1BSngaJEwCeB29nwpxIC yGuzvksRqr0yzcXk35nit/65T9VWhdDkdASeL+gspkvJoOa6IkWzb40RSGLhikK7 cO5YO0QbXXFKMRMoclll2kG4sTAULr//wrD2F6Th0zXocozQvADZ2jovNQa4BXVk m+nqZsVW90AS0H/oQI7qp8imm8YsSQ5zQrYIAMBVVwqzhTPNlcMN1kWbYcS2tqjL brQMvFwlX5th0/UT/qk/DRK03E7eMJNbNmlvmYN2SEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=pQtzM1 DqFDdfzJczHbE0hVR7RaJ+DVrWztT+rRlCQh0=; b=kSixDL1BIp5Sj4eeF2VUnQ kBTRdHv/l7Tu8RpL7Iqpqx5KgWdTiwPDLn5ZL13eAcB8MSZM4hHOZK5Na2NznlMA ltIkJJBx9A+WfDXKf1lVmTB+srpRzXKohgvHwcbWlvPe43qpQ188z7AEqqIQM81t lUM9TMGCmV/2ZlTRG4TRENfR8ReQyw6f0oaGr1y/zMQ+UHfw8JU8ADnkBIZklXEK NPDw0W86KqXbPjjhegPy9PtcO/lyW6PDF/QpMSg4kqVKSOVikaxni8EeLRYXiQQy e9bkpsywCyK7kLZfk/l+G7Qu3EFzZQlQRNb2Ju0MnI4/F9v2/RMNvhmDqUUzBIyw == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeguddgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefirhgvghcu mffjuceoghhrvghgsehkrhhorghhrdgtohhmqeenucggtffrrghtthgvrhhnpeevueehje fgfffgiedvudekvdektdelleelgefhleejieeugeegveeuuddukedvteenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhh drtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 06:12:50 -0400 (EDT) Date: Tue, 22 Jun 2021 12:12:46 +0200 From: Greg KH To: David Laight Cc: 'Mauro Carvalho Chehab' , "linux-usb@vger.kernel.org" , "linuxarm@huawei.com" , "mauro.chehab@huawei.com" , Laurent Pinchart , Mauro Carvalho Chehab , "linux-kernel@vger.kernel.org" , "linux-media@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH v3] media: uvc: don't do DMA on stack Message-ID: References: <6832dffafd54a6a95b287c4a1ef30250d6b9237a.1624282817.git.mchehab+huawei@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 08:07:12AM +0000, David Laight wrote: > From: Mauro Carvalho Chehab > > Sent: 21 June 2021 14:40 > > > > As warned by smatch: > > drivers/media/usb/uvc/uvc_v4l2.c:911 uvc_ioctl_g_input() error: doing dma on the stack (&i) > > drivers/media/usb/uvc/uvc_v4l2.c:943 uvc_ioctl_s_input() error: doing dma on the stack (&i) > > > > those two functions call uvc_query_ctrl passing a pointer to > > a data at the DMA stack. those are used to send URBs via > > usb_control_msg(). Using DMA stack is not supported and should > > not work anymore on modern Linux versions. > > > > So, use a kmalloc'ed buffer. > ... > > + buf = kmalloc(1, GFP_KERNEL); > > + if (!buf) > > + return -ENOMEM; > > + > > ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id, > > chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL, > > - &i, 1); > > + buf, 1); > > Thought... > > Is kmalloc(1, GFP_KERNEL) guaranteed to return a pointer into > a cache line that will not be accessed by any other code? > > (This is slightly weaker than requiring a cache-line aligned > pointer - but very similar.) > > Without that guarantee you can't use the returned buffer for > read dma unless the memory accesses are coherent. For USB buffers, that should be fine, we have been doing this for decades now... thanks, greg k-h