RDKOSS-899 : DO NOT MERGE - bluezChk-RDKC - #62
Conversation
Reason for change: Inclusion of coverity for BT Test Procedure: NA Risks: Low Priority: P2 Signed-off-by: ppalan289 <preethi_palanisamy@comcast.com>
There was a problem hiding this comment.
Pull request overview
Adds a BlueZ source patch intended to introduce known defects (resource leak + null dereference) so Coverity can detect them, and wires that patch into the bluez5_5.48 Yocto recipe via SRC_URI.
Changes:
- Introduces a new BlueZ patch that intentionally leaks memory and performs a NULL-dereference pattern.
- Applies the new patch unconditionally by adding it to
SRC_URIin the bluez5_5.48.bbappend.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| recipes-connectivity/bluez5/bluez5_5.48/bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch | Injects intentional Coverity-detectable defects into gdbus/watch.c (add_match). |
| recipes-connectivity/bluez5/bluez5_5.48.bbappend | Adds the new patch to SRC_URI, causing it to apply during normal builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data, | ||
| { | ||
| DBusError err; | ||
| char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | ||
| + char *coverity_test_buf; | ||
| + | ||
| + /* Intentionally allocate memory and do not free it on all paths | ||
| + * Used to validate Coverity RESOURCE_LEAK detection | ||
| + */ | ||
| + coverity_test_buf = g_new0(char, 16); | ||
| + | ||
| + /* Intentionally introduce NULL dereference before NULL check | ||
| + * Used to validate Coverity NULL_DEREFERENCE detection | ||
| + */ | ||
| + coverity_test_buf[0] = 'C'; | ||
| + | ||
| + if (coverity_test_buf == NULL) | ||
| + return FALSE; | ||
|
|
||
| format_rule(data, rule, sizeof(rule)); | ||
| dbus_error_init(&err); | ||
| @@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data, | ||
| return FALSE; | ||
| } | ||
|
|
||
| + /* coverity_test_buf intentionally not freed */ |
There was a problem hiding this comment.
This patch intentionally introduces a NULL dereference (dereferencing coverity_test_buf before checking for NULL) and an unconditional memory leak. Even if meant for Coverity validation, including this in the BlueZ source applied by the recipe can cause real runtime crashes under low-memory conditions and degrades code quality. Please avoid shipping intentional defects: either remove this patch from the normal build, or guard the injected code behind a compile-time flag and only enable/apply it in a dedicated Coverity-only build configuration (e.g., conditional SRC_URI based on a DISTRO_FEATURE/PACKAGECONFIG/override).
| @@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data, | |
| { | |
| DBusError err; | |
| char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | |
| + char *coverity_test_buf; | |
| + | |
| + /* Intentionally allocate memory and do not free it on all paths | |
| + * Used to validate Coverity RESOURCE_LEAK detection | |
| + */ | |
| + coverity_test_buf = g_new0(char, 16); | |
| + | |
| + /* Intentionally introduce NULL dereference before NULL check | |
| + * Used to validate Coverity NULL_DEREFERENCE detection | |
| + */ | |
| + coverity_test_buf[0] = 'C'; | |
| + | |
| + if (coverity_test_buf == NULL) | |
| + return FALSE; | |
| format_rule(data, rule, sizeof(rule)); | |
| dbus_error_init(&err); | |
| @@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data, | |
| return FALSE; | |
| } | |
| + /* coverity_test_buf intentionally not freed */ | |
| @@ -166,6 +166,6 @@ static gboolean add_match(struct filter_data *data, | |
| { | |
| DBusError err; | |
| char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | |
| format_rule(data, rule, sizeof(rule)); | |
| dbus_error_init(&err); | |
| @@ -178,6 +178,6 @@ static gboolean add_match(struct filter_data *data, | |
| return FALSE; | |
| } | |
| file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \ | ||
| " | ||
|
|
There was a problem hiding this comment.
Adding this patch to SRC_URI makes the intentional crash/leak injection apply to all builds of bluez5_5.48, not just Coverity runs. If the goal is to validate Coverity, please make this patch conditional (e.g., using bb.utils.contains on a dedicated DISTRO_FEATURE like 'coverity', or a recipe override) so production images are unaffected, or keep it out of this layer entirely.
| file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \ | |
| " | |
| " | |
| SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'coverity', ' file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch', '', d)}" |
| file://bluez-5.48-068-RDKOSS-553-stream-use-after-free.patch \ | ||
| file://bluez-5.48-069-RDKEMW-11885-UAF-in-messagefilter.patch \ | ||
| file://bluez-5.48-070-ES1-2351-remove-corrupted-hog.patch \ | ||
| file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \ |
There was a problem hiding this comment.
PR description states "Risks: Low", but this change introduces an intentional NULL dereference and memory leak into BlueZ for all builds (via SRC_URI). Unless this is strictly gated to Coverity-only builds, the operational risk is high (potential crash under OOM). Please update the PR description risk assessment or change the implementation to ensure production builds are unaffected.
Reason for change: Inclusion of coverity for BT
Test Procedure: NA
Risks: Low
Priority: P2