Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3881138pxv; Mon, 28 Jun 2021 15:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGg/IeQ7IXItqu6f2EHjJqxAaizhhlVH0tzEBBxJgOqQuj+EUpZvKPqU9XDondhEkc+oAG X-Received: by 2002:a02:666d:: with SMTP id l45mr1669579jaf.0.1624919594603; Mon, 28 Jun 2021 15:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624919594; cv=none; d=google.com; s=arc-20160816; b=y3taljfv8HrrZZf8fPKswihuTsngoO9hoawif92btlYor/FH9azxrBIXRG0IE29Dnh 0AyGo/x1uHtN1g4Cko20NWQHeIciun0Psoj/T9vgXno10TqnhtHDFp0WByBTEsoRSYjY H4co+yZaMjgLDo/g/CXBIEDPUFBuKg1mJr031dz0m6HWkIm+dTjviGrqA2Z+XvAm40+6 +IvpgbR9tNwN+P2unTJ8SqVBXyjCPTW6lGcdpyTu8YDjcVioAS/71cF20+8/6jfKy2zd 4Vmtv9204CdTOi1HNVc1eGmZF7WAxNdUBE4Cb08XkoCvf/piEqJqbO6aC9Vq3MRAz922 Nw8A== 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=AWl9xE04rYiOFo2WDH9kquqBjtTODLPhiq2snsqV9n4=; b=c9Wew/T6TxA/k/I88FSxjv2oRmoU2NyPUrtikIRooxOSRZDYHx4Fzdon6KgrTzAK11 Ra+DyVcK46QEU+/g8ftVZzM2O5P3yBtk+HYlhoVwbPZ4+Sx+QhzAcljgOUFPbYJ+rXwn Q3NLPb67R+ZGLes6GYDdl+DfOXn30XxzGyj/zqKTGke6Q/2rhwvSRj8jnpowDv7s44da H33fboB9X9DDQxPEeUCI1XgG0bCv453Bo55oFs3j78tNw+Y5EsZIKv8+CMgiTUnR0DzP vNDa6cs7s1Q/XtwDjkfHC4BgPUNS3pBxN8lhj+aI1A52MZzK35QnHEo9xAhUCZokCLtG /kqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WF3WRx8l; 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 p11si17545206ioo.38.2021.06.28.15.32.38; Mon, 28 Jun 2021 15:33: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=WF3WRx8l; 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 S236918AbhF1P11 (ORCPT + 99 others); Mon, 28 Jun 2021 11:27:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:36572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236785AbhF1PCj (ORCPT ); Mon, 28 Jun 2021 11:02:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA5B861CDD; Mon, 28 Jun 2021 14:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891386; bh=XIOz4vqnwOvpOo3hRFgpsztyM9IMnV29zg9GI6fTdPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WF3WRx8lq64vLmG3Z7Eq5m+yL9oGWXZx7Ca7ybay4yGI6bufvl8hXxru0qz9k4rov yYtusJZefZ8rWRoMqamtzX9zHOcvcHZBOo7uVcvoVsJ8Zpa18uws9whlPDKbbZEXS/ gD3D5oP/KsZAa0vpjqERI9Ic/GllTRiYDy/jGdLPJwDUE73Kie8WmEDpF1aMK9ywIM GNCWOD/8Lt/sA5eu6jjhJOrYD3mHfjXQt6prZUJqFsD0kvN0rJOhYlCoXfNWz1NgZj z9LYmHwnieYeJafQ0SqxsYdCHA9x8ZxL0uUXL5a0HW990TktM1UCvCmThC/MhLwodh iScy5W2c3neVw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Triplett , "David S . Miller" , Sasha Levin Subject: [PATCH 4.4 09/57] net: ipconfig: Don't override command-line hostnames or domains Date: Mon, 28 Jun 2021 10:42:08 -0400 Message-Id: <20210628144256.34524-10-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144256.34524-1-sashal@kernel.org> References: <20210628144256.34524-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.4.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:42+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 60f564db25a3..173777aa5add 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -890,7 +890,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) { @@ -941,12 +941,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