Skip to content

Commit

Permalink
net: pktgen: fix mpls maximum labels list parsing
Browse files Browse the repository at this point in the history
Fix mpls maximum labels list parsing up to MAX_MPLS_LABELS entries (instead
of up to MAX_MPLS_LABELS - 1).

Addresses the following:

	$ echo "mpls 00000f00,00000f01,00000f02,00000f03,00000f04,00000f05,00000f06,00000f07,00000f08,00000f09,00000f0a,00000f0b,00000f0c,00000f0d,00000f0e,00000f0f" > /proc/net/pktgen/lo\@0
	-bash: echo: write error: Argument list too long

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Peter Seiderer authored and Paolo Abeni committed Mar 4, 2025
1 parent 80f6c19 commit 2b15a06
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,10 @@ static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
pkt_dev->nr_labels = 0;
do {
__u32 tmp;

if (n >= MAX_MPLS_LABELS)
return -E2BIG;

len = hex32_arg(&buffer[i], 8, &tmp);
if (len <= 0)
return len;
Expand All @@ -911,8 +915,6 @@ static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
return -EFAULT;
i++;
n++;
if (n >= MAX_MPLS_LABELS)
return -E2BIG;
} while (c == ',');

pkt_dev->nr_labels = n;
Expand Down

0 comments on commit 2b15a06

Please sign in to comment.