Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3594902pxv; Mon, 28 Jun 2021 08:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDSoor8N0DB2eGOPj2PDnRiW8Vj3bqEvBTylM/WmLisdTUasF8eaqx2SKnKCzoxiCeOPCX X-Received: by 2002:a5d:6d06:: with SMTP id e6mr29164662wrq.28.1624893098678; Mon, 28 Jun 2021 08:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624893098; cv=none; d=google.com; s=arc-20160816; b=GlTXOVEtXxqx0aLgZ8Fk86BBT9J2bDFLg8tqQgKIHjPR1ZofOVmPiuNB7xOZkspDve 6x0gf5mKEmYFS50od+ropEldxwm+5jRKf2aVXJXB+FRTNXUIWYP5w3qDGGhzoNocWTr8 T8KjaLhok4XtDC4BYTiU8Z92lpV0KXnxN2h/GuJlqGnx9eU7THMvWdWBs8tQAzZx+bXJ ooEfWjkvSLAtgZNQgtuiC7vHJVs64TCGX+VjYPuTZYPg0Ovj01VxJrvm/Prg/iVfJh8O 8ZrvTzYdSmqdCps/JdoblP/3yUCK+wTkEZ8DWrkY/3SAYLubMiqtbtuXaD6Ax9fcbf36 jEyg== 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=7almkW+89TnDi18c+9pCGoSax/cXhJF+/FxeGbEDnN8=; b=kiEJ1a4jgCjYDrulq8Y8X6sE+9DsN8bzE+qxsWeiI5z13DbMZAPjYe8h5WyE8lMFH7 ooU5lmhdZSYyfTlAhqw+fGKYxAWAkGwjrHwdvlWDJjqN0SC86n6KAadPvnwzm2Dml6bn YCOGcMfFz7rsfVddatqpkYrX9LfsCveQAsMStFA4E6mjlVacykTssS8/ktHjOr1m3onn vu+t98ycX+DDSMobfmcDPeAP08YmeRLuox/YH64ktyAQaMpbaKKHl12DLx6kY2HBOXW/ oI/DDodfmWKplD0eSqA9IOe+VHdgxAf/x6pjyUIo7OTdFQ1RHgSZMVJbj31rgvQ6e3uD Tb8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hBGfIRg9; 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 gz1si14206162ejc.700.2021.06.28.08.11.08; Mon, 28 Jun 2021 08:11:38 -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=hBGfIRg9; 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 S235312AbhF1PI6 (ORCPT + 99 others); Mon, 28 Jun 2021 11:08:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:55610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236407AbhF1OsX (ORCPT ); Mon, 28 Jun 2021 10:48:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6461261CA7; Mon, 28 Jun 2021 14:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891001; bh=B25B92srqSsF/6Dh15xn0nPKBcW6GX2zydGaLZi44Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hBGfIRg9XyviZkLoDDlywghtQup0RK1JTo+399OUzFEwK4rUgMtOa5v8LNScpfiV5 s3W21I433twO2DAx3FqNNQqaJ/Xog2iQBAnRPa6HI+U+0YtTsmp2dwCMTxIARATvxd 30iZwtWHGeHmutOnXdmNBY4yqDU6vXPUj1HKxtyIONnpxIFXKQd1eD5552NftsWtF9 8FOwT+zThuIA4EzPj6pllwQbRKnrPMwdduS+wZRaj3TEGf6ZrHxZgRyt8+8b6pF9LY rSojNSR7JKeGoFXXdLgDlal1Jo2jAHsxh7Eip/pGJeQBQwXVMyfiymzzBDeqn2+ZyA +BNSZRTbC/6Ug== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Triplett , "David S . Miller" , Sasha Levin Subject: [PATCH 4.14 13/88] net: ipconfig: Don't override command-line hostnames or domains Date: Mon, 28 Jun 2021 10:35:13 -0400 Message-Id: <20210628143628.33342-14-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+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 f0782c91514c..41e384834d50 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -881,7 +881,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) { @@ -930,12 +930,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