All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing
@ 2026-10-16  4:11 Liu Chao
  2026-10-16  4:14 ` netdev-bot+sinfo
  2026-10-16  8:18 ` Antoine Tenart
  0 siblings, 2 replies; 3+ messages in thread
From: Liu Chao @ 2026-10-16  4:11 UTC (permalink / raw)
  To: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: netdev, linux-kernel

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;
+					}
 				}
-			}
 
 			pr_debug("DHCP: Got message type %d (%s)\n", mt, d->dev->name);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing
  2026-10-16  4:11 [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing Liu Chao
@ 2026-10-16  4:14 ` netdev-bot+sinfo
  2026-10-16  8:18 ` Antoine Tenart
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-10-16  4:14 UTC (permalink / raw)
  To: Liu Chao
  Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing
  2026-10-16  4:11 [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing Liu Chao
  2026-10-16  4:14 ` netdev-bot+sinfo
@ 2026-10-16  8:18 ` Antoine Tenart
  1 sibling, 0 replies; 3+ messages in thread
From: Antoine Tenart @ 2026-10-16  8:18 UTC (permalink / raw)
  To: Liu Chao
  Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netdev, linux-kernel

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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-16  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16  4:11 [PATCH] net: ipv4: ipconfig: fix OOB read in DHCP option parsing Liu Chao
2026-10-16  4:14 ` netdev-bot+sinfo
2026-10-16  8:18 ` Antoine Tenart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.