`CON34-C`: Implementation seems to check incorrect aspects of thread storage duration objects

Đang mở
#801 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Một pull request liên quan đã được merge.

  • #778 của @lcartey — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với phần triển khai CON34-C và quá trình xác thực hiện có cho các giá trị tss_t, sau đó so sánh với các ví dụ tuân thủ và không tuân thủ trong issue này. Thay đổi được hoàn tất khi vi phạm thread-storage dự kiến được báo cáo và các trường hợp giá trị chưa được khởi tạo không liên quan không bị quy cho CON34-C; hãy xác thực bằng các bài kiểm thử hiện có cho rule.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

false positive/false negative Standard-CERT-C
Affected rules
  • CON34-C
Description

The documentation seems to describe the risk of passing a tss_t into a thread. The risk here is that the new thread will have no value.

In the "compliant" case it says the appropriate fix is to use tss_get() to get the value in the current thread, then pass that value into the new thread.

In our implementation, we check that any tss_t values are definitely given a value before retrieved and passed into a thread creation statement. This is not the intention of the rule, adds additional implementation complexity, and reveals no violations in MRVA.

Example
tss_t key;
void f1() {
  // Should be marked non-compliant: new thread has no value for tss_get(key)
  // Currently not reported
  thrd_create(..., &key);
}

void f2() {
  // While the following code is suspect, it is NOT the intention of the rule is not to disallow this:
  tss_t localkey;
  tss_set(localkey, malloc(...));
  void* v = tss_get(localkey);
  thrd_create(..., v);

  // The fact that v is uninitialized has nothing to do with threads. For instance, this is also erroneous:
  printf("%d", *v);

  // Further, the above code has nothing to do with thread storage duration, and isn't necessarily invalid:
  static void *shared_buf = malloc(...);
  thrd_create(..., shared_buf); // Reasonable pattern
}
Ngôn ngữ chính
CodeQL
Star
227
Fork
82
Merge trung bình
6 ngày 7 giờ
Pull request đã merge (30 ngày)
9

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/codeql-coding-standards

Tất cả issue của github/codeql-coding-standards

Issue tương tự

Thêm issue về DevTools

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.