Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3777261pxv; Mon, 28 Jun 2021 12:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyDKhWXiXdKK8UsbIP4jHDu8yL8o5P7PaggWjIXAv8SYtv0239OILj5v3dB2VwiZtHmVdj X-Received: by 2002:a02:b0da:: with SMTP id w26mr1124402jah.42.1624908974204; Mon, 28 Jun 2021 12:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624908974; cv=none; d=google.com; s=arc-20160816; b=H+t517ueyV4V8+GgQgmHBuMWdt6xpyWQCNopfy2WzQ+I8+4wADnjV/5/eVHq0jQbkT LD06Uc8Wj97FrTSTbeuJil45X5giyVIxnpd+7lrBey6EYcRBPDQ73a+dZ52F65U6NUAs YcVL0XWL4vjcBEykAgLQhEIU3zd11vp661ssK3nX9FzHiI5YETU9VpJHPvoBshi8TMWi ccnKCkymstIV46vcVtSJUZ8v5hCzuKjbFENoAV9crIh9pDtlxVix6POTBEYHu36uuYIm BAWlj2wNUmM4oFG6kdZwyAo9jLBVnbiozzl2VrMBWAEtgQPCYjeJ1xCnUEn5s8a3bV0k VTBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2Ecx/pA/PpMhc12wBGCRcAn7DHGUScLHnXqnG17jK5Y=; b=TrDSEL7mJqNYwJ9PEmu+Xa54fRliTpFT/bAJyGbXa640wNspN78ACnIajs41CdZ+iu HiOB/B16Vkw8yfjXYhHO7PlLA6vlpO/9gfIe4qK3jbsaMDaLgj2e4WoKnIEqGGTESX+2 4QKVHju/mz8qFZk1xcpJKK2Ge3JWxvihbjBnid2hHepOlCn/dCBots5xhV3NOxuo8eZH vJTJVixHtv+GDzj3vSqVdux0rKHYa8tJOebrDllGrz+8qscPfd7iHz/Jt6JCMNmVeu5E 10lEcOUzcfkRY7CHqiV4IkJMGwD/1fascBunNShfpSfYJEt1yk+P08MrCutZloFglUB4 Hq0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jOHU7JG2; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si18927988iln.52.2021.06.28.12.36.01; Mon, 28 Jun 2021 12:36:14 -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=@kernel.org header.s=k20201202 header.b=jOHU7JG2; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236034AbhF1Oyb (ORCPT + 99 others); Mon, 28 Jun 2021 10:54:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:43982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235567AbhF1OkJ (ORCPT ); Mon, 28 Jun 2021 10:40:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DBF4E61C4D; Mon, 28 Jun 2021 14:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624890801; bh=88pIXm3i093tIChz13k6XghCQ0SvYtyMLsDBBea0Woo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOHU7JG2p+6gYWiyCGE41g3QChtU5XBkWQyLiKcFdoKJPfWvXuSz5xyV0xJNPsnqS ivRgJ4GY/UfYHOtnIVAdCTi+HxP4TWFgaGVSohulg4+6WcU5FWmDmAE102W16F24mM 4E+AD+ffnyxwdX2PFoh7ayRgB2ecLn5pWGGQQTaSY7xRWOai3sZTB6wuGc9/quNWpB duIMISMcP1yaqHeJtNhe35/pzG78wg1WIeYeAic711Cw9KKS0azHkYUdzxiv4EiaqJ Nflv6QnlcsHESi5xH9Z+jwO7ODOSvRvgD+Z+Ns3GS3VuzgZSqO6zZMXJUCPijRuavN wAKtUIEEYKVeg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Triplett , "David S . Miller" , Sasha Levin Subject: [PATCH 4.19 016/109] net: ipconfig: Don't override command-line hostnames or domains Date: Mon, 28 Jun 2021 10:31:32 -0400 Message-Id: <20210628143305.32978-17-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143305.32978-1-sashal@kernel.org> References: <20210628143305.32978-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.196-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.196-rc1 X-KernelTest-Deadline: 2021-06-30T14:32+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Triplett [ Upstream commit b508d5fb69c2211a1b860fc058aafbefc3b3c3cd ] If the user specifies a hostname or domain name as part of the ip= command-line option, preserve it and don't overwrite it with one supplied by DHCP/BOOTP. For instance, ip=::::myhostname::dhcp will use "myhostname" rather than ignoring and overwriting it. Fix the comment on ic_bootp_string that suggests it only copies a string "if not already set"; it doesn't have any such logic. Signed-off-by: Josh Triplett Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ipconfig.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 88212615bf4c..58719b9635d9 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -866,7 +866,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d /* - * Copy BOOTP-supplied string if not already set. + * Copy BOOTP-supplied string */ static int __init ic_bootp_string(char *dest, char *src, int len, int max) { @@ -915,12 +915,15 @@ static void __init ic_do_bootp_ext(u8 *ext) } break; case 12: /* Host name */ - ic_bootp_string(utsname()->nodename, ext+1, *ext, - __NEW_UTS_LEN); - ic_host_name_set = 1; + if (!ic_host_name_set) { + ic_bootp_string(utsname()->nodename, ext+1, *ext, + __NEW_UTS_LEN); + ic_host_name_set = 1; + } break; case 15: /* Domain name (DNS) */ - ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); + if (!ic_domain[0]) + ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); break; case 17: /* Root path */ if (!root_server_path[0]) -- 2.30.2