Skip to content

load program: permission denied: !read_ok #1009

Answered by lmb
cuizhipeng326 asked this question in Q&A
Discussion options

You must be logged in to vote

I misread the error you gave, sorry. This is the important part:

*(u8 *)(r10 -10) = r0: R0 !read_ok

This tells you:

  • A write of a single u8
  • Into the stack at offset - 10 (r10 is the stack pointer)
  • Fails because r0 has not been initialized
  • r0 is the register used for return values

I'm guessing that your problem isn't actually in parse_ip_src_triple but in the caller. Try and check any place where you're writing into a u8 local variable and see whether there is a way that write might be uninitialized. The fact that changing the code to use htons(IPPROTO_ICMP) might just be clang being very smart and eliminating your code.

For the future, please post questions like this on StackOverflow.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@cuizhipeng326
Comment options

@lmb
Comment options

Answer selected by cuizhipeng326
@cuizhipeng326
Comment options

@ti-mo
Comment options

@cuizhipeng326
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1008 on April 12, 2023 09:57.