From: "cron2 (Code Review)" Date: Wed, 11 Dec 2024 14:23:26 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <5ac033bcd649168d77e97e8dcb95dc9304da8bb9-EmailReviewComments-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="HM2sxGhGTj0="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: forward: Fix potential unaligned access in drop_if_recursive_routing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --HM2sxGhGTj0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/ope= nvpn/+/827?usp=3Demail ) Change subject: forward: Fix potential unaligned access in drop_if_recursiv= e_routing ...................................................................... Patch Set 1: Code-Review-1 (2 comments) File src/openvpn/forward.c: http://gerrit.openvpn.net/c/openvpn/+/827/comment/70a6dbae_af15a5b9 : PS1, Line 1406: memcpy(&pip, BPTR(buf) + ip_hdr_offset, sizeof(stru= ct openvpn_iphdr)); I don't like that. We're in the per-packet fast path here, and this is exe= cuted for every single packet - so we shouldn't memcpy() the whole I header= around. I'd suggest doing a `memcmp(pip->daddr, ..., sizeof(pip->daddr))`. That sh= ould be of similar cost. http://gerrit.openvpn.net/c/openvpn/+/827/comment/d54bde03_5397571d : PS1, Line 1432: if (IN6_ARE_ADDR_EQUAL(&tun_sa.addr.in6.sin6_addr, = &pip6.daddr)) This is doing the `memcmp()` already, so we should be fine here... ``` #define IN6_ARE_ADDR_EQUAL(a, b) \ (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) = =3D=3D 0) ``` -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/827?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I74a9eec4954f3f9d208792b6b34357571f76ae4c Gerrit-Change-Number: 827 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Comment-Date: Wed, 11 Dec 2024 14:23:26 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment --HM2sxGhGTj0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

Patch set 1:Code-Review -1=

Vi= ew Change

2 comments:

  • File src/openvpn/forward.c:

    =
    • Patch Set #1, Line 140= 6: memcpy(&= pip, BPTR(buf) + ip_hdr_offset, sizeof(struct openvpn_iphdr));

      I don't like t= hat. We're in the per-packet fast path here, and this is executed for = every single packet - so we shouldn't memcpy() the whole I header aroun= d.

      I'd su= ggest doing a `memcmp(pip->daddr, ..., sizeof(pip->daddr))`. That sh= ould be of similar cost.

    • Patch Set #1, Line 1432: if (IN6_ARE_ADDR_EQUAL(= &tun_sa.addr.in6.sin6_addr, &pip6.daddr))

      This is doing the `memcmp()` al= ready, so we should be fine here...

      ```
      #define IN6_ARE_ADDR_EQUAL(a, b)= \
      (memcmp(&(a)->s6_addr[0], &(b)-= >s6_addr[0], sizeof(struct in6_addr)) =3D=3D 0)
      ```

To view, visit change 827. To unsubscribe, or for help writing mail f= ilters, visit settings.<= /p>

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I74a9eec4954f3f9d208792b6b34= 357571f76ae4c
Gerrit-Change-Number: 827
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Comment-Date: Wed, 11 Dec 2024 14:23:26= +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
--HM2sxGhGTj0=--