Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1429854AbdDYKf4 (ORCPT ); Tue, 25 Apr 2017 06:35:56 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34970 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S980937AbdDYKfn (ORCPT ); Tue, 25 Apr 2017 06:35:43 -0400 Date: Tue, 25 Apr 2017 13:35:33 +0300 From: Maksim Salau To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, Greg Kroah-Hartman , Alan Stern , Mathias Nyman , Peter Chen , Roger Quadros , Baoyou Xie , Sekhar Nori , Chris Bainbridge , Wolfram Sang , linux-usb@vger.kernel.org (open list:USB SUBSYSTEM) Subject: Re: [PATCH v2] usb: core: Warn if an URB's transfer_buffer is on stack Message-ID: <20170425133533.52ba1cb6@gmail.com> In-Reply-To: <20170424012939.29929-1-f.fainelli@gmail.com> References: <20170424012939.29929-1-f.fainelli@gmail.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1020 Lines: 25 > + } else if (object_is_on_stack(urb->transfer_buffer)) { > + WARN_ONCE(1, "transfer buffer is on stack\n"); > + ret = -EAGAIN; > } else { Hi, Has anyone considered a fail-safe mode? I.e.: if a buffer is on stack, kmemdup it and continue with a warning. This will give us both: functional drivers (with possibly decreased efficiency in speed and memory footprint) and warnings for developers that a particular driver requires attention. This mode will not affect drivers which obey the rules, but will make offenders at least functional. My main concern is that not every user is able to detect and report a problem, which prevents drivers from functioning. Especially this is a problem for not wide spread devices. Due to this users a seeing unusable equipment, but developers are not aware of those, even if fixes are trivial. Such mode has a also a negative effect: if a developer has a device with an offending driver, he can miss the warning message, since the driver just works. Regards, Maksim.