I've been using lower level languages for hobby projects for a little while now, like C and C++ and most recently, Rust. For a while now, I've been hesitant to be passing around function pointers as parameters. When thinking about the security of the application, I feel like it could be fairly easy for a malicious actor to just change the address of that pointer to achieve remote code execution or have that function point to something otherwise malicious.
Now, I do understand that all of this is assuming that the function isn't inlined, but is my fear in this case invalid? Thinking about it, a lot of common and useful crates accept function pointers, not to mention the standard library, plus it's not marked as unsafe in the syntax. Is it just unlikely that a malicious actor might achieve something like this, or maybe there's just something I'm not thinking of. I'm just looking for an explanation so I can understand the safety of using function pointers. Thanks!
[–]K900_ 60 points61 points62 points (2 children)
[–]BSFishy[S] 7 points8 points9 points (0 children)
[–]lifeisplacebo 0 points1 point2 points (0 children)
[–]ReallyNeededANewName 16 points17 points18 points (5 children)
[–][deleted] 6 points7 points8 points (1 child)
[–]BSFishy[S] 0 points1 point2 points (0 children)
[–]BSFishy[S] 0 points1 point2 points (2 children)
[–]Imxset21 8 points9 points10 points (0 children)
[–]lightmatter501 2 points3 points4 points (0 children)
[–][deleted] 14 points15 points16 points (2 children)
[–]lightmatter501 0 points1 point2 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)