Skip to content

Conversation

bazsi
Copy link
Collaborator

@bazsi bazsi commented Feb 5, 2019

Signed-off-by: Balazs Scheidler [email protected]

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@xtaran
Copy link

xtaran commented Feb 5, 2019

While I haven't checked if the same issue is present when using IPv6 nor if that afinet driver is IPv4 only, it looks to me as if this code is hardcoding IPv4-specific values:

/* maximum ip datagram is 65535, minus IP + UDP header */
self->spoof_source_max_msglen = MAX(0, MIN(max_msglen, 65535 - 20 - 8));

So if not all we're looking at here is IPv4-only, this might cause some issues with UDP over IPv6.

@bazsi
Copy link
Collaborator Author

bazsi commented Feb 6, 2019 via email

@xtaran
Copy link

xtaran commented Feb 6, 2019

You are right these are ipv4 specific values, but in reality these don't really matter that much. In reality, anything that is more than a very few fragments will be practically useless in production scenarios.

True indeed.

My thought was though more going towards a potential buffer overflow or memory leak if this maximal allowed size is used in conjunction with IPv6 UDP packets… The current value seems to be the theoretically biggest usable size. (Which is probably be totally ok if using this with IPv6 packets doesn't cause any memory management issues — but I'm not versed enough with C to determine if this is the case.)

I can't remember the exact reasoning for the truncation, […] And 1024 was the limit in RFC3164.

I suspected the latter as cause: The old syslog RFC 3164 indeed limits the size to 1024 bytes. And it also has a requirement to make relayed syslog messages adhering to the RFC if they didn't do before. These two rules together demands such a — from nowadays point of view unexpected — behaviour.

Anyway, thanks for caring and looking into this!

@gaborznagy
Copy link
Collaborator

Do we need to make this value configurable by users?
How about extending the max. value if we need a limit at all.
By adding an option to control this setting:

  • the user should always take care of the set limit, and still can hit that limit
  • it increases configuration complexity

As I see it after reading the linked RFC3164 parts, that we should only limit the length if we have to force RFC3164 format and not always.

@xtaran
Copy link

xtaran commented Feb 6, 2019

As I see it after reading the linked RFC3164 parts, that we should only limit the length if we have to force RFC3164 format and not always.

Sounds ok for me, too.

Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open point: #2535 (comment)

Copy link
Collaborator

@lbudai lbudai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @gaborznagy regarding to the warning message, or if we think that this max size is also known to the users, then we could document that we check the input.

@szemere szemere changed the title afinet: add option to set the maximum spoofed datagram size [WIP] afinet: add option to set the maximum spoofed datagram size Feb 14, 2019
@bazsi bazsi force-pushed the spoof-source-max-msglen branch from 8ad81d7 to 887d128 Compare March 22, 2019 09:00
@bazsi
Copy link
Collaborator Author

bazsi commented Mar 22, 2019

I have now added a warning, although I don't see it really adds any value. I don't expect anyone hitting that. But with that this should be ok for merging.

@bazsi bazsi changed the title [WIP] afinet: add option to set the maximum spoofed datagram size afinet: add option to set the maximum spoofed datagram size Mar 22, 2019
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the warning on the setter function!

I have given some thoughts to my previous comment:

Do we need to make this value configurable by users?
How about extending the max. value if we need a limit at all.
By adding an option to control this setting:

the user should always take care of the set limit, and still can hit that limit
it increases configuration complexity
As I see it after reading the linked RFC3164 parts, that we should only limit the length if we have to force RFC3164 format and not always.

I see that we need a limit, and we cannot guess the max value as it is environment-related, so this should be set by the user.

I was thinking to have a warning in case we truncate the UDP packet.
However if we consider that this max value is forced by the environment which cannot be changed, then the warning messages wouldn't help at all.
It would be just noise in the internal logs.
And I think the truncate feature implemented, because it was not possible to avoid fragmentation.

@gaborznagy gaborznagy merged commit 5c3f497 into syslog-ng:master Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants