News for hackers. Stuff that matters.
Re:Landlock-Ing Linux by smartmic on Saturday November 29, 2025 @06:15PM (#46091740)
I am puzzled by this:

> A official c library doesn’t exist yet unfortunately, but there’s several out there you can try.

> Landlock is a Linux Security Module (LSM) available since Linux 5.13

Since when is not a C API the first and foremost interface for developers when it comes to Linux kernel stuff?

Re:Landlock-Ing Linux by muvlon on Saturday November 29, 2025 @06:23PM (#46091796)
The first and foremost interface of the kernel is the syscall interface aka the uapi. libc and other C libraries like liburing or libcap are downstream of that. Many syscalls still don't have wrappers in libc after years of use.
Re:Landlock-Ing Linux by smartmic on Saturday November 29, 2025 @06:31PM (#46091851)
Thanks for clarification! I meant more, why isn't there a C API first, but Rust, Haskell, and Go before that — that's kind of surprising or new to me.
Re:Landlock-Ing Linux by wging on Saturday November 29, 2025 @07:05PM (#46092093)
I read the article as saying that there's no official C library but unofficial ones do exist. Quote below, emphasis mine.

> A official c library doesn’t exist yet unfortunately, but there’s several out there you can try.

Also, it looks like there is more than zero support for C programs calling Landlock APIs. Even without a 3rd-party library you're not just calling syscall() with a magic number:

https://docs.kernel.org/userspace-api/landlock.html

https://github.com/torvalds/linux/blob/6bda50f4/include/uapi...

https://github.com/torvalds/linux/blob/6bda50f4/include/linu...

Re:Landlock-Ing Linux by WJW on Saturday November 29, 2025 @06:53PM (#46092014)
I don't understand what you mean. There's no "official" Rust, Haskell and Go APIs for this thing either. All libraries available seem to be just what some third party made available. There's also several C libraries, just none that have been officially endorsed by the Linux kernel team.
Re:Landlock-Ing Linux by nine_k on Saturday November 29, 2025 @07:15PM (#46092161)
Go is famous for not needing libc and talking to the kernel. Rust and Haskell have communities that are very interested in safety and security, so they are earlier adopters.

For C, unofficial support apparently sufficed for now.

Re:Landlock-Ing Linux by samus on Saturday November 29, 2025 @10:14PM (#46093280)
Yet for many syscalls there is an official library - in most cases a wrapper in libc, but especially io_uring is known to provide a C library that most applications ought to use instead of the raw syscalls.
Re:Landlock-Ing Linux by ijustlovemath on Saturday November 29, 2025 @10:35PM (#46093404)
Is io_uring not itself a set of syscalls?
Re:Landlock-Ing Linux by projektfu on Sunday November 30, 2025 @07:46AM (#46096219)
https://github.com/axboe/liburing

"This is the io_uring library, liburing. liburing provides helpers to setup and teardown io_uring instances, and also a simplified interface for applications that don't need (or want) to deal with the full kernel side implementation."

Re:Landlock-Ing Linux by samus on Sunday November 30, 2025 @08:02AM (#46096309)
Yes, it is. But it's rather complicated and not all applications need its full power.

https://lwn.net/Articles/810414/

Re:Landlock-Ing Linux by moffkalast on Sunday November 30, 2025 @10:35AM (#46097459)
What do you call syscalls in then? Assembly?
Re:Landlock-Ing Linux by jeroenhd on Saturday November 29, 2025 @06:55PM (#46092023)
The lack of a C API should not stop any C developers from using it, hopefully. The wrapper libraries are relatively simple (i.e. https://codeberg.org/git-bruh/landbox) and both Rust and Go can expose a C FFI in case developers would rather link against a more "official" library instead.

The Linux kernel has a relatively simple example on how to use the syscall even if you can't find a library to deal with it for you: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...

There is no "liblandlock" or whatever, though there totally could be. The only reason Rust, Go, and Haskell have an easy-to-use API for this syscall is because someone bothered to implement a wrapper and publish it to the usual package managers. Whatever procedure distros use to add new libraries could just as easily be used to push a landlock library/header to use it in C.

Re:Landlock-Ing Linux by mulle_nat on Saturday November 29, 2025 @07:59PM (#46092450)
I use this and have no problems with it: https://github.com/marty1885/landlock-unveil
Re:Landlock-Ing Linux by megous on Saturday November 29, 2025 @09:30PM (#46093028)
There is a C API. man landlock_add_rule for example.

https://github.com/torvalds/linux/blob/master/include/uapi/l...

you can add simple one-line wrappers if you don't like using syscall() function.

Re:Landlock-Ing Linux by wyldfire on Saturday November 29, 2025 @09:37PM (#46093076)
It's pretty subtle but it's referring to The C Library, libc.{a,so,dll,etc}. The library provided by your toolchain that supports the language.

Meaning glibc or musl or your favorite C library probably doesn't have this yet, but since the system calls are well defined you can use A C library (create your own header file using the _syscallN macro for example).

Re:Landlock-Ing Linux by Levitating on Saturday November 29, 2025 @11:15PM (#46093658)
> Since when is not a C API the first and foremost interface for developers when it comes to Linux kernel stuff?

Since the kernel developers don't make userland software?

Re:Landlock-Ing Linux by habbekrats on Sunday November 30, 2025 @07:20AM (#46096049)
Re:Landlock-Ing Linux by eikenberry on Tuesday December 02, 2025 @06:45PM (#46128492)
Because C is not the primary interface language for kernel syscalls. There is no language specific primary interface as the syscall is the primary interface and it is language agnostic. This is one of Linux's great strengths, a stable syscall API that doesn't rely on a system library.