Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp733037imm; Wed, 18 Jul 2018 09:43:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfirgJC+WZ06Xbp5MfWLpqWThetSx4kMPsbWLzBU3VWJWfVMbI8PBb0Lb7ufOR0Rq/pJEzi X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr6743046pll.165.1531932213450; Wed, 18 Jul 2018 09:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531932213; cv=none; d=google.com; s=arc-20160816; b=ANUPF8uF9oLklg71J660pXF0djIys2AR7SdwuqMAL47VnwL3bX3EMrQ/u2+6I0neuR +QxXOzlk9Ciq6zeEBfNLfhW1n1slyvzUBgNscL7PXLxI3TmQKKPIsgoaYp+VYNeagFkm VQtEYHdkyv+QybmrphAcJrBrjbUOlwe3wpjN7k1//lHpv7Cr2uugMf0/EjvAEDo4VsPF hp1BKzcZZvraz2wMMSOwIDPnl64PimuJyE1kX0BEhyVjlc5B1YMWPDAqphAdnXpedImY EHSQ0E6khzTKWYuqUhHMFVGdCDcDjO3uDV1G+0WqDFgYVWx748usaOsDY0TW5L2rDpyO W+AQ== 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:dkim-signature:arc-authentication-results; bh=+Bwwb0t8beQe43hJEUdWtX7lxnkLSP0zlUepbeC+z98=; b=DA6/fz1dNZhnnS1L7+GWwHmuc5HMQS+mdZfon+jAT7pT5m4cEurKXpnuqHPvERGZyO 50vS4gdS20z6FJTCnle0Rgp0kpBQE83t7crowbWv0mQzt8HoZDSvmo5aZif9m47/0D3/ sH41UAGvmePsK8dJScP4nFJf1FIAx8aFrkv1FCSPQ0HOFNuJ1+wRzr2o4oq5eGvkiqq7 gstU0JKWRSJps9fG/0JynBER4HY9sm5ab8CYLqppAWbg8mAlFTEq+wgamUlv+1mHd4oE JkUnrWHKl3E+3VErGHxhwEZ0UeAwN5JRlnWpfS9NjuECi+iPdonnD5ZJMNdFiQ/E37rR 6d0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DFKvhNg4; 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 l1-v6si3611539pgb.464.2018.07.18.09.43.17; Wed, 18 Jul 2018 09:43:33 -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; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DFKvhNg4; 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 S1731426AbeGRRV0 (ORCPT + 99 others); Wed, 18 Jul 2018 13:21:26 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:38825 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730897AbeGRRV0 (ORCPT ); Wed, 18 Jul 2018 13:21:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=+Bwwb0t8beQe43hJEUdWtX7lxnkLSP0zlUepbeC+z98=; b=DFKvhNg4d6tFI3HqC75eIffPVKI+puUKbDAUMl24puOSMSmIi3LmbNmuXdSxKAm7/j2alNXRw0zxwzlOGwQ4UAd9YTtzZ1HV+GSUbnrrni2eTRbPFsxdSiXJ470bu9YxOLo0PQcNneaYyiyR1s5IaYBUcExZG7vXZ7BnDdWJ09M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1ffpWs-0004Ea-Id; Wed, 18 Jul 2018 18:42:18 +0200 Date: Wed, 18 Jul 2018 18:42:18 +0200 From: Andrew Lunn To: Bartosz Golaszewski Cc: Sekhar Nori , Kevin Hilman , Russell King , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Lukas Wunner , Rob Herring , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , David Lechner , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH 4/5] net: add support for nvmem to eth_platform_get_mac_address() Message-ID: <20180718164218.GD12477@lunn.ch> References: <20180718161035.7005-1-brgl@bgdev.pl> <20180718161035.7005-5-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180718161035.7005-5-brgl@bgdev.pl> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + if (!IS_ERR(nvmem)) { > + addr = nvmem_cell_read(nvmem, &alen); > + if (!IS_ERR(addr)) { > + from = "nvmem"; > + /* Don't use ether_addr_copy() in case we > + * didn't get the right size. > + */ Please verify the size. A short read can still give a valid MAC address, so the is_valid_ether_addr(addr) is not sufficient. > + memcpy(addrbuf, addr, alen); Another reason to check the length is that you appear to have a buffer overflow here, if alen > 6. Andrew > + kfree(addr); > + addr = addrbuf; > + } > + > + nvmem_cell_put(nvmem); > + } > + } > + > if (!addr || !is_valid_ether_addr(addr)) > return -ENODEV; > > -- > 2.17.1 >