Skip to content

Commit

Permalink
netfilter: ctnetlink: Fix regression in CTA_HELP processing
Browse files Browse the repository at this point in the history
Prior to Linux 4.4, it was usually harmless to send a CTA_HELP attribute
containing the name of the current helper.  That is no longer the case:
as of Linux 4.4, if ctnetlink_change_helper() returns an error from
the ct->master check, processing of the request will fail, skipping the
NFQA_EXP attribute (if present).

This patch changes the behavior to improve compatibility with user
programs that expect the kernel interface to work the way it did prior
to Linux 4.4.  If a user program specifies CTA_HELP but the argument
matches the current conntrack helper name, ignore it instead of generating
an error.

Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Kevin Cernekee authored and Pablo Neira Ayuso committed Feb 6, 2017
1 parent a963d71 commit f95d7a4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1478,14 +1478,23 @@ static int ctnetlink_change_helper(struct nf_conn *ct,
struct nlattr *helpinfo = NULL;
int err;

/* don't change helper of sibling connections */
if (ct->master)
return -EBUSY;

err = ctnetlink_parse_help(cda[CTA_HELP], &helpname, &helpinfo);
if (err < 0)
return err;

/* don't change helper of sibling connections */
if (ct->master) {
/* If we try to change the helper to the same thing twice,
* treat the second attempt as a no-op instead of returning
* an error.
*/
if (help && help->helper &&
!strcmp(help->helper->name, helpname))
return 0;
else
return -EBUSY;
}

if (!strcmp(helpname, "")) {
if (help && help->helper) {
/* we had a helper before ... */
Expand Down

0 comments on commit f95d7a4

Please sign in to comment.