NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/55149: ipfilter fil.c's problem



>Number:         55149
>Category:       kern
>Synopsis:       ipfilter fil.c's problem
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 07 10:30:00 +0000 2020
>Originator:     Kouichi Hashikawa
>Release:        9.0-RELEASE
>Organization:
>Environment:
NetBSD kalinka 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
in src/sys/external/bsd/ipf/netinet/fil.c:ipf_pr_ipv4hdr(),
morefrag is always 0.

--------
        off &= IP_MF|IP_OFFMASK;
        if (off != 0) {
                fi->fi_flx |= FI_FRAG;
                off &= IP_OFFMASK;
                if (off != 0) {
                        int morefrag = off & IP_MF;
--------


>How-To-Repeat:
always.
>Fix:
I think, problem will be fixed by following patch.

--- src/sys/external/bsd/ipf/netinet/fil.c-dist0        2020-04-03 19:57:07.663853044 +0900
+++ src/sys/external/bsd/ipf/netinet/fil.c      2020-04-07 19:27:03.182639923 +0900
@@ -1685,6 +1685,7 @@
        const struct optlist *op;
        u_char *s, opt;
        u_short off;
+       int morefrag;
        fr_ip_t *fi;
        ip_t *ip;
 
@@ -1697,7 +1698,8 @@
        fin->fin_crc = p;
        fi->fi_tos = ip->ip_tos;
        fin->fin_id = ntohs(ip->ip_id);
-       off = ntohs(ip->ip_off);
+       off = ntohs(ip->ip_off) & IP_OFFMASK;
+       morefrag = ntohs(ip->ip_off) & IP_MF;
 
        /* Get both TTL and protocol */
        fi->fi_p = ip->ip_p;
@@ -1722,13 +1724,9 @@
         * set packet attribute flags based on the offset and
         * calculate the byte offset that it represents.
         */
-       off &= IP_MF|IP_OFFMASK;
-       if (off != 0) {
+       if (morefrag != 0 || off != 0) {
                fi->fi_flx |= FI_FRAG;
-               off &= IP_OFFMASK;
                if (off != 0) {
-                       int morefrag = off & IP_MF;
-
                        if (off == 1 && p == IPPROTO_TCP) {
                                fin->fin_flx |= FI_SHORT;       /* RFC 3128 */
                                DT1(ipf_fi_tcp_frag_off_1, fr_info_t *, fin);




Home | Main Index | Thread Index | Old Index