Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9983633ybi; Wed, 24 Jul 2019 13:31:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKUlzqYJDJUPtkRhE2B/DIfbAsLEuIM+btpRGnFgQcQzzYYZljcyNEhX2F6lP5W01Nlfbz X-Received: by 2002:aa7:90d8:: with SMTP id k24mr12979415pfk.115.1564000318604; Wed, 24 Jul 2019 13:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000318; cv=none; d=google.com; s=arc-20160816; b=ad1uOAgnDg594uH8mOaZc6YknmFXPopEYU4XoT4pFjXXGYtK1AhhvZo3IQDOBbuSJw BgpIGxSM0s2LHFR7WWcevTzDei9wZBoBi725pTJGjW90uxzmZilKGm3xeeorwbFs6nwW j/esSTmRXkXNsD5otmb7h4WoDD+NYsQeSBbA3Wl1V3P9sXF3mU6F7t0NHJU1XkIU/y3o PLmpZ68k7UaVdr1lQccpupgPER/qJ3RcSFF/f/14H8vH17ARGxRi4VIJo6JW/j+iivNN MyGETVeaepXn4GhR6gZOohb9bz382Nb/z4ajiRjRdNOGEPfBXAtZR1g8Jq3aM1nVnrum bxxw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8XCPybwxswORiKHbhByyd39myRpsRZTFERdmaCMYGag=; b=mxLTWaSYsPLBxfuiVf+1jgMQ65oe4teoeFKPWIYgRZboPEVwwNBOuGdUHu3z8BlTNX MmpY+eq/N5Hg89NJfBXSDX7lFxaLgG9WjyI13hw9o0DpwKOGuCs9pEYX/zt0tzv6TSHR metpLDmeQ2WSoR0QcPG5H8J9hnbFhOHmN+XevYtR20p9hinbfkCGZHy3WQyQqHuXePFG X+MtfguDC5rLqzESgBeSkYRVYA38EeldivWDiHSzsu7x08Dr9+l+iCbjl1UH1qviSlp8 D+hqMlK2Omqu4C7npCY2zkIgQn4UepjAJNZ8f5lNzv52IyDBX93YgOgQP88HCzpl9ytQ FbNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GD6qD68/"; 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 j9si16500562pgq.555.2019.07.24.13.31.44; Wed, 24 Jul 2019 13:31:58 -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=@kernel.org header.s=default header.b="GD6qD68/"; 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 S2388899AbfGXU3T (ORCPT + 99 others); Wed, 24 Jul 2019 16:29:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388794AbfGXTdL (ORCPT ); Wed, 24 Jul 2019 15:33:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28740229F3; Wed, 24 Jul 2019 19:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996790; bh=rabk5HJpjleC/RCsRwYf0b5VguYCDz59AVw06qg5qRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GD6qD68/9lEittBg0u2aP4Z+Erg06p3iz0rlIb7ls5T/o6V5twSXMUuiVJrNkeP3x foU9O6eMu5cZSpp5TDMqzvSannHW0FSpMxjuYiIsSEIwRzI7RuLfiWPGrzSAZuZgcA FiWVn4AiZp98DnDZud9h3CZFBaDYsISef6gC20Bw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Magnus Karlsson , Yonghong Song , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.2 218/413] libbpf: fix GCC8 warning for strncpy Date: Wed, 24 Jul 2019 21:18:29 +0200 Message-Id: <20190724191750.274281968@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit cdfc7f888c2a355b01308e97c6df108f1c2b64e8 ] GCC8 started emitting warning about using strncpy with number of bytes exactly equal destination size, which is generally unsafe, as can lead to non-zero terminated string being copied. Use IFNAMSIZ - 1 as number of bytes to ensure name is always zero-terminated. Signed-off-by: Andrii Nakryiko Cc: Magnus Karlsson Acked-by: Yonghong Song Acked-by: Magnus Karlsson Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- tools/lib/bpf/xsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index 38667b62f1fe..8a7a05bc657d 100644 --- a/tools/lib/bpf/xsk.c +++ b/tools/lib/bpf/xsk.c @@ -337,7 +337,8 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) channels.cmd = ETHTOOL_GCHANNELS; ifr.ifr_data = (void *)&channels; - strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; err = ioctl(fd, SIOCETHTOOL, &ifr); if (err && errno != EOPNOTSUPP) { ret = -errno; -- 2.20.1