tipc: input validation
Subsystems (2)
cover tipc: input validation
This series fixes two buffer overflow on tipc due to missing input leght validation on key and algname params.
Andrea Claudi (2):
tipc: bail out if algname is abnormally long
tipc: bail out if key is abnormally long
tipc/misc.c | 3 +++ tipc/node.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.30.2
PATCH 2/2 tipc: bail out if key is abnormally long
tipc segfaults when called with an abnormally long key:
$ tipc node set key 0123456789abcdef0123456789abcdef0123456789abcdef *** buffer overflow detected ***: terminated
Fix this returning an error if key length is longer than TIPC_AEAD_KEYLEN_MAX.
--- tipc/misc.c | 3 +++ 1 file changed, 3 insertions(+)
tipc/misc.c +3 -0
@@ -113,6 +113,9 @@ int str2key(char *str, struct tipc_aead_key *key) } } +if (len >TIPC_AEAD_KEYLEN_MAX ) +return -1 ; +/* Obtain key: */ if (!ishex) { key->keylen = len;
Signature · 1 line
2.30.2
PATCH 1/2 tipc: bail out if algname is abnormally long
In reply to Andrea Clauditipc segfaults when called with an abnormally long algname:
$ tipc node set key 0x1234 algname supercalifragilistichespiralidososupercalifragilistichespiralidoso *** buffer overflow detected ***: terminated
Fix this returning an error if provided algname is longer than TIPC_AEAD_ALG_NAME.
--- tipc/node.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tipc/node.c +7 -2
@@ -236,10 +236,15 @@ get_ops:/* Get algorithm name, default: "gcm(aes)" */ opt_algname =get_opt (opts,"algname" ); -if (!opt_algname) +if (!opt_algname) {strcpy (input.key.alg_name,"gcm(aes)" ); -else + }else { +if (strlen (opt_algname->val) >TIPC_AEAD_ALG_NAME ) { +fprintf (stderr,"error, invalid algname\n" ); +return -EINVAL ; + }strcpy (input.key.alg_name, opt_algname->val); + }/* Get node identity */ opt_nodeid =get_opt (opts,"nodeid" );
Signature · 1 line
2.30.2
Re: [PATCH iproute2 1/2] tipc: bail out if algname is abnormally long
[ cc author of Fixes commit ]
Quoted 37 lines · Andrea Claudi
tipc segfaults when called with an abnormally long algname:
$ tipc node set key 0x1234 algname supercalifragilistichespiralidososupercalifragilistichespiralidoso *** buffer overflow detected ***: terminatedFix this returning an error if provided algname is longer than
TIPC_AEAD_ALG_NAME.Fixes 24bee3bf9752 ("tipc: add new commands to set TIPC AEAD key")Signed-off-by Andrea Claudi <[email protected]>--- tipc/node.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tipc/node.c +7
-2@@ -236,10 +236,15 @@ get_ops:/* Get algorithm name, default: "gcm(aes)" */ opt_algname =get_opt (opts,"algname" ); -if (!opt_algname) +if (!opt_algname) {strcpy (input.key.alg_name,"gcm(aes)" ); -else + }else { +if (strlen (opt_algname->val) >TIPC_AEAD_ALG_NAME ) { +fprintf (stderr,"error, invalid algname\n" ); +return -EINVAL ; + }strcpy (input.key.alg_name, opt_algname->val); + }/* Get node identity */ opt_nodeid =get_opt (opts,"nodeid" );
David Ahern
AppliedRe: [PATCH iproute2 1/2] tipc: bail out if algname is abnormally long
In reply to Andrea ClaudiQuoted 5 lines · Andrea Claudi
tipc segfaults when called with an abnormally long algname:
$ tipc node set key 0x1234 algname supercalifragilistichespiralidososupercalifragilistichespiralidoso *** buffer overflow detected ***: terminated
Quoted 9 lines
Fix this returning an error if provided algname is longer than
TIPC_AEAD_ALG_NAME.Fixes 24bee3bf9752 ("tipc: add new commands to set TIPC AEAD key")Signed-off-by Andrea Claudi <[email protected]>--- tipc/node.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
applied both, thanks.