Re: [RELEASE] ebtables version 2.0.8-rc3

Bart De Schuymer <[email protected]> Wed, 10 Jan 2007 20:08:12 +0100
Newsgroups gmane.linux.network.bridge.ebtables.user
Message-ID <[email protected]>
Op za, 23-12-2006 te 20:37 +0100, schreef Carl-Daniel Hailfinger:

> Userspace sets wh_dst_ofs=EBT_ALIGN(sizeof(struct ebt_among_info)), but the
> kernel expects wh_dst_ofs=sizeof(struct ebt_among_info). On i386, the EBT_ALIGN
> macro has no effect for the among match, but on x86_64 it does. That explains
> why the bug was never noticed on i386.
> 
> So we either change the kernel or userspace. Changing the kernel would mean
> that suddenly all existing userspace works.

It's best not to force people into using a specific kernel, so adjusting
userspace is the thing to do.

Please test the attached userspace patch.

Cheers,
Bart

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Ebtables-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ebtables-user
patch_among.diff (text/x-patch, 1.6 KB)
--- extensions/ebt_among.c.old	2007-01-08 12:36:44.000000000 +0100
+++ extensions/ebt_among.c	2007-01-10 12:29:59.000000000 +0100
@@ -298,6 +298,8 @@ static struct ebt_mac_wormhash *create_w
 	return result;
 }
 
+static int unaligned_old_size;
+
 #define OPT_DST 0x01
 #define OPT_SRC 0x02
 static int parse(int c, char **argv, int argc,
@@ -308,7 +310,7 @@ static int parse(int c, char **argv, int
 	    (struct ebt_among_info *) (*match)->data;
 	struct ebt_mac_wormhash *wh;
 	struct ebt_entry_match *h;
-	int new_size, old_size;
+	int old_size, wh_size;
 	long flen;
 	int fd;
 
@@ -354,13 +356,15 @@ static int parse(int c, char **argv, int
 		if (ebt_errormsg[0] != '\0')
 			break;
 
-		old_size = sizeof(struct ebt_entry_match) + (**match).match_size;
-		h = malloc((new_size = old_size + ebt_mac_wormhash_size(wh)));
+		wh_size = ebt_mac_wormhash_size(wh);
+		old_size = sizeof(struct ebt_entry_match) + unaligned_old_size;
+		unaligned_old_size += wh_size;
+		h = malloc(sizeof(struct ebt_entry_match) + EBT_ALIGN(unaligned_old_size));
 		if (!h)
 			ebt_print_memory();
 		memcpy(h, *match, old_size);
-		memcpy((char *) h + old_size, wh, ebt_mac_wormhash_size(wh));
-		h->match_size = new_size - sizeof(struct ebt_entry_match);
+		memcpy((char *) h + old_size, wh, wh_size);
+		h->match_size = EBT_ALIGN(unaligned_old_size);
 		info = (struct ebt_among_info *) h->data;
 		if (c == AMONG_DST) {
 			info->wh_dst_ofs =
@@ -489,5 +493,6 @@ static struct ebt_u_match among_match = 
 
 void _init(void)
 {
+	unaligned_old_size = sizeof(struct ebt_among_info);
 	ebt_register_match(&among_match);
 }