Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4269443ybi; Mon, 27 May 2019 14:51:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdQ/jzQ7iC2kMUK0fQUoWUX/QWjHpbvdLCr0G0kTX0EkWDY+nty8oTn33hXw4mdGL2BBu+ X-Received: by 2002:a17:902:bb89:: with SMTP id m9mr88304728pls.188.1558993862895; Mon, 27 May 2019 14:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558993862; cv=none; d=google.com; s=arc-20160816; b=wDCUAU+PKzH1RMVhjsB17GntUqolRB/uzhpIJOVlInmtMJxOaaLvuDeM5Sihg/e+Xp 6JZrR8fvaM8KYbhFJ9hvMupPLf9hjtdXzyIiT5CFlYyEdMRJxCXYSpfUYHInGr1ps4ps KE8DG12Z35+e2HFyz1yUcbaWpVcoI/y6TF012qqLoCYTgWjOywWQd2rELpzOs6IcdkfG ZTUauTe6fq3Q0EStugNy3vpfVAQ3dsY3+pLXSI8e7f1nqfy53Bd82552tG1f9s0c4Bnd QBCrbPRAx3X6yFBZKoirsPEc+Vbzo8fo2I/WdF0pZEyXXZvUa72weZrWtHyA3gKKDXq4 eY5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Oo+l5dqkenGdaWu5V62xv5Lwp20lmcm25QvuJlksiyg=; b=wMPCIuK3RR3PACddJ3u9Py9j8m36u7lB6J38Mdh9NlGGZATd8hontpEuCKVY1Fkyce tBfz5IMkv1uSKsr0qhIb94UAY1SmdWg9157wsmS1Ra72t6lHLAjZ2YybuEMJUQ+491Ef ar37P1+j9HiusIRUafoeyXGZGjVETgkjrmOooG1BUdGYg+ehngueW/P9xCbLS9hbEyJI FCBPjSdBJLsWaeHYl0U6sT8Mksck2cRf/3DFxYu/CRkln2/xaXZ/9ciguGZfi3ku+wXL IwdL7+sI1xRTeJ9GwFFBPSElF7hBouCiNCTm2pYMnTxNTZ+R0MAktQv53q9mawcOBTE2 zxGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=K66sq1g9; 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 z3si18838066pgv.401.2019.05.27.14.50.47; Mon, 27 May 2019 14:51:02 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=K66sq1g9; 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 S1727465AbfE0Vdo (ORCPT + 99 others); Mon, 27 May 2019 17:33:44 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35439 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbfE0Vdo (ORCPT ); Mon, 27 May 2019 17:33:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id t1so9671548pgc.2 for ; Mon, 27 May 2019 14:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Oo+l5dqkenGdaWu5V62xv5Lwp20lmcm25QvuJlksiyg=; b=K66sq1g9D55mvXRtxUkh1xDtvyutqANxXOtarmXY0BgX/H8oQ+OxF7NOCR58HPxeIK ll6xospYcoEFnMvSU8rKEQ8xNr8z2fwS4AB2gNmtt5to/bhdUhm/tYKFK8zrZqklnkG1 zE4d1OjyXokFdYIMkiCRW8Bx2y3TBOUqLcosxBtXDlotOWv83FvBN86p8WKpTgPTJgmZ yL46t4JVbkhsk3E/jsCJiHUiFULntMzvPYQn6xzabqpWQ5eJTTWQYzw+5WIS+yAAuhzJ ZfPAoTIpseLvqvNQd4BFcSy+x9eI9Az7wgW4lLLNi8/S6808H5+GH4r7Wy0X5bstAnql ob2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Oo+l5dqkenGdaWu5V62xv5Lwp20lmcm25QvuJlksiyg=; b=Tczb3fixvHEmG0CquFmylD4t6NbnmHYbM48Sry1zS5jeBSlQVJsR+mfebSKQNJ7cYl aT16G93cORuQLX5Z/P/wbzUAl4m3FAGrkthHrggq7itJpkrQXvHARu28rpsi+UFhKs4o YaHFNqaLAGw1Aht6OrOpYvf2WIBbci4cIjFr3ih3hJbrBZTw2qbL4RFC+XAEUEoXm2Ve L+RCNltjsj+omS1cg1I9FQog6PeKd88wY3w2BegEghAruw0KfZZuoxZ1phDo0SC9bE5G bL0Y178e5hx18AjX89u2Ln97mh9woDdP2erTXm35VjIyePJjJfsPyKvSuUnHwG2nKL+C owrw== X-Gm-Message-State: APjAAAXr1GaSIY8aXBjRL+X6Iou9CmdmcOZNWcLDdZl5xl7afx/t0kW/ 8wSVqDATA2HGlgDvgVrwS3r9R7hXW0c= X-Received: by 2002:a17:90a:cf12:: with SMTP id h18mr1035180pju.77.1558992823303; Mon, 27 May 2019 14:33:43 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z6sm23727363pfr.135.2019.05.27.14.33.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 May 2019 14:33:43 -0700 (PDT) Date: Mon, 27 May 2019 14:33:41 -0700 From: Stephen Hemminger To: "Gustavo A. R. Silva" Cc: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy() Message-ID: <20190527143341.1dbc04c8@hermes.lan> In-Reply-To: References: <20190527183855.GA32553@embeddedor> <20190527142026.3a07831f@hermes.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 May 2019 16:28:05 -0500 "Gustavo A. R. Silva" wrote: > On 5/27/19 4:20 PM, Stephen Hemminger wrote: > > On Mon, 27 May 2019 13:38:55 -0500 > > "Gustavo A. R. Silva" wrote: > > > >> The strncpy() function is being deprecated. Replace it by the safer > >> strscpy() and fix the following Coverity warning: > >> > >> "Calling strncpy with a maximum size argument of 16 bytes on destination > >> array ifrr.ifr_ifrn.ifrn_name of size 16 bytes might leave the destination > >> string unterminated." > >> > >> Notice that, unlike strncpy(), strscpy() always null-terminates the > >> destination string. > >> > >> Addresses-Coverity-ID: 1445537 ("Buffer not null terminated") > >> Signed-off-by: Gustavo A. R. Silva > >> --- > >> drivers/net/macvlan.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c > >> index 61550122b563..0ccabde8e9c9 100644 > >> --- a/drivers/net/macvlan.c > >> +++ b/drivers/net/macvlan.c > >> @@ -831,7 +831,7 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) > >> struct ifreq ifrr; > >> int err = -EOPNOTSUPP; > >> > >> - strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ); > >> + strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ); > >> ifrr.ifr_ifru = ifr->ifr_ifru; > >> > >> switch (cmd) { > > > > Why not use strlcpy like all the other places IFNAMSIZ is copied? > > > > strlcpy() is also being deprecated. Are you going to fix all these: $ git grep strlcpy | grep IFNAMSIZ| wc -l 47