Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756897AbdCUKdI (ORCPT ); Tue, 21 Mar 2017 06:33:08 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36750 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756133AbdCUKdG (ORCPT ); Tue, 21 Mar 2017 06:33:06 -0400 Date: Tue, 21 Mar 2017 11:33:02 +0100 From: Daniel Vetter To: Arnd Bergmann Cc: Jani Nikula , Ander Conselvan de Oliveira , David Airlie , Linux Kernel Mailing List , dri-devel , Daniel Vetter , intel-gfx@lists.freedesktop.org Subject: Re: [Intel-gfx] [PATCH] drm/i915: use static const array for PICK macro Message-ID: <20170321103302.fnrt4tnze46grmdi@phenom.ffwll.local> Mail-Followup-To: Arnd Bergmann , Jani Nikula , Ander Conselvan de Oliveira , David Airlie , Linux Kernel Mailing List , dri-devel , Daniel Vetter , intel-gfx@lists.freedesktop.org References: <20170320215713.3086140-1-arnd@arndb.de> <877f3javde.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 4.8.0-1-amd64 User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1739 Lines: 35 On Tue, Mar 21, 2017 at 09:44:07AM +0100, Arnd Bergmann wrote: > On Tue, Mar 21, 2017 at 9:26 AM, Jani Nikula > wrote: > > On Mon, 20 Mar 2017, Arnd Bergmann wrote: > >> The varargs macro trick in _PIPE3/_PHY3/_PORT3 was meant as an optimization > >> to shrink the i915 kernel module by around 1000 bytes. > > > > Really, I didn't care one bit about the size shrink, I only cared about > > making it easier and less error prone to increase the number of args in > > a number of places. Maintainability and correctness were the goals. Just > > for the record. ;) > > Ok. My only interest here is the warning about possible stack overflow, > though the fact that KASAN considers the array code to be fragile is > an indication that it is perhaps actually dangerous: if we ever run into > a bug that causes the array index to overflow, we might in theory > have a security bug that lets users access arbitrary kernel pointers. > > While the risk for that actually happening is very low, the original code > was safer in that regard. My patch on top of yours merely turns a > hypothetical arbitrary stack access into an arbitrary .data access, > and I don't even know which one would be worse. Even without these arrays, if userspace could control the index we feed into these you get arbitrary mmio access. Or semi-arbitrary at least. None of these are bugs we should ever let through, and I think with the current code design (where the driver constructs structs that contain the right indizes, and userspace only ever gets to point at these structs using an idr lookup) none of these are likely to happen. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch