• Liping Zhang's avatar
    netfilter: nfnl_cthelper: fix incorrect helper->expect_class_max · ae5c6821
    Liping Zhang authored
    The helper->expect_class_max must be set to the total number of
    expect_policy minus 1, since we will use the statement "if (class >
    helper->expect_class_max)" to validate the CTA_EXPECT_CLASS attr in
    ctnetlink_alloc_expect.
    
    So for compatibility, set the helper->expect_class_max to the
    NFCTH_POLICY_SET_NUM attr's value minus 1.
    
    Also: it's invalid when the NFCTH_POLICY_SET_NUM attr's value is zero.
    1. this will result "expect_policy = kzalloc(0, GFP_KERNEL);";
    2. we cannot set the helper->expect_class_max to a proper value.
    
    So if nla_get_be32(tb[NFCTH_POLICY_SET_NUM]) is zero, report -EINVAL to
    the userspace.
    Signed-off-by: default avatarLiping Zhang <zlpnobody@gmail.com>
    Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
    ae5c6821
nfnetlink_cthelper.c 16.7 KB