Article View: linux.kernel.netdev
Article #3881Re: [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing
From: Antoine Tenart
Date: Fri, 16 Oct 2026 08:18
Date: Fri, 16 Oct 2026 08:18
71 lines
7703 bytes
7703 bytes
On Fri, Oct 16, 2026 at 12:11:52PM +0800, Liu Chao wrote:
> The DHCP option parser in ic_bootp_recv() advances the option
> pointer by the option length and only checks that the new pointer
> has not reached the end of the packet. The length byte and the
> option payload (opt[1], opt[2]) are then read without verifying
> that they lie within the buffer, so a malformed reply from a
> rogue DHCP server can trigger an out-of-bounds read.
>
> Validate the option length against the remaining bytes before
> consuming the option, and skip options that do not fit. This
> keeps the existing parsing logic intact while ensuring all reads
> stay within the received packet.
>
> Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
> Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
> ---
> net/ipv4/ipconfig.c | 38 ++++++++++++++++++++------------------
> 1 file changed, 20 insertions(+), 18 deletions(-)
>
> diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
> index 22a788987..0b39a5ccf 100644
> --- a/net/ipv4/ipconfig.c
> +++ b/net/ipv4/ipconfig.c
> @@ -1081,25 +1081,27 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
> __be32 server_id = NONE;
> int mt = 0;
>
> - ext = &b->exten[4];
> - while (ext < end && *ext != 0xff) {
> - u8 *opt = ext++;
> - if (*opt == 0) /* Padding */
> - continue;
> - ext += *ext + 1;
> - if (ext >= end)
> - break;
> - switch (*opt) {
> - case 53: /* Message type */
> - if (opt[1])
> - mt = opt[2];
> - break;
> - case 54: /* Server ID (IP address) */
> - if (opt[1] >= 4)
> - memcpy(&server_id, opt + 2, 4);
> - break;
> + ext = &b->exten[4];
> + while (ext < end && *ext != 0xff) {
> + u8 *opt = ext++;
> + if (*opt == 0) /* Padding */
> + continue;
> + if (ext >= end)
> + break;
> + ext += *ext + 1;
> + if (ext > end)
> + break;
> + switch (*opt) {
> + case 53: /* Message type */
> + if (opt[1])
> + mt = opt[2];
> + break;
> + case 54: /* Server ID (IP address) */
> + if (opt[1] >= 4)
> + memcpy(&server_id, opt + 2, 4);
> + break;
> + }
> }
> - }
Please fix the indentation.
Isn't there a similar issue later in that function?
Technical Details
Message-ID:
<atHc9N49BfiGal3l@kwain>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347169-linux-kernel-netdev=dewy.ruReferences:
<20261016041152.2294843-1-liuc63@xiaopeng.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347169-linux-kernel-netdev=dewy.ru From: atenart@kernel.org (Antoine Tenart) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing Date: Fri, 16 Oct 2026 10:18:15 +0200 Organization: Usenet Network Message-ID: <atHc9N49BfiGal3l@kwain> References: <20261016041152.2294843-1-liuc63@xiaopeng.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2716421"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:sF6Da0R8zdSSbokqwbYj8r/KspA= sha256:Il7ED+YxfL9aFpiU6SM9W2lpWY3+PqAS21vvW/F4d7s= sha1:w9DjWY6hM30RR//0bOOZwnPxVhE= sha256:5Xa707uM0+L+LMMnxvNUNW0t2Zk2uhc1W2/kitqgn7U= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 7D068110498; Fri, 16 Oct 2026 11:22:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.44 X-Spam-Status: No, score=-1.44 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hAWYQlGsSZHW; Fri, 16 Oct 2026 11:22:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347169-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 42AB4110494; Fri, 16 Oct 2026 11:22:12 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 5AB91365EA; Fri, 16 Oct 2026 08:18:21 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20737361DB5; Fri, 16 Oct 2026 08:18:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cnGcFODt" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ACC3321F5E; Fri, 16 Oct 2026 08:18:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792138699; cv=none; b=WRxl67lka4CabzefHp5bPeTVPs22GXHKV3mwhPoEfb0vtXXzFaY8FHSGlY8/FuP+y37tpSg52C1o1L1Vsp9YCQUJxpshgrOi9HYNip3ETI0zQGwjrbMIV4V+94CZarlc6CE1afhJK1L0au9NVxgC5jGqhDRJpmvUVSp0jUf7OvI= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792138699; c=relaxed/simple; bh=jPT2TNYxgshiy5c36ncFZHEPx/mEloRIpcHB+v9LGrQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fmpH4cnMcr7FYDxDz5q1QGWq1CU+v0LYkrKIf0iaCzIgFrm8zMpGatmR1gkoNuUv41m4/stTRU9fXbd+BSavMpC9E6gqmYnWgZIAjCNxzjj0J7TUsV+hn8QwzntE0gwJxL1YBYxAiqiYQbowvmRMU8lsnIRtim7UZa9prf+bUOU= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cnGcFODt; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 351BE1F000C4; Fri, 16 Oct 2026 08:18:17 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792138697; bh=dBB+2bgOQbqNUHoch49xb5bDvd9pyA5NBJLGE5ayi94=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=cnGcFODt0h+SiVoV8i/+BzuEC7rd1EYEB7hAH8IjoVWjs9otPZhAF0LZ+NJTszPnS yH6dBCBq4lujTy7tEM+DH51XDx5FghhtalN0V+RmJX909ilj1oe/s6BjZVANAFs8Nn RUnd/S9/OJHgaLbW6RJHKYl80MTn0P+OAkbjkkEk1x12486G0q3vWZCRlJNKsszCd6 6w4rOfZTtp9esNIaKqxCU9C1gKCPWbZ5/J8QNTa/k9HxCNJ+N6qqjBH+MuFTL+sSN+ 5fs3nAH9D9uyJxzmpVn11wY1Kds+00rPCKHEXuPlRc/lWmBRW53MGe6eu3I/FaHL2H ogHUR9q8SSk0A== X-Cc: "David S . Miller" <davem@davemloft.net>, David Ahern <dsahern@kernel.org>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <20261016041152.2294843-1-liuc63@xiaopeng.com>