You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net: signed-integer-overflow in LocalServiceInfo #24049
nScore is of type int which is signed and is 4 bytes wide on my machine (clang-12). nScore is incremented by SeenLocal during the version handshake here:
So I believe this UB is peer-triggerable (I don't think the compiler can detect this), but I don't think it's a big deal unless there's a node out there compiled with UBSAN or ftrapv. It seems like nScore can just be changed to int64_t.
I have a potential fix… It's ugly, though. And it looks like it should be UB, but I can't find a reason why.
The function which may invoke UB is (currently) defined like so:
I spent over a hundred hours trying to prove it couldn't be done.
First, I asked more senior engineers, chatted llvm devs to know it could [be an asan bug], then finally posted on stackoverflow.
You […] ignored previous discussions, ignored two review comments
I did? I'll have to look into that. I agree with the rest of your comment, though.
I have very little free time, and this isn't how I want to spend it.
Please don't mistake my frustration for arrogance.
Activity
fanquake commentedon Aug 8, 2022
#24090 was closed with no comment. @Crypt-iQ do you want to follow up here?
Crypt-iQ commentedon Aug 8, 2022
I won't have time to work on this unfortunately
fanquake commentedon Aug 9, 2022
Ok. Labelling this "Up for grabs" for now.
ViralTaco commentedon Sep 29, 2022
I have a potential fix… It's ugly, though. And it looks like it should be UB, but I can't find a reason why.
The function which may invoke UB is (currently) defined like so:
bitcoin/src/net.cpp
Lines 344 to 352 in 5b6f0f3
It's ugly, I know… But it leaves everything else in this repo untouched.
Fix bitcoin#24049: signed integer overflow in `SeenLocal`
ViralTaco commentedon Nov 24, 2022
Replying to #26399 (comment):
The patch makes the behavior of the code defined. (See: [intro.compliance.general], [intro.abstract])
It should do so, without any conversions.
I spent over a hundred hours trying to prove it couldn't be done.
First, I asked more senior engineers, chatted llvm devs to know it could [be an asan bug], then finally posted on stackoverflow.
I did? I'll have to look into that. I agree with the rest of your comment, though.
I have very little free time, and this isn't how I want to spend it.
Please don't mistake my frustration for arrogance.
DevAgrawal1112 commentedon Apr 1, 2023
Since I am new to open source, I would like to know if I need to change int to int64_t for nScore or if I have to work on something else.
bitcoin#24049 Issue: Update nScore datatype
Merge bitcoin#34028: p2p: Prevent integer overflow in LocalServiceInf…
Merge bitcoin#34028: p2p: Prevent integer overflow in LocalServiceInf…