Skip to content

Conversation

cfc4n
Copy link
Member

@cfc4n cfc4n commented Aug 9, 2025

This pull request makes several small but important changes to improve robustness and compatibility in the SSL/TLS probing code, especially when handling BoringSSL and OpenSSL differences. The main focus is on error handling and initialization logic, ensuring the code does not return prematurely in certain edge cases, and making pointer casting explicit for clarity.

Error handling and robustness improvements:

  • Commented out early return statements in several BPF probe functions (probe_ssl_master_key in boringssl_masterkey.h and probe_entry_SSL_read in openssl.h) to prevent premature exit when encountering expected conditions, such as version being zero in BoringSSL or pointer reads failing, which can be normal in some cases. This allows the probes to continue processing and handle these cases more gracefully. [1] [2] [3]
  • Added comments explaining why early returns are suppressed, particularly noting BoringSSL's use of ssl->s3->hs and the possibility of ssl->version being empty. [1] [2]

Pointer casting and initialization:

  • Explicitly casted pointers to void* in calls to bpf_probe_read_user for clarity and correctness in probe_entry_SSL_read (openssl.h).

Initialization logic fix:

  • Moved the initialization of eventCollectorWriter outside of the error check in the runModule function in root.go, ensuring it is always set when needed.

…L and OpenSSL integration

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@cfc4n cfc4n requested a review from Copilot August 9, 2025 08:56
@cfc4n cfc4n added 🐞 bug Something isn't working fix bug fix PR labels Aug 9, 2025
@cfc4n cfc4n linked an issue Aug 9, 2025 that may be closed by this pull request
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 9, 2025
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

1 similar comment
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes error handling and improves robustness in SSL/TLS probing code, particularly for BoringSSL compatibility. The changes prevent premature exits from BPF probe functions when encountering expected conditions that can be normal in certain SSL implementations.

  • Commented out early return statements in BPF probe functions to allow continued processing when pointer reads fail or version values are zero
  • Added explicit pointer casting to void* for bpf_probe_read_user calls
  • Fixed initialization logic for eventCollectorWriter to ensure it's always set when needed

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
kern/openssl.h Removes early returns and adds explicit pointer casting in SSL_read probe function
kern/boringssl_masterkey.h Prevents early return when version reading fails in BoringSSL master key probe
cli/cmd/root.go Fixes eventCollectorWriter initialization to occur outside error check

kern/openssl.h Outdated
Comment on lines 378 to 391
// return 0;
} else {
// 在BoringSSL中,主要使用ssl_st->s3->hs对象, ssl_st->version 可能为空
ssl_rbio_ptr = (u64 *)(ssl + SSL_ST_RBIO);
ret = bpf_probe_read_user(&ssl_rbio_addr, sizeof(ssl_rbio_addr),
ssl_rbio_ptr);
if (ret) {
debug_bpf_printk(
"(OPENSSL) bpf_probe_read ssl_rbio_ptr failed, ret: %d\n",
ret);
// return 0;
}
// get ssl->bio->method->type
u32 bio_type = process_BIO_type(ssl_rbio_addr);
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of commenting out the return statement, consider using a more explicit approach like setting a flag or adding a specific condition check. Commented-out code reduces maintainability and makes the control flow unclear.

Copilot uses AI. Check for mistakes.

debug_bpf_printk(
"(OPENSSL) bpf_probe_read ssl_rbio_ptr failed, ret: %d\n",
ret);
// return 0;
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of commenting out the return statement, consider using a more explicit approach like setting a flag or adding a specific condition check. Commented-out code reduces maintainability and makes the control flow unclear.

Suggested change
// return 0;
return 0;

Copilot uses AI. Check for mistakes.

debug_bpf_printk(
"(OPENSSL) bpf_probe_read ssl_rbio_num_ptr failed, ret: %d\n",
ret);
// return 0;
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of commenting out the return statement, consider using a more explicit approach like setting a flag or adding a specific condition check. Commented-out code reduces maintainability and makes the control flow unclear.

Suggested change
// return 0;
return 0;

Copilot uses AI. Check for mistakes.

@@ -200,7 +200,7 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
int ret = bpf_probe_read_user(&version, sizeof(version), (void *)ssl_version_ptr);
if (ret) {
debug_bpf_printk("bpf_probe_read tls_version failed, ret :%d\n", ret);
return 0;
// return 0; // 在BoringSSL中,version可能为0,主要是使用了ssl->s3->hs对象
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of commenting out the return statement, consider using a more explicit approach like setting a flag or adding a specific condition check. Commented-out code reduces maintainability and makes the control flow unclear.

Suggested change
// return 0; // 在BoringSSL中,version可能为0,主要是使用了ssl->s3->hs对象
// In BoringSSL, version may be 0, mainly because ssl->s3->hs object is used. Do not return here.

Copilot uses AI. Check for mistakes.

kern/openssl.h Outdated
}
// return 0;
} else {
// 在BoringSSL中,主要使用ssl_st->s3->hs对象, ssl_st->version 可能为空
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment contains mixed languages (Chinese and English) and inconsistent formatting. Consider using English consistently for code comments to improve maintainability for international development teams.

Suggested change
// 在BoringSSL中,主要使用ssl_st->s3->hs对象, ssl_st->version 可能为空
// In BoringSSL, the ssl_st->s3->hs object is mainly used; ssl_st->version may be null

Copilot uses AI. Check for mistakes.

@@ -200,7 +200,7 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
int ret = bpf_probe_read_user(&version, sizeof(version), (void *)ssl_version_ptr);
if (ret) {
debug_bpf_printk("bpf_probe_read tls_version failed, ret :%d\n", ret);
return 0;
// return 0; // 在BoringSSL中,version可能为0,主要是使用了ssl->s3->hs对象
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment contains Chinese text. Consider using English consistently for code comments to improve maintainability for international development teams.

Suggested change
// return 0; // 在BoringSSL中,version可能为0,主要是使用了ssl->s3->hs对象
// return 0; // In BoringSSL, version may be 0, mainly because the ssl->s3->hs object is used

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

3 similar comments
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

…tegration

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

5 similar comments
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

5 similar comments
Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

Copy link

github-actions bot commented Aug 9, 2025

🔧 Debug Build Complete

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n cfc4n merged commit 7dd4e9e into master Aug 10, 2025
11 checks passed
@cfc4n cfc4n deleted the bugfix/pixel6-capture-failed branch August 10, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working fix bug fix PR size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pixel6 抓不到包 用的v1.3.1
1 participant