map_fd | map_fd workaround for ld_classic on OS X

 by   bfleischer C Version: map_fd-1.0 License: No License

kandi X-RAY | map_fd Summary

kandi X-RAY | map_fd Summary

map_fd is a C library typically used in Xcode, macOS applications. map_fd has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

Xcode 3.2.6 is the last version of Xcode that supports building kernel extension for Mac OS X 10.4 and 10.5. However, running Xcode 3.2.6 on Mac OS X versions greater than 10.6 is unsupported and requires some tweaking.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              map_fd has a low active ecosystem.
              It has 5 star(s) with 2 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 1 open issues and 0 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of map_fd is map_fd-1.0

            kandi-Quality Quality

              map_fd has no bugs reported.

            kandi-Security Security

              map_fd has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              map_fd does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              map_fd releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of map_fd
            Get all kandi verified functions for this library.

            map_fd Key Features

            No Key Features are available at this moment for map_fd.

            map_fd Examples and Code Snippets

            No Code Snippets are available at this moment for map_fd.

            Community Discussions

            QUESTION

            ebpf: BPF_FUNC_map_lookup_elem calling convention
            Asked 2021-May-07 at 20:22

            Looking at kernel's sample/bpf/sock_example.c:

            ...

            ANSWER

            Answered 2021-May-07 at 20:22

            File descriptors when writing your program in user space, but later replaced by pointers to the map by the verifier.

            File Descriptors When Writing Your eBPF Program

            You write your eBPF program in user space, where you don't have any address pointer to the map. So you use a file descriptor for referencing that map for the various operations (lookups, updates, deletes) that your program may run.

            If writing your program in C, instead of assembly instructions like you do, this is usually abstracted: The program references the map with a C pointer, but the loader (typically relying on libbpf) performs some relocation step to extract metadata about the map from a dedicated ELF section of the object file, retrieves the file descriptor to the map, and inserts it in the relevant bytecode instructions.

            Kernel Verifier Switches to Pointers

            But you are correct: in the kernel, the BPF_FUNC_map_lookup_elem() helper and the like use pointers to the maps, not file descriptors. This is at load time, during verification of the program, that the verifier replaces the file descriptors by the pointers to the memory area associated to the maps (see resolve_pseudo_ldimm64() from kernel/bpf/verifier.c). It is possible to get a pointer at this time: The verifier does have access to the kernel-memory pointers for those maps.

            Note that the verifier actually goes even further and, for some map types (hash, arrays), it even replaces the calls to the helpers for map lookups completely, using instead instructions to directly read from the relevant addresses in the map (search for map_gen_lookup for details).

            Source https://stackoverflow.com/questions/67440821

            QUESTION

            _Alignas(N), [[gnu::aligned(N)]], and __attribute__((aligned(N))) position in declarations
            Asked 2021-May-04 at 11:15

            For the following union (without AAA or BBB):

            ...

            ANSWER

            Answered 2021-May-04 at 11:15

            I don't know what the theoretical answer is according to the standard and the GNU documentation, as they're not very detailed, but here's an extensive experimental answer.

            For my experiment I wrote the following file:

            align.c:

            Source https://stackoverflow.com/questions/67271825

            QUESTION

            Unable to run bpf program as non root
            Asked 2021-Jan-29 at 18:16

            I am trying to run a simple bpf program that I wrote. But I am not able to run it as non root user. Below is the program I am trying to load, It basically gets the pointer to my map whose fd is map_fd (I am not showing the code where I create the map). It works as root but for some reason fails with non root user.

            Output of uname -a

            ...

            ANSWER

            Answered 2021-Jan-29 at 18:16

            TL;DR. Qeole is correct, you first need to make sure you are using one of the BPF program types allowed for unprivileged users. You also need to check your sysctl settings. Finally, your current program has a pointer leak that should be fixed before it is loaded by an unprivileged users.

            Using the correct program type

            The kernel allows unprivileged users to load only two types of BPF programs, BPF_PROG_TYPE_SOCKET_FILTER and BPF_PROG_TYPE_CGROUP_SKB. You can see the check in the kernel for that condition in kernel/bpf/syscall.c.

            Setting the proper sysctl

            The kernel.unprivileged_bpf_disabled sysctl controls whether unprivileged users can load eBPF programs. It is unfortunately set to 0 (allow loading) on major distributions.

            Source https://stackoverflow.com/questions/65949586

            QUESTION

            Network packet counting: Failure to read packet data from a BPF socket filter
            Asked 2020-Nov-13 at 14:37

            I'd like to count incoming network packets and it len in bytes for each TOS value. I created two maps, the first one with 256 entries which contains packet count of each TOS value and the second with packet bytes. So I've written the following eBPF socket filter:

            ...

            ANSWER

            Answered 2020-Nov-13 at 14:28
            Problem: Reading from the Socket Buffer

            The context placed in BPF_REG_1 before the program starts is not a pointer to the beginning of the data. Instead, it is a pointer to a struct __sk_buff defined in the UAPI headers as follows:

            Source https://stackoverflow.com/questions/64803992

            QUESTION

            BPF: `bpf_obj_get_info_by_fd` fails with `Invalid argument`
            Asked 2020-Mar-13 at 10:08

            I try to get the fd of the BPF_MAP_TYPE_XSKMAP in my user-space program.

            This is the code:

            ...

            ANSWER

            Answered 2020-Mar-13 at 10:08

            There is a comment in a function from the kernel code called when you try to retrieve information about your program, stating:

            /* If we're handed a bigger struct than we know of, ensure all the unknown bits are 0 - i.e. new user-space does not rely on any kernel feature extensions we don't know about yet. [...] */

            I think this is what you hit in your case. Your libbpf version might use some attributes in struct bpf_prog_info that the kernel is not aware of.

            To ensure that the kernel accepts it, simply try to zero-initialise your struct:

            Source https://stackoverflow.com/questions/60654466

            QUESTION

            AF_XDP: invalid indirect read from stack
            Asked 2020-Mar-12 at 16:04

            I tried to implement the mapping I talked about in this post: AF_XDP: map `(SRC-IP, DST-IP, DST-Port)` to index to `BPF_MAP_TYPE_XSKMAP`

            My Kernelprogram has this map:

            ...

            ANSWER

            Answered 2020-Mar-12 at 16:04

            The BPF and XDP Reference Guide from Cilium has an excellent explanation for this problem.

            In short, this is because the compiler automatically adds some padding to your key and moves it to the stack before calling the map update helper. But when this program is checked, the verifier realises there are some uninitialised bytes it is not aware of, and rejects the program.

            You could fix it by packing your struct, although this also has some disadvantages. The recommended solution is to manually pad your key to have it fit on a multiple of four bytes. From OP's edit:

            Source https://stackoverflow.com/questions/60601180

            QUESTION

            eBPF maps for one element. Map type and kernel/user space communication
            Asked 2019-Aug-24 at 13:43

            I'd create a map to store just one element (a port number) and it should be read/written both from userspace and kernelspace. Which map type should I use? Which size for key and value is appropriate and how can I write/read from both sides?

            _user.c

            ...

            ANSWER

            Answered 2019-Aug-23 at 14:58

            If you know you have just one element, the easiest is probably to go for an array map. In that case, you can trivially access your map entry by its index in the array: 0.

            If you were to do that, the size of the key would be the size of a 4-byte integer (sizeof(uint32_t)), which are always used for array indices. The size of the value would be the size you need to store your port number: very likely a sizeof(uint16_t).

            Then you can read/write from your BPF program by calling the relevant BPF helper functions: bpf_map_lookup_elem() or bpf_map_update_elem() (see man page for details). They are usually defined in bpf_helpers.h which is not usually installed on your system, you can find versions of it in bcc or kernel repo.

            From user space, you would update the entry by using the bpf() system call, with its relevant commands: BPF_MAP_LOOKUP_ELEM() and BPF_MAP_UPDATE_ELEM() (see man page). But you don't necessarily have to re-implement the calls yourself: if you write a program, you should probably have a look at libbpf that provides wrappers. If you want to update your map from the command line, this is easy to do with bpftool (see man page), something like bpftool map update key 0 0 0 0 value 0x37 0x13 (update) or bpftool map lookup key 0 0 0 0 (lookup).

            Source https://stackoverflow.com/questions/57628432

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install map_fd

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/bfleischer/map_fd.git

          • CLI

            gh repo clone bfleischer/map_fd

          • sshUrl

            git@github.com:bfleischer/map_fd.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link