Enforce flag checking in API's
cover Enforce flag checking in API's
Since the DPDK api's are lazy about checking for flag values it means the flags can never be extended in future releases without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel openat() problem. Openat api was added but since kernel did not check flags it ended up that another syscall openat2() was necessary before the flags could be used.
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++++ lib/librte_ring/rte_ring.c | 7 +++++++ lib/librte_stack/rte_stack.c | 5 +++++ 4 files changed, 25 insertions(+)
Signature · 1 line
2.20.1
RFC 1/4 ring: future proof flag settings
All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_ring/rte_ring.c | 7 +++++++ 1 file changed, 7 insertions(+)
lib/librte_ring/rte_ring.c +7 -0
@@ -100,6 +100,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 ); +/* future proof flags, only allow supported values */ +if (flags & ~(RING_F_SP_ENQ |RING_F_SC_DEQ )) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %d\n" , flags); +return -EINVAL ; + } +/* init the ring structure */ memset (r,0 ,sizeof (*r)); ret =strlcpy (r->name, name,sizeof (r->name));
Signature · 1 line
2.20.1
RFC 2/4 hash: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/librte_hash/rte_cuckoo_hash.c +9 -0
@@ -32,6 +32,9 @@#include "rte_hash.h" #include "rte_cuckoo_hash.h" +/* Mask of all flags supported by this version */ +#define RTE_HASH_EXTRA_FLAGS_MASK 0x2f +#define FOR_EACH_BUCKET (CURRENT_BKT ,START_BUCKET ) \ for (CURRENT_BKT = START_BUCKET; \ CURRENT_BKT != NULL; \
@@ -164,6 +167,12 @@ rte_hash_create(const struct rte_hash_parameters *params)return NULL ; } +if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK ) { + rte_errno =EINVAL ; +RTE_LOG (ERR ,HASH ,"rte_hash_create: unsupported extra flags\n" ); +return NULL ; + } +/* Validate correct usage of extra options */ if ((params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY ) && (params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF )) {
Signature · 1 line
2.20.1
RFC 3/4 stack: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_stack/rte_stack.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/librte_stack/rte_stack.c +5 -0
@@ -59,6 +59,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,unsigned int sz;int ret; +if (flags & ~(RTE_STACK_F_LF )) { +STACK_LOG_ERR ("Unsupported stack flags %#x\n" , flags); +return NULL ; + } +#ifdef RTE_ARCH_64 RTE_BUILD_BUG_ON (sizeof (struct rte_stack_lf_head ) !=16 );#else
Signature · 1 line
2.20.1
RFC 4/4 cfgfile: check flags value
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/librte_cfgfile/rte_cfgfile.c +4 -0
@@ -272,6 +272,10 @@ rte_cfgfile_create(int flags)int i;struct rte_cfgfile *cfg; +/* future proof flags usage */ +if (flags & ~(CFG_FLAG_GLOBAL_SECTION |CFG_FLAG_EMPTY_VALUES )) +return NULL ; + cfg =malloc (sizeof (*cfg));if (cfg ==NULL )
Signature · 1 line
2.20.1
Re: [dpdk-dev] [RFC 1/4] ring: future proof flag settings
In reply to Stephen HemmingerQuoted 23 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Stephen Hemminger
Sent: Wednesday, February 12, 2020 11:08 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [RFC 1/4] ring: future proof flag settingsAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_ring/rte_ring.c | 7 +++++++ 1 file changed, 7 insertions(+)lib/librte_ring/rte_ring.c +0
-0
lib/librte_ring/rte_ring.c rte_ring_init(struct rte_ring *r, const char *name, unsigned count, · line 109
Quoted 10 lines
lib/librte_ring/rte_ring.c +7
-0@@ -100,6 +100,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 ); +/* future proof flags, only allow supported values */ +if (flags & ~(RING_F_SP_ENQ |RING_F_SC_DEQ )) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %d\n" , flags); +return -EINVAL ; + } +
Good idea, I think, but seems you forgot RING_F_EXACT_SZ.
Quoted 5 lines
lib/librte_ring/rte_ring.c +0
-1/* init the ring structure */ memset (r,0 ,sizeof (*r)); ret =strlcpy (r->name, name,sizeof (r->name)); --2.20.1
v2 cover enforce checking on flag values in API's
In reply to Stephen HemmingerSince the DPDK api's are lazy about checking for flag values it means the flags can never be extended in future releases without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel openat() problem. Openat api was added but since kernel did not check flags it ended up that another syscall openat2() was necessary before the flags could be used.
v2 - rebase and fix checkpatch warnings from RFC
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++++ lib/librte_ring/rte_ring.c | 10 ++++++++++ lib/librte_stack/rte_stack.c | 5 +++++ 4 files changed, 28 insertions(+)
Signature · 1 line
2.20.1
PATCH v2 1/4 ring: future proof flag settings
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
--- lib/librte_ring/rte_ring.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_ring/rte_ring.c +10 -0
@@ -42,6 +42,9 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq) +/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK 0x007F +/* true if x is a power of 2 */ #define POWEROF2 (x) ((((x)-1) & (x)) == 0)
@@ -197,6 +200,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,RTE_BUILD_BUG_ON (offsetof(struct rte_ring_headtail , tail) != offsetof(struct rte_ring_rts_headtail, tail.val.pos)); +/* future proof flags, only allow supported values */ +if (flags & ~RING_F_MASK ) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %#x\n" , flags); +return -EINVAL ; + } +/* init the ring structure */ memset (r,0 ,sizeof (*r)); ret =strlcpy (r->name, name,sizeof (r->name));
Signature · 1 line
2.20.1
PATCH v2 2/4 hash: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/librte_hash/rte_cuckoo_hash.c +9 -0
@@ -32,6 +32,9 @@#include "rte_hash.h" #include "rte_cuckoo_hash.h" +/* Mask of all flags supported by this version */ +#define RTE_HASH_EXTRA_FLAGS_MASK 0x2f +#define FOR_EACH_BUCKET (CURRENT_BKT ,START_BUCKET ) \ for (CURRENT_BKT = START_BUCKET; \ CURRENT_BKT != NULL; \
@@ -164,6 +167,12 @@ rte_hash_create(const struct rte_hash_parameters *params)return NULL ; } +if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK ) { + rte_errno =EINVAL ; +RTE_LOG (ERR ,HASH ,"rte_hash_create: unsupported extra flags\n" ); +return NULL ; + } +/* Validate correct usage of extra options */ if ((params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY ) && (params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF )) {
Signature · 1 line
2.20.1
PATCH v2 3/4 stack: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_stack/rte_stack.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/librte_stack/rte_stack.c +5 -0
@@ -59,6 +59,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,unsigned int sz;int ret; +if (flags & ~(RTE_STACK_F_LF )) { +STACK_LOG_ERR ("Unsupported stack flags %#x\n" , flags); +return NULL ; + } +#ifdef RTE_ARCH_64 RTE_BUILD_BUG_ON (sizeof (struct rte_stack_lf_head ) !=16 );#else
Signature · 1 line
2.20.1
PATCH v2 4/4 cfgfile: check flags value
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/librte_cfgfile/rte_cfgfile.c +4 -0
@@ -272,6 +272,10 @@ rte_cfgfile_create(int flags)int i;struct rte_cfgfile *cfg; +/* future proof flags usage */ +if (flags & ~(CFG_FLAG_GLOBAL_SECTION |CFG_FLAG_EMPTY_VALUES )) +return NULL ; + cfg =malloc (sizeof (*cfg));if (cfg ==NULL )
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settings
In reply to Stephen Hemminger<snip>
Quoted 15 lines
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_ring/rte_ring.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/librte_ring/rte_ring.c index renamed from lib/librte_ring/rte_ring.c +0
-0
ebe5ccf0de68..70685121581f100644
lib/librte_ring/rte_ring.c static struct rte_tailq_elem rte_ring_tailq = { }; · line 45
Quoted 4 lines
lib/librte_ring/rte_ring.c +2
-0@@ -42,6 +42,9 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq) +/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK 0x007F
Is it better to construct this using the actual flag #defines?
Quoted 21 lines
lib/librte_ring/rte_ring.c +8
-0+/* true if x is a power of 2 */ #define POWEROF2 (x) ((((x)-1) & (x)) == 0)@@ -197,6 +200,13 @@ rte_ring_init(struct rte_ring *r, const char *name,unsigned count, RTE_BUILD_BUG_ON(offsetof(struct rte_ring_headtail, tail) != offsetof(struct rte_ring_rts_headtail, tail.val.pos)); +/* future proof flags, only allow supported values */ +if (flags & ~RING_F_MASK ) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %#x\n" , flags); +return -EINVAL ; + } +/* init the ring structure */ memset (r,0 ,sizeof (*r));ret =
strlcpy(r->name, name, sizeof(r->name));
--
2.20.1
Re: [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settings
Quoted 19 lines · On Fri, 24 Apr 2020 18:07:15 +0000 Honnappa Nagarahalli…
<snip>
Quoted 17 lines
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_ring/rte_ring.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/librte_ring/rte_ring.c index renamed from lib/librte_ring/rte_ring.c +0
-0
ebe5ccf0de68..70685121581f100644lib/librte_ring/rte_ring.c +0
-0@@ -42,6 +42,9 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq)
Quoted 3 lines
lib/librte_ring/rte_ring.c static struct rte_tailq_elem rte_ring_tailq = { · line 46
Quoted 2 lines
lib/librte_ring/rte_ring.c +2
-0+/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK 0x007FIs it better to construct this using the actual flag #defines?
sure, but it gets long
Re: [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settings
Quoted 31 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Stephen Hemminger
Sent: Friday, April 24, 2020 8:02 PM
To: Honnappa Nagarahalli <[email protected]>
Cc: [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settingsQuoted 19 lines · On Fri, 24 Apr 2020 18:07:15 +0000 Honnappa Nagarahalli…
<snip>
Quoted 17 lines
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_ring/rte_ring.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/librte_ring/rte_ring.c index renamed from lib/librte_ring/rte_ring.c +0
-0
ebe5ccf0de68..70685121581f100644lib/librte_ring/rte_ring.c +0
-0@@ -42,6 +42,9 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq)
Quoted 5 lines
Quoted 3 lines
lib/librte_ring/rte_ring.c static struct rte_tailq_elem rte_ring_tailq = { · line 46
Quoted 2 lines
lib/librte_ring/rte_ring.c +2
-0+/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK 0x007FIs it better to construct this using the actual flag #defines?
sure, but it gets long
+1 to use public defines here.
v3 cover Enforce checking on flag values in API's
In reply to Stephen HemmingerThe DPDK API's are lax about checking for undefined flag values. This makes it impossible to add new bits to existing API's without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel openat() problem. Openat api was added but since kernel did not check flags it ended up that another syscall openat2() was necessary before the flags could be used.
v3 - define mask based on existing defines for ring and hash
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ lib/librte_hash/rte_cuckoo_hash.c | 14 ++++++++++++++ lib/librte_ring/rte_ring.c | 12 ++++++++++++ lib/librte_stack/rte_stack.c | 5 +++++ 4 files changed, 35 insertions(+)
Signature · 1 line
2.20.1
PATCH v3 1/4 ring: future proof flag settings
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
--- lib/librte_ring/rte_ring.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
lib/librte_ring/rte_ring.c +12 -0
@@ -42,6 +42,11 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq) +/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK (RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ | \ + RING_F_MP_RTS_ENQ | RING_F_MC_RTS_DEQ | \ + RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ ) +/* true if x is a power of 2 */ #define POWEROF2 (x) ((((x)-1) & (x)) == 0)
@@ -197,6 +202,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,RTE_BUILD_BUG_ON (offsetof(struct rte_ring_headtail , tail) != offsetof(struct rte_ring_rts_headtail, tail.val.pos)); +/* future proof flags, only allow supported values */ +if (flags & ~RING_F_MASK ) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %#x\n" , flags); +return -EINVAL ; + } +/* init the ring structure */ memset (r,0 ,sizeof (*r)); ret =strlcpy (r->name, name,sizeof (r->name));
Signature · 1 line
2.20.1
PATCH v3 2/4 hash: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_hash/rte_cuckoo_hash.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/librte_hash/rte_cuckoo_hash.c +14 -0
@@ -32,6 +32,14 @@#include "rte_hash.h" #include "rte_cuckoo_hash.h" +/* Mask of all flags supported by this version */ +#define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \ + RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \ + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \ + RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \ + RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \ + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) +#define FOR_EACH_BUCKET (CURRENT_BKT ,START_BUCKET ) \ for (CURRENT_BKT = START_BUCKET; \ CURRENT_BKT != NULL; \
@@ -164,6 +172,12 @@ rte_hash_create(const struct rte_hash_parameters *params)return NULL ; } +if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK ) { + rte_errno =EINVAL ; +RTE_LOG (ERR ,HASH ,"rte_hash_create: unsupported extra flags\n" ); +return NULL ; + } +/* Validate correct usage of extra options */ if ((params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY ) && (params->extra_flag &RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF )) {
Signature · 1 line
2.20.1
PATCH v3 3/4 stack: check flags on creation
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_stack/rte_stack.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/librte_stack/rte_stack.c +5 -0
@@ -59,6 +59,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,unsigned int sz;int ret; +if (flags & ~(RTE_STACK_F_LF )) { +STACK_LOG_ERR ("Unsupported stack flags %#x\n" , flags); +return NULL ; + } +#ifdef RTE_ARCH_64 RTE_BUILD_BUG_ON (sizeof (struct rte_stack_lf_head ) !=16 );#else
Signature · 1 line
2.20.1
PATCH v3 4/4 cfgfile: check flags value
In reply to Stephen HemmingerAll API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
--- lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/librte_cfgfile/rte_cfgfile.c +4 -0
@@ -272,6 +272,10 @@ rte_cfgfile_create(int flags)int i;struct rte_cfgfile *cfg; +/* future proof flags usage */ +if (flags & ~(CFG_FLAG_GLOBAL_SECTION |CFG_FLAG_EMPTY_VALUES )) +return NULL ; + cfg =malloc (sizeof (*cfg));if (cfg ==NULL )
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 1/4] ring: future proof flag settings
In reply to Stephen Hemminger<snip>
Quoted 6 lines
All API's should check that they support the flag values passed. These checks ensure that the extra bits can safely be used without risk of ABI breakage.
Signed-off-by Stephen Hemminger <[email protected]>
Quoted 36 lines
--- lib/librte_ring/rte_ring.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)lib/librte_ring/rte_ring.c index renamed from lib/librte_ring/rte_ring.c +0
-0
ebe5ccf0de68..e16dd45a82de100644lib/librte_ring/rte_ring.c +12
-0@@ -42,6 +42,11 @@ static struct rte_tailq_elem rte_ring_tailq = { };EAL_REGISTER_TAILQ (rte_ring_tailq) +/* mask of all valid flag values to ring_create() */ #define +RING_F_MASK (RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ | \ + RING_F_MP_RTS_ENQ | RING_F_MC_RTS_DEQ | \ + RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ ) +/* true if x is a power of 2 */ #define POWEROF2 (x) ((((x)-1) & (x)) == 0)@@ -197,6 +202,13 @@ rte_ring_init(struct rte_ring *r, const char *name,unsigned count, RTE_BUILD_BUG_ON(offsetof(struct rte_ring_headtail, tail) != offsetof(struct rte_ring_rts_headtail, tail.val.pos)); +/* future proof flags, only allow supported values */ +if (flags & ~RING_F_MASK ) { +RTE_LOG (ERR ,RING , +"Unsupported flags requested %#x\n" , flags); +return -EINVAL ; + } +/* init the ring structure */ memset (r,0 ,sizeof (*r));ret =
strlcpy(r->name, name, sizeof(r->name));
--
2.20.1
Re: [dpdk-dev] [PATCH v3 4/4] cfgfile: check flags value
In reply to Stephen HemmingerQuoted 6 lines · Stephen Hemminger
All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
Signed-off-by Stephen Hemminger <[email protected]>---
Re: [dpdk-dev] [PATCH v3 0/4] Enforce checking on flag values in API's
In reply to Stephen HemmingerQuoted 19 lines · Stephen Hemminger
The DPDK API's are lax about checking for undefined flag values. This makes it impossible to add new bits to existing API's without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel
openat()problem. Openat api was added but since kernel did not check flags it ended up that another syscallopenat2()was necessary before the flags could be used.v3 - define mask based on existing defines for ring and hash
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
Quoted 6 lines
lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ lib/librte_hash/rte_cuckoo_hash.c | 14 ++++++++++++++ lib/librte_ring/rte_ring.c | 12 ++++++++++++ lib/librte_stack/rte_stack.c | 5 +++++ 4 files changed, 35 insertions(+)
I think this is a good idea to do in DPDK
Re: [dpdk-dev] [PATCH v3 0/4] Enforce checking on flag values in API's
In reply to Stephen HemmingerQuoted 19 lines
The DPDK API's are lax about checking for undefined flag values. This makes it impossible to add new bits to existing API's without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel
openat()problem. Openat api was added but since kernel did not check flags it ended up that another syscallopenat2()was necessary before the flags could be used.v3 - define mask based on existing defines for ring and hash
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
Quoted 7 lines
lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ lib/librte_hash/rte_cuckoo_hash.c | 14 ++++++++++++++ lib/librte_ring/rte_ring.c | 12 ++++++++++++ lib/librte_stack/rte_stack.c | 5 +++++ 4 files changed, 35 insertions(+)--
Series Acked-by: Konstantin Ananyev <[email protected]>
Quoted 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 2/4] hash: check flags on creation
In reply to Stephen HemmingerQuoted 9 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, April 27, 2020 4:16 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Wang, Yipeng1 <[email protected]>; Gobriel, Sameh <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v3 2/4] hash: check flags on creation
Quoted 5 lines
All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
Signed-off-by Stephen Hemminger <[email protected]>---
Re: [dpdk-dev] [PATCH v3 3/4] stack: check flags on creation
In reply to Stephen HemmingerQuoted 8 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, April 27, 2020 6:16 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Eads, Gage <[email protected]>; Olivier Matz <[email protected]>
Subject: [PATCH v3 3/4] stack: check flags on creation
Quoted 5 lines
All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI.
Signed-off-by Stephen Hemminger <[email protected]>---
Thomas Monjalon
AppliedRe: [dpdk-dev] [PATCH v3 0/4] Enforce checking on flag values in API's
In reply to Bruce Richardson28/04/2020 12:28, Bruce Richardson:
Quoted 20 lines · Stephen Hemminger
Quoted 11 lines
The DPDK API's are lax about checking for undefined flag values. This makes it impossible to add new bits to existing API's without causing ABI breakage. This means we end up doing unnecessary symbol versioning just to work around applications that might pass in naughty bits.
This is the DPDK analog of the Linux kernel
openat()problem. Openat api was added but since kernel did not check flags it ended up that another syscallopenat2()was necessary before the flags could be used.Quoted 8 lines
v3 - define mask based on existing defines for ring and hash
Stephen Hemminger (4):
ring: future proof flag settings
hash: check flags on creation
stack: check flags on creation
cfgfile: check flags value
Quoted 3 lines
I think this is a good idea to do in DPDK
Series-acked-by Bruce Richardson <[email protected]>
Applied, thanks