The commit is pushed to "branch-rh7-3.10.0-1160.105.1.vz7.220.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.105.1.vz7.220.2
------>
commit a7cc4a58990d1511117720adbdd7c40062a84641
Author: Florian Westphal <f...@strlen.de>
Date:   Sat Jan 20 22:50:04 2024 +0100

    ms/netfilter: nf_tables: reject QUEUE/DROP verdict parameters
    
    This reverts commit e0abdadcc6e1.
    
    core.c:nf_hook_slow assumes that the upper 16 bits of NF_DROP
    verdicts contain a valid errno, i.e. -EPERM, -EHOSTUNREACH or similar,
    or 0.
    
    Due to the reverted commit, its possible to provide a positive
    value, e.g. NF_ACCEPT (1), which results in use-after-free.
    
    Its not clear to me why this commit was made.
    
    NF_QUEUE is not used by nftables; "queue" rules in nftables
    will result in use of "nft_queue" expression.
    
    If we later need to allow specifiying errno values from userspace
    (do not know why), this has to call NF_DROP_GETERR and check that
    "err <= 0" holds true.
    
    mFixes: e0abdadcc6e1 ("netfilter: nf_tables: accept QUEUE/DROP verdict 
parameters")
    Cc: sta...@vger.kernel.org
    Reported-by: Notselwyn <notsel...@pwning.tech>
    Signed-off-by: Florian Westphal <f...@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pa...@netfilter.org>
    
    This patch has been previously applied as a ReadyKernel patch in the
    scope of https://virtuozzo.atlassian.net/browse/RK-439.
    
    Besides this patch has been already backported into new RedHat kernel:
      * Thu Feb 15 2024 Rado Vrbovsky <rvrbo...@redhat.com> 
[3.10.0-1160.114.1.el7]
      - netfilter: nf_tables: reject QUEUE/DROP verdict parameters
        (Florian Westphal) [RHEL-23500] {CVE-2024-1086}
    
    (cherry picked from commit f342de4e2f33e0e39165d8639387aa6c19dff660)
    Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com>
---
 net/netfilter/nf_tables_api.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 59496e02a5fd..66137ce5e648 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4754,16 +4754,10 @@ static int nft_verdict_init(const struct nft_ctx *ctx, 
struct nft_data *data,
        data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
 
        switch (data->verdict.code) {
-       default:
-               switch (data->verdict.code & NF_VERDICT_MASK) {
-               case NF_ACCEPT:
-               case NF_DROP:
-               case NF_QUEUE:
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               /* fall through */
+       case NF_ACCEPT:
+       case NF_DROP:
+       case NF_QUEUE:
+               break;
        case NFT_CONTINUE:
        case NFT_BREAK:
        case NFT_RETURN:
@@ -4782,6 +4776,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, 
struct nft_data *data,
                chain->use++;
                data->verdict.chain = chain;
                break;
+       default:
+               return -EINVAL;
        }
 
        desc->len = sizeof(data->verdict);
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to