[libvirt] [PATCH] nwfilter: assure that virNWFilterSnoop(Eth|Dhcp)Hdr objects don't change size

Laine Stump posted 1 patch 6 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180219193019.23177-1-laine@laine.org
src/nwfilter/nwfilter_dhcpsnoop.c | 2 ++
1 file changed, 2 insertions(+)
[libvirt] [PATCH] nwfilter: assure that virNWFilterSnoop(Eth|Dhcp)Hdr objects don't change size
Posted by Laine Stump 6 years, 2 months ago
These two objects are used to access fields in actual ethernet packets
captures with libpcap, so it's essential that they don't change size
for any reason. This patch uses gnulib's verify() macro to make sure
their sizes don't change.

Signed-off-by: Laine Stump <laine@laine.org>
---

danpb suggested doing this in his response to my patch fixing virMacAddr:

  https://www.redhat.com/archives/libvir-list/2018-February/msg00850.html

I decided to make it a separate patch from the virMacAddr fix.

 src/nwfilter/nwfilter_dhcpsnoop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 743136277d..8e955150fa 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -195,6 +195,7 @@ struct _virNWFilterSnoopEthHdr {
     uint16_t eh_type;
     uint8_t eh_data[];
 } ATTRIBUTE_PACKED;
+verify(sizeof(struct _virNWFilterSnoopEthHdr) == 14);
 
 typedef struct _virNWFilterSnoopDHCPHdr virNWFilterSnoopDHCPHdr;
 typedef virNWFilterSnoopDHCPHdr *virNWFilterSnoopDHCPHdrPtr;
@@ -216,6 +217,7 @@ struct _virNWFilterSnoopDHCPHdr {
     char      d_file[128];
     uint8_t   d_opts[];
 } ATTRIBUTE_PACKED;
+verify(sizeof(struct _virNWFilterSnoopDHCPHdr) == 236);
 
 /* DHCP options */
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nwfilter: assure that virNWFilterSnoop(Eth|Dhcp)Hdr objects don't change size
Posted by Daniel P. Berrangé 6 years, 2 months ago
On Mon, Feb 19, 2018 at 02:30:19PM -0500, Laine Stump wrote:
> These two objects are used to access fields in actual ethernet packets
> captures with libpcap, so it's essential that they don't change size
> for any reason. This patch uses gnulib's verify() macro to make sure
> their sizes don't change.
> 
> Signed-off-by: Laine Stump <laine@laine.org>
> ---
> 
> danpb suggested doing this in his response to my patch fixing virMacAddr:
> 
>   https://www.redhat.com/archives/libvir-list/2018-February/msg00850.html
> 
> I decided to make it a separate patch from the virMacAddr fix.
> 
>  src/nwfilter/nwfilter_dhcpsnoop.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list