Concerning ULOG and the MAC logging bug
Hi, I am new here so excuse me first for my bad english and then for all mistake i can make :))
So I found a bug in ULOG concerning the logging of MAC Address, searching the list archive i found a patch from Harald Welte but I think a better one can be written in this, but since i am new to kernel/netfilter coding perhaps that's not the way to do it .....
(ipt_ULOG.c) :
---------------------------------------------
Line 210
pm = NLMSG_DATA(nlh);
memset(pm, 0, sizeof(ulog_packet_msg_t));
/* copy hook, prefix, timestamp, payload, etc. */
pm->data_len = copy_len;
pm->timestamp_sec = (*pskb)->stamp.tv_sec;
pm->timestamp_usec = (*pskb)->stamp.tv_usec;
pm->mark = (*pskb)->nfmark;
pm->hook = hooknum;
if (loginfo->prefix[0] != '\0')
strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
if (in && in->hard_header_len > 0
&& (*pskb)->mac.raw != (void *) (*pskb)->nh.iph
&& in->hard_header_len <= ULOG_MAC_LEN) {
memcpy(pm->mac, (*pskb)->mac.raw, in->hard_header_len);
pm->mac_len = in->hard_header_len;
}
if (in)
strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
if (out)
strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
if (copy_len)
memcpy(pm->payload, (*pskb)->data, copy_len); ------------------------------------------------
Since the payload can also be exploited with wrong data , i would prefer a memset solution like this to the else solution proposed. And we can then erase all the else.
Please let me know, what do you think of it.
And let me know if there is a better way to tell about bugs and put some code changes.
Thx.
Quoted 2 lines · Gael Mauleon
Hi, I am new here so excuse me first for my bad english and then for all mistake i can make :))
Don't mention it. Most people on this world (including me) are not native english speakers.
Quoted 10 lines
So I found a bug in ULOG concerning the logging of MAC Address, searching the list archive i found a patch from Harald Welte but I think a better one can be written in this, but since i am new to kernel/netfilter coding perhaps that's not the way to
do it [...]Since the payload can also be exploited with wrong data , i would prefer a memset solution like this to the else solution proposed. And we can then erase all the else.
Indeed this is an alternative solution. The question is: What is more
efficient: Memsetting the whole structure or a potential branch introduced by the 'else' clause.
And: What do you mean by 'payload can be exploited with wrong data'. Are you talking about the to-be-logged packet which will become the payload of the netlink message? How could this contain wrong data?
Quoted 2 lines
And let me know if there is a better way to tell about bugs and put some code changes.
for code changes we usually use unified diff (diff -u) between original and changed code. It can easily be read by a human being and also automatically applied in case we really want to accept this change.
Quoted 1 line
Thx.
Signature · 4 lines
- Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ "If this were a dictatorship, it'd be a heck of a lot easier, just so long as I'm the dictator." -- George W. Bush Dec 18, 2000
Hi,
I think I had read the ulog_packet struct the wrong way. That's why i was talking about the payload, but it was mistake.
So the else is probably more efficient :)
But in absolute, i think memset on a struct is probably more efficient than many strncpy in some "else" statements.
Thx for the reply :)
----- Original Message -----
From: "Harald Welte" <[email protected]>
To: "Gael Mauleon" <[email protected]>
Cc: <[email protected]>
Sent: Monday, December 09, 2002 7:39 PM
Subject: Re: Concerning ULOG and the MAC logging bug
Indeed this is an alternative solution. The question is: What is more
efficient: Memsetting the whole structure or a potential branch introduced by the 'else' clause.
And: What do you mean by 'payload can be exploited with wrong data'. Are you talking about the to-be-logged packet which will become the payload of the netlink message? How could this contain wrong data?
Quoted 2 lines
And let me know if there is a better way to tell about bugs and put some code changes.
for code changes we usually use unified diff (diff -u) between original and changed code. It can easily be read by a human being and also automatically applied in case we really want to accept this change.