News for hackers. Stuff that matters.

thasso

I would just love it if the front page were full of "Show HN: HackerFoo" posts for two weeks now.
Re:Flux 2 Klein pure C inference on Monday January 19, 2026 @03:10PM (#46683849)
> I believe that inference systems not using the Python stack (which I do not appreciate) are a way to free open models usage and make AI more accessible.

What's wrong with the Python stack? I have never much used it or any other ML stack so I'm genuinely curious.

Re:I/O Multiplexing (select vs. poll vs. epoll/kqueue) on Sunday October 12, 2025 @10:24AM (#45558438)
Your example on read(2) is a good one. There's no way to fix it purely by changing the API because, by nature, the user chooses the size of the buffer.

The difference is that fd_set is a structure that's not defined by the user. If fd_set had a standard size, the kernel could verify that nfds is within the allowed range for the fd_set structure. The select(2) system call would be harder to misuse then, although misuse would still be possible by passing custom buffers instead of pointers to fd_set structures. In that sense, I think we agree on the "problem".

It's indeed just a bit of Unix history, but I was surprised by it nonetheless.

Re:I/O Multiplexing (select vs. poll vs. epoll/kqueue) on Sunday October 12, 2025 @09:32AM (#45558126)
I don't get where my misunderstanding lies. Didn't I point out that the __copy_to_user call returns EFAULT if the memory is unmapped or unwritable? The problem is that some parts of the user stack may be mapped and writable although they're past the end of the fd_set structure.

> there's no formal API for it in the glibc headers

The author claims you can pass nfds > 1024 to select(2).If you use the fd_set structure with a size of 1024, this may lead to memory corruption if an FD > 1023 becomes ready if I understand correctly.

Re:I/O Multiplexing (select vs. poll vs. epoll/kqueue) on Sunday October 12, 2025 @08:43AM (#45557836)
This part is bewildering to me:

> Now, if you try to watch file descriptor 2000, select will loop over fds from 0 to 1999 and will read garbage. The bigger issue is when it tries to set results for a file descriptor past 1024 and tries to set that bit field in say readfds, writefds or errorfds field. At this point it will write something random on the stack eventually crashing the process and making it very hard to debug what happened since your stack is randomized.

I'm not too literate on the Linux kernel code, but I checked, and it looks like the author is right [1].

It would have been so easy to introduce a size check on the array to make sure this can't happen. The man page reads like FD_SETSIZE differs between platforms. It states that FD_SETSIZE is 1024 in glibc, but no upper limit is imposed by the Linux kernel. My guess is that the Linux kernel doesn't want to assume a value of FD_SETSIZE so they leave it unbounded.

It's hard to imagine how anyone came up with this thinking it's a good design. Maybe 1024 FDs was so much at the time when this was designed that nobody considered what would happen if this limit is reached? Or they were working on system where 1024 was the maximum number of FDs that a process can open?

[1]: The core_sys_select function checks the nfds argument passed to select(2) and modifies the fd_set structures that were passed to the system call. The function ensures that n <= max_fds (as the author of the post stated), but it doesn't compare n to the size of the fd_set structures. The set_fd_set function, which modifies the user-side fd_set structures, calls right into __copy_to_user without additional bounds checks. This means page faults will be caught and return -EFAULT, but out-of-bounds accesses that corrupt the user stack are possible.

Show HN: I wrote a from-scratch OS to serve my blog

https://github.com/thass0/tatix

Hey HN! This is a fun/educational project I built to learn OS programming. I started working on it right after graduating high school last year and have been working on it on and off during my first year of university. It features a TCP/IP stack, an HTTP server, a RAM file system, a BIOS bootloader, paging and memory management, and concurrent tasks based on cooperative scheduling, along with a...

( Read More... | 1 comment | on HN )
Claude gave me a pretty convincing response without hesitation. Can't verify if it's sensible though.
Re:Long Term Support on Friday August 01, 2025 @11:40AM (#44758447)
Can recommend this podcast [1] with Richard Hipp, primary author of SQLite, talking about, among other things, about the origins of SQLite and how they tested it for use in aviation.

[1]: https://corecursive.com/066-sqlite-with-richard-hipp/

Re:A Rust Shaped Hole on Thursday July 17, 2025 @03:20AM (#44590639)
A nice thing about C is that you can be pretty confident that you know all major footguns (assuming you spent some time reading about it). With languages that are young or complex there is a much greater chance you’re making a terrible mistake because you’re not aware of it.
Re:Is Anybody Using This Private Key on Friday July 04, 2025 @12:53PM (#44466062)
Wait why did it say the key was unused when I submitted the first time, but now it shows the key is already taken?
Re:The Rise of Whatever on Friday July 04, 2025 @05:06AM (#44462686)
I'm shocked every time I go to City Hall and wait while the clerk types my name letter by letter with two fingers. Doesn't he do that every day?! How as it never occurred to him or anyone else that maybe, just maybe, they would benefit from a typing course. It’s just one example of a pattern I’ve noticed with a lot of office workers.
Re:Demystifying Debuggers on Wednesday June 11, 2025 @02:48AM (#44244848)
If you are interested in debuggers, there was a post series by Sy Brand a few years back:

https://blog.tartanllama.xyz/writing-a-linux-debugger-setup/

Eli Bendersky also wrote about debuggers (I think his post is a great place to start):

https://eli.thegreenplace.net/2011/01/23/how-debuggers-work-...

I was fascinated with debuggers a while back exactly because they were so mysterious to me. I then wrote a ptrace debugger myself [1]. It features pretty simple implementations of the most common stuff you would expect in a debugger. Though I made the grave mistake of formatting all the code in GNU style.

[1]: https://github.com/thass0/spray/tree/main/src

Re:Ask HN: Anyone making a living from a paid API? on Saturday May 31, 2025 @11:43AM (#44144998)
Is this legal? How frequently do people with unique knowledge in a company pull things like this off?
Re:Chomsky on What ChatGPT Is Good For on Sunday May 25, 2025 @01:51PM (#44089498)
> The world’s preeminent linguist Noam Chomsky, and one of the most esteemed public intellectuals of all time, whose intellectual stature has been compared to that of Galileo, Newton, and Descartes, tackles these nagging questions in the interview that follows.

By whom?

Why don't we hear about this happening to people who are equally wealthy in classical (non-crypto) assets? Are they more discreet and harder to make out or are there protections in place at, e.g., banks that limit the efficacy of these kinds of attacks? I guess most wealth people don't have enough of their wealth in liquid assets to be a good target but people with lot's of crypto assets can easily transfer it all.
Re:On File Formats on Sunday May 25, 2025 @01:49AM (#44085843)
For archive formats, or anything that has a table of contents or an index, consider putting the index at the end of the file so that you can append to it without moving a lot of data around. This also allows for easy concatenation.
What’s the limit on how much wood we can produce? I hear people say using wood is good for carbon capture, but trees take a lot of time to grow, no? If we started using 2x to 10x the amount of wood as we did before, wouldn’t we deplete our stock of trees?
Re:Implementing a RISC-V Hypervisor on Saturday May 17, 2025 @09:40AM (#44014265)
I’m really fascinated by hypervisors but I struggled to find resources when first trying to get into them. Would love it if someone could point me to more content like this.
Re:I think about C99 strict aliasing rules on Friday May 16, 2025 @08:03PM (#44010892)
Systems languages have these weird semantics to allow writing performant low-level code and abstracting over the hardware at the same time (unsafe Rust too, check out its memory model for example). This doesn’t make any sense. Either you want a high level language to write correct code on many machines, or, if you want to make code fast, you want a language that allows writing for a specific platform. The C standard is stupid, just turn on -fno-strict-aliasing like any sane person would and get on with it.