llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[LifetimeSafety] Track assignment chains within the same statement

Open suoyuan666 opened this issue 6 months ago • 2 comments

https://godbolt.org/z/zE1raqKzY

void target() {
    int *s;
    {
        int tgt = 2;
        int *a, *b, *c;
        a = b = c = &tgt;
        s = a;
    }
    printf("s: %d\n", *s);
}

There is a use-after-free bug in the code above, but the current implementation fails to detect it.

This happens because a and b do not hold the corresponding Loan for tgt. As a result, if we replace s = a with s = c, the use-after-free can be correctly identified.

I have conducted a preliminary analysis of this issue, which can be found here: https://github.com/llvm/llvm-project/pull/196075#discussion_r3264392605

suoyuan666 avatar May 19 '26 11:05 suoyuan666

@llvm/issue-subscribers-clang-temporal-safety

Author: Yuan Suo (suoyuan666)

https://godbolt.org/z/zE1raqKzY
void target() {
    int *s;
    {
        int tgt = 2;
        int *a, *b, *c;
        a = b = c = &tgt;
        s = a;
    }
    printf("s: %d\n", *s);
}

There is a use-after-free bug in the code above, but the current implementation fails to detect it.

This happens because a and b do not hold the corresponding Loan for tgt. As a result, if we replace s = a with s = c, the use-after-free can be correctly identified.

I have conducted a preliminary analysis of this issue, which can be found here: https://github.com/llvm/llvm-project/pull/196075#discussion_r3264392605

I would like to work on this.

NeKon69 avatar May 19 '26 11:05 NeKon69