Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754149AbbK3QQK (ORCPT ); Mon, 30 Nov 2015 11:16:10 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:37420 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753414AbbK3QQE (ORCPT ); Mon, 30 Nov 2015 11:16:04 -0500 Date: Mon, 30 Nov 2015 11:16:02 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Krzysztof Opasiak cc: Greg KH , =?UTF-8?Q?Emilio_L=c3=b3pez?= , , , , , , , , Subject: Re: [PATCH v1 0/1] ioctl to disallow detaching kernel USB drivers In-Reply-To: <565817FD.3090409@samsung.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2167 Lines: 43 On Fri, 27 Nov 2015, Krzysztof Opasiak wrote: > >> I run through your code and as far as I understand above is not exactly > >> true. Your patch allows only to prevent userspace from accessing interfaces > >> which has kernel drivers, there is no way to stop an application from taking > >> control over all free interfaces. > >> > >> Let's say that your device has 3 interfaces. First of them has a kernel > >> driver but second and third doesn't. You have 2 apps. One should communicate > >> using second interface and another one third. But first app is malicious and > >> it claims all free interfaces of received device (your patch doesn't prevent > >> this). And when second app starts it is unable to do anything with the > >> device because all interfaces are taken. How would you like to handle this? > > > > You can't, and why would you ever want to, as you can't tell what an app > > "should" or "should not" do. If you really care about this, then use a > > LSM policy to prevent this. > > Well, an app can declare what it does and what it needs in it's manifest > file (or some equivalent of this) and the platform should ensure that > app can do only what it has declared. > > I would really like to use LSM policy in here but currently it is > impossible as one device node represents whole device. Permissions (even > those from LSM) are being checked only on open() not on each ioctl() so > as far as I know there is nothing which prevents any owner of opened fd > to claim all available (not taken by someone else) interfaces and LSM > policy is unable to filter those calls (unless we add some LSM hooks > over there). How about this approach? Once a process has dropped its usbfs privileges, it's not allowed to claim any interfaces (either explicitly or implicitly). Instead, it or some manager program must claim the appropriate interfaces before dropping privileges. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/