From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933356AbdGTFtE (ORCPT ); Thu, 20 Jul 2017 01:49:04 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:52436 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754629AbdGTFtC (ORCPT ); Thu, 20 Jul 2017 01:49:02 -0400 Date: Wed, 19 Jul 2017 22:49:01 -0700 (PDT) Message-Id: <20170719.224901.2173661512386984465.davem@davemloft.net> To: colin.king@canonical.com Cc: andy@greyhouse.net, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: tehuti: don't process data if it has not been copied from userspace From: David Miller In-Reply-To: <20170719174659.22646-1-colin.king@canonical.com> References: <20170719174659.22646-1-colin.king@canonical.com> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 19 Jul 2017 22:49:02 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin King Date: Wed, 19 Jul 2017 18:46:59 +0100 > From: Colin Ian King > > The array data is only populated with valid information from userspace > if cmd != SIOCDEVPRIVATE, other cases the array contains garbage on > the stack. The subsequent switch statement acts on a subcommand in > data[0] which could be any garbage value if cmd is SIOCDEVPRIVATE which > seems incorrect to me. Instead, just return EOPNOTSUPP for the case > where cmd == SIOCDEVPRIVATE to avoid this issue. > > As a side note, I suspect that the original intention of the code > was for this ioctl to work just for cmd == SIOCDEVPRIVATE (and the > current logic is reversed). However, I don't wont to change the current > semantics in case any userspace code relies on this existing behaviour. > > Detected by CoverityScan, CID#139647 ("Uninitialized scalar variable") > > Signed-off-by: Colin Ian King Yeah this is the safest change for now, applied. Francois added the register address range checking a year after the driver was added, so maybe someone used this facility. It should have been done via ethtool getregs...