Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp393978ybi; Wed, 29 May 2019 23:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqybP4Ll3IVBPWirltkZIkCXze7dqXVBKWHX8YbTsE9EAUuONUZqfeN1TXNDgY1kU+dlFMTQ X-Received: by 2002:aa7:880f:: with SMTP id c15mr2276587pfo.100.1559199027439; Wed, 29 May 2019 23:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559199027; cv=none; d=google.com; s=arc-20160816; b=06HoML97Bmgf5kzFSJyyH50X/S6NpU3YRvph1eb4X7ZUUru5NIgG+X/8KLIYEHf5hl ad6CDeJde3OhAvtVMnfsMnJEpZ3CP4iN3AlhWGym337GAp1mQrRXmSpzDXGf0zDHtNp2 xe/W15FfSyKXPMdLpoZOJN2A6x2+ZqxSF538/c11xMQF4GtPXRZ+YAnXTLG0Pp/jIPrf ocurtRuEACQV2DB4peiIedghaJCU6ohbVCEIve6bttPwzXl6DIOMY289TEidGR5Vehr9 ZxSeCoXx9qYBZVSg0rOfNfrWEDouhGOSDXwktq1XYEegkTeJz0fNEAFCiU9b4JSAWwfv Q6RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Kmgr1Ejh3e/3sO9RUHz31FprP1NQXkqVoe0Bvt7fT6k=; b=Q0oapn620jsw1Q7HHZD4mEe1LyHD79KMCKW2KnFX6sYvsb1KiqmJf6w9fiVIzj4VLb KcPFqKtZcDsNB/i3NZb6d0AKC3GTtDYzgDvj8ApvUqXHZDU8s3rVydmJZ9f6IP/uYWqU +Ck6yMH7TMIpqmyCucA/1IhElLAucnHWO05diUEc3RV4Tw9o4OkeoT4/9p4PvfgB/9J9 7BpYWPqaQK1wjcOoMm+uF5odP/CoBJtiY9o/xh6Zsv9DF1T2e1aFWfifiOQTQVXppg2e DEg7OXoC9+U045B1afPyZwjmkievF6L9yvuq5vpgaTYd/N1viDp8M1D8e+2IJtNDgqoY W3Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si2508035pgl.591.2019.05.29.23.50.11; Wed, 29 May 2019 23:50:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727540AbfE3Gsu (ORCPT + 99 others); Thu, 30 May 2019 02:48:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:50884 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725961AbfE3Gsu (ORCPT ); Thu, 30 May 2019 02:48:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 28DE6ACF8; Thu, 30 May 2019 06:48:49 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 646C0E0326; Thu, 30 May 2019 08:48:48 +0200 (CEST) Date: Thu, 30 May 2019 08:48:48 +0200 From: Michal Kubecek To: netdev@vger.kernel.org Cc: David Miller , vivien.didelot@gmail.com, linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, linville@redhat.com, f.fainelli@gmail.com Subject: Re: [PATCH net-next] ethtool: copy reglen to userspace Message-ID: <20190530064848.GA27401@unicorn.suse.cz> References: <20190528205848.21208-1-vivien.didelot@gmail.com> <20190529.221744.1136074795446305909.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529.221744.1136074795446305909.davem@davemloft.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 10:17:44PM -0700, David Miller wrote: > From: Vivien Didelot > Date: Tue, 28 May 2019 16:58:48 -0400 > > > ethtool_get_regs() allocates a buffer of size reglen obtained from > > ops->get_regs_len(), thus only this value must be used when copying > > the buffer back to userspace. Also no need to check regbuf twice. > > > > Signed-off-by: Vivien Didelot > > Hmmm, can't regs.len be modified by the driver potentially? The driver certainly shouldn't raise it as that could result in kernel writing past the buffer provided by userspace. (I'll check some drivers to see if they truncate the dump or return an error if regs.len from userspace is insufficient.) And lowering it would be also wrong as that would mean dump would be shorter than what ops->get_regs_len() returned. Michal Kubecek