Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp329791pxb; Mon, 16 Aug 2021 06:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhdoJURAkbpiPpAQbh0X8O5Z2u0wzZ54WPl9VyURyjDOFvlvQZcZhOA4vmeC1gH860Spbi X-Received: by 2002:a05:6402:375:: with SMTP id s21mr20266102edw.318.1629120490021; Mon, 16 Aug 2021 06:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120490; cv=none; d=google.com; s=arc-20160816; b=AIz9Vq1uJRER9FjG7OTrhnTtpySs2tuXG4vYa+MCkPSt86jgg3ShU47dE/4yEX9qS1 HhhFHud9YNXstPKK3zz/nYkOLmHGMc5mOZNpLbn2FxKEKYG1UFrSThFYrxwX4oM/fLyH ZWcODk1j0ntrG5T549QFxksHbwLWE349INEb/ZkefpMl2eFBK+SK66fwlHpQ2avOOmMP XzQ/HZPHmfZBw8Uc8nJ3RqW6x1erp+JIHeqj8PEb7lA1yFCcq1QwcKA7Qp3NZdO8UcLI Rkow/qZouIB3YmumshTQ6TmZjKTBUbj+fy3guutpyMYJ5KsKVZy164PquSBblxYhzLou WhnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ONubPORAjmT46SzC58UVa/3McUDbpKnk6oTaJVAXA0c=; b=V7NrkBbDv1bh3zXb0t53fPf64KMItr97e+7OH4Gb6d18SU2Fgt59pQKM6JXHOu9VZj XwqnWYxTBWchZ/P7UCv36BlG/ztpj5VtA0ExVm2GTILCYb9Icerv0uA4XqPzHLyTqbYk OeNiXUq2uUP+I6CqV0z2EOAnv0GY0JvF/R0tVINcSJt8AajTwR2FhHj8cQsyIrXCqc9p cn/LvvbG88+grgEsMRbE4gA9IxLQRhpltPwCPE10xa4j5YeZW/rsVkES4Fm+ih1Lc2V9 pNY/6oSXOUoLO+PX3puv+q/P1aRL4IGrTVw59CFEBNrTfmPGAbAj9rKj6/sww8+6qKaw +NpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HcR6QU5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si4012563edc.268.2021.08.16.06.27.46; Mon, 16 Aug 2021 06:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HcR6QU5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241223AbhHPNZO (ORCPT + 99 others); Mon, 16 Aug 2021 09:25:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:37180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240285AbhHPNPD (ORCPT ); Mon, 16 Aug 2021 09:15:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80F5A632D7; Mon, 16 Aug 2021 13:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119542; bh=GhC2CBBb7EFek9zTKaPoS0L6SLfurb1hT2mpe2FoohM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HcR6QU5ivUEMT2SlHMJ02MUrTKC1u4tsYxtH82RPVCDkrDJt/yWjdtvVBVwILnypj V0eG+Sa3EScMM7A7r4rCJLcMla/lJ4ZIUo+GMgzN63VleZQo3ZPVzkRaIajH8GusI2 Wnp8kKeMBQRDmC4B5HNQDLgnC1kmfaqtGMog7uqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 067/151] ppp: Fix generating ifname when empty IFLA_IFNAME is specified Date: Mon, 16 Aug 2021 15:01:37 +0200 Message-Id: <20210816125446.272259344@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár [ Upstream commit 2459dcb96bcba94c08d6861f8a050185ff301672 ] IFLA_IFNAME is nul-term string which means that IFLA_IFNAME buffer can be larger than length of string which contains. Function __rtnl_newlink() generates new own ifname if either IFLA_IFNAME was not specified at all or userspace passed empty nul-term string. It is expected that if userspace does not specify ifname for new ppp netdev then kernel generates one in format "ppp" where id matches to the ppp unit id which can be later obtained by PPPIOCGUNIT ioctl. And it works in this way if IFLA_IFNAME is not specified at all. But it does not work when IFLA_IFNAME is specified with empty string. So fix this logic also for empty IFLA_IFNAME in ppp_nl_newlink() function and correctly generates ifname based on ppp unit identifier if userspace did not provided preferred ifname. Without this patch when IFLA_IFNAME was specified with empty string then kernel created a new ppp interface in format "ppp" but id did not match ppp unit id returned by PPPIOCGUNIT ioctl. In this case id was some number generated by __rtnl_newlink() function. Signed-off-by: Pali Rohár Fixes: bb8082f69138 ("ppp: build ifname using unit identifier for rtnl based devices") Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ppp/ppp_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index b9dd47bd597f..7a099c37527f 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -1317,7 +1317,7 @@ static int ppp_nl_newlink(struct net *src_net, struct net_device *dev, * the PPP unit identifer as suffix (i.e. ppp). This allows * userspace to infer the device name using to the PPPIOCGUNIT ioctl. */ - if (!tb[IFLA_IFNAME]) + if (!tb[IFLA_IFNAME] || !nla_len(tb[IFLA_IFNAME]) || !*(char *)nla_data(tb[IFLA_IFNAME])) conf.ifname_is_set = false; err = ppp_dev_configure(src_net, dev, &conf); -- 2.30.2