Multiple threads calling the same function may cause condition race issues, which often leads to abnormal behavior and can cause more serious vulnerabilities such as abnormal termination, denial of service, and compromised data integrity.
This patch adds check in checkpatches.sh for strtok, which is non-reentrant. Cc: [email protected] Signed-off-by: Jie Hai <[email protected]> Acked-by: Chengwen Feng <[email protected]> Acked-by: Morten Brørup <[email protected]> --- devtools/checkpatches.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index d860f190457e..8c3d32d8e552 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -145,6 +145,14 @@ check_forbidden_additions() { # <patch> -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ "$1" || res=1 + # refrain from using some non-reentrant functions + awk -v FOLDERS="lib drivers app examples" \ + -v EXPRESSIONS="strtok\\\(" \ + -v RET_ON_FAIL=1 \ + -v MESSAGE='Using non-reentrant function strtok, prefer strtok_r' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 + # refrain from using some pthread functions awk -v FOLDERS="lib drivers app examples" \ -v EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\(" \ -- 2.22.0

