expr: fix registers datatypes
PATCH 1/1 expr: fix registers datatypes
Registers datatypes must be enum nft_registers.
Pablo Neira says:
<< From the kernel representation point of view, it doesn't make any sense to have set both sreg and dreg, but we should not make such assumption from userspace. If the user sets both sreg and dreg, it's wrong and the kernel should reply -EINVAL so the user knows that it has to fix its userspace code. This requires a bit more memory in userspace, but we don't have the memory restrictions that we have in kernelspace, so a bit more consumption won't harm. >>
So, while at it, delete the meta expr union for registers.
--- src/expr/cmp.c | 2 +- src/expr/meta.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
src/expr/cmp.c +1 -1
@@ -26,7 +26,7 @@struct nft_expr_cmp {union nft_data_reg data; -uint8_t sreg;/* enum nft_registers */ +enum nft_registers sreg;uint8_t op;/* enum nft_cmp_ops */ };
src/expr/meta.c +2 -4
@@ -28,10 +28,8 @@struct nft_expr_meta {uint8_t key;/* enum nft_meta_keys */ -union { -uint8_t dreg;/* enum nft_registers */ -uint8_t sreg;/* enum nft_registers */ - }; +enum nft_registers dreg; +enum nft_registers sreg; }; static int
Pablo Neira Ayuso
maintainerQuoted 11 lines · Arturo Borrero Gonzalez
Registers datatypes must be enum
nft_registers.Pablo Neira says:
<< From the kernel representation point of view, it doesn't make any sense to have set both sreg and dreg, but we should not make such assumption from userspace. If the user sets both sreg and dreg, it's wrong and the kernel should reply-EINVALso the user knows that it has to fix its userspace code. This requires a bit more memory in userspace, but we don't have the memory restrictions that we have in kernelspace, so a bit more consumption won't harm. >>
Quoted 1 line
So, while at it, delete the meta expr union for registers.
Need a fix for this in master, I forgot to specify. I just sent several patches. Thanks anyway.