previous: >>107860495#define __NR_brk 12now THIS is a strange syscall. it's always a good sign when the notes section advises you not to use a function, lol. if you haven't read any of the other man pages yet, go read this one: https://man7.org/linux/man-pages/man2/brk.2.html>the actual Linux system call returns the new program break on success.>On failure, the system call returns the current break.such a bizarre api. there's lots of bookkeeping and hoops required if you dare to use this syscall for your allocator. but it's pretty neat to use in toy examples. it requires a very nonstandard approachrelevant resources: man manman syscallshttps://man7.org/linux/man-pages/https://linux.die.net/man/https://elixir.bootlin.com/linux/https://elixir.bootlin.com/musl/https://elixir.bootlin.com/glibc/
#define __NR_brk 12
man man
man syscalls
Usecase?
>>107868233>Usecase?It's needed for your process to get more memory, e.g. so that malloc / new can actually allocate it for your pointers.According to quick search, now malloc/etc prefer to use mmap and other mechanisms usually.>>107868194how about you mention the use case in first postbrk() and sbrk() change the location of the program break, which defines the end of the process's data segment (i.e., the program break is the first location after the end of the uninitialized data segment). Increasing the program break has the effect of allocating memory to the process; decreasing the break deallocates memory.
Does anyone actually write programs for linux in assembly? What kind of person is interested in syscalls other than compiler authors? (Not judging, just curious)
>>107868275>What kind of person is interested in syscalls other than compiler authors? (Not judging, just curious)libc authorspeople doing security (restricting syscalls)
>>107868264>how about you mention the use case in first posti mean, that's sort of what the links to the man pages are for. depending on the specific syscall, its use case might be pretty complicated, so it wouldn't always fit nicely into the OP. i generally try to include at least a small blurb about the syscall to get discussion started, though. but i would hope most people are reading through the man pages before replying. maybe i am being unrealistic with my expectations... i guess it probably wouldn't hurt to include a link to the specific manpage for each day's syscall, at least>>107868275there are certain situations (e.g. embedded development) where you won't have access to the standard library, so you need to write your own implementation of a lot of quality of life features that it provides
>>107868290How does reducing syscalls improve security?
>>107868311nta, but syscalls are very powerful. it's giving you direct access to features of the kernel. depending on your security model, it's pretty easy to use them to bypass certain security measures. that's the whole raison d'être for seccomp: https://en.wikipedia.org/wiki/Seccompreally interesting subject. you should definitely read up on it if you're at all inclined
>>107868311>>>107868290 (You)>How does reducing syscalls improve security?for example, if your program can't use any of the syscalls that can open files, then it will never open any file to steal data from it, even if program is 100% pwnd and does what ever the attacker tells it to do, the OS will refuse to do it.you need of course first to block even more powerful syscalls e.g. starting new processes and more, I thinkAlso your program can try to attack kernel itself (by bugs in kernel) which is another region of the war (and is mostly up to the OS the git gud)
>>107868290>libc authors>people doing security (restricting syscalls)also, debugging programs - with strace.that's a nice way to ask "wtf is this program doing right now" if you mean what effect it has besides internally calculating
Of course, if you care about security THAT deeply, Linux would be your second choice to OpenBSD.
>>107868275System calls make the operating system POSIX compliant.
>>107868393>Of course, if you care about security THAT deeply, Linux would be your second choice to OpenBSD.That's right, use at least OpenBSD (better use microkernels, e.g. research Genode).Although in all of them you have syscalls of some kind, it's nice to know that. (In microkernel userspace programs probably too, right?)
>>107868437microkernels seem really interesting to me. i have been meaning to read up on them for a few months now. any other recommendations beyond genode?
>>107868461>microkernels seem really interesting to me. i have been meaning to read up on them for a few months now. any other recommendations beyond genode?I think Genode will be the one to try. AFAIK they both support being a host for hypervisor (so you run other systems later on inside it),and they also are using SeL4 or can use it (which was pretty famous).Hang around /g/ we will discuss this stuff over time. Put "microkernel" in topic when doing so
>>107868194Isn't brk just a happy-path version of mmap on any arch with an MMU?>>107868275You can use syscalls from C in a way that preserves the libc's state if you use its wrappers. This is not that useful for brk but is for eg io_uring and, often, read. Since C FILE *s don't give you nearly enough information to do most stuff you'd want to do.
>>107868194some other pages that advise you not to use a function:signals{g,s}etmaskselectgets(3)fpurge(3)
>>107868275are you referring to the actual syscalls, or also the libc wrapped versions?
>>107868826lol @ fpurge
>>107868264>According to quick search, now malloc/etc prefer to use mmap and other mechanisms usually.That means "none."
>>107869459>>According to quick search, now malloc/etc prefer to use mmap and other mechanisms usually.>That means "none."wat?99% of all non trivial programs need mallocs or new
>>107868461TRON is the best microkernel.t. OpenBSD developer>>107868336>ntaStop doing this.
>>107869521>Stop doing this.why?
>>107869543Because it's retarded and all you're doing is outing yourself as being very new. I was nice and tried to help you. I won't do it again.
>>107869551i've been using 4chan since 2011
>>107869437hm?
>>107869502Look at OP again.
>>107869587I don't believe you. Even if it were true that still means you showed up 3-4 years after the cancer was already unbearable. In other words; It isn't any type of flex.We don't need to know that you're not that anon. We already know based on the content of your post. Even if you were that anon it wouldn't matter. This trend is retarded and started a year ago. It was stupid then and it's stupid now. Stop doing it. Everyone will just assume you're an outsider and ignore the content of your post. You're basically being a tripfag without entering a tripcode at this point.I was here many years before you claimed to have showed up but I don't feel the need to tell everyone because it's unrelated to the content to any thread worth posting in. Much like this off-topic discussion is unrelated to this one. Like I said I was being nice. I won't do it in the future. This is why I don't do it. You're already trying to turn it into a pissing contest because I called you out.
>>107869551saying nta is very normal, anon
>>107869624just the wording in its notes was amusing
>>107869628>You're already trying to turn it into a pissing contestholy projection lol
>>107869634Ah, I thought you were referring to the function in generalAnd indeed, the dry writing style is sometimes unintentionally amusing
>>107869628It has been going on for much longer than a year. But yes, it is comparably new, which doesn't change the fact that it is quite useful.
>>107869671It's not useful at all. It's stupid. It's something only an attention whore would do.The only purpose it serves is knowing if the person using it showed up after about 2023.
>>107868275no, certainly not https://2ton.com.au/if only there were some way to search for information on topics like thissome kind of engine for searcheswe could call it a search engine
>>nta>>107869551I think it's ok either way.>>107869521Tron might be interesting.... for micro controllers? Strengths Extremely small footprint (kilobytes) Deterministic real‑time behavior Simple API, easy to implement Billions of deployed devices (phones, appliances, automotive ECUs) Vendor freedom: many commercial and open implementations Limitations Not a full OS—no standard filesystem, networking, or drivers No formal verification No unified ecosystem (each vendor’s implementation differs) Not designed for high‑assurance securityBecause TRON is a spec, each vendor’s implementation has its own license. Examples: µITRON implementations from different companies may be proprietary Some ITRON kernels are open source (e.g., TOPPERS/JSP, TOPPERS/ASP) Others are commercial RTOS products Some are deeply embedded in hardware and never released publiclyMore details in picrel
>>107869699>if only there were some way to search for information on topics like this>some kind of engine for searches>we could call it a search enginekek