The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2f76d2eb377ccec60f3f921c71107f81db90aa64

commit 2f76d2eb377ccec60f3f921c71107f81db90aa64
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2026-12-02 21:13:48 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2026-12-02 21:13:48 +0000

    netinet6: limit size of packet options set via setsockopt(2) to MCLBYTES
    
    While soopt_getm() can indeed allocate a chain of mbufs, the control is
    then passed to ip6_pcbopts(), that passes to ip6_setpktopts().  And the
    latter refuses to work on a chain and returns EINVAL.  This all was true
    since KAME import.  Thus, the limit set by aec9c8d5a5ee indeed protects
    from a local DoS vector, but it doesn't make a practical sense.  Anything
    between MCLBYTES and IPV6_PKTOPTIONS_MBUF_LIMIT would be refused with
    EINVAL and freed.
    
    Reviewed by:            pouria
    Fixes:                  aec9c8d5a5ee52dd6d19892138ef78fc78ef2210
    PR:                     100219
    Differential Revision:  https://reviews.freebsd.org/D62252
---
 sys/netinet6/ip6_output.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 0c259e9df0eb..f6b8aed8e280 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1487,15 +1487,6 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
        int retval;
 #endif
 
-/*
- * Don't use more than a quarter of mbuf clusters.  N.B.:
- * nmbclusters is an int, but nmbclusters * MCLBYTES may overflow
- * on LP64 architectures, so cast to u_long to avoid undefined
- * behavior.  ILP32 architectures cannot have nmbclusters
- * large enough to overflow for other reasons.
- */
-#define IPV6_PKTOPTIONS_MBUF_LIMIT     ((u_long)nmbclusters * MCLBYTES / 4)
-
        level = sopt->sopt_level;
        op = sopt->sopt_dir;
        optname = sopt->sopt_name;
@@ -1554,9 +1545,8 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
                        {
                                struct mbuf *m;
 
-                               if (optlen > IPV6_PKTOPTIONS_MBUF_LIMIT) {
-                                       printf("ip6_ctloutput: mbuf limit 
hit\n");
-                                       error = ENOBUFS;
+                               if (optlen > MCLBYTES) {
+                                       error = EINVAL;
                                        break;
                                }
 

Reply via email to