News for hackers. Stuff that matters.
Re:Ways of Implementing a System Call by burfog on Friday January 17, 2020 @01:38AM (#22072408)
There are many more. It would be difficult to enumerate them all. Nearly anything that causes an exception is easy. Examples:

The 0xf1 byte, an "icebp" or "int1" instruction

In 32-bit code, use an FPU stack underflow

In 64-bit mode, access a non-canonical address

In 32-bit code, use the "into" instruction

Write data using a segment selector that goes beyond the LDT limit

With the alignment checking enabled, do a misaligned memory operation

Of course, we can also do system calls without causing exceptions. Examples:

Write the system call number to a well-known memory location that the OS will poll

Modulate the CPU temperature by running code. The OS decodes the signal. Use message passing that involves OFDM, LDPC, ASN.1, and digital signatures.

Re:Ways of Implementing a System Call by kccqzy on Friday January 17, 2020 @03:31AM (#22072910)
I'd do an integer division by zero. The syscall number would be the dividend, and zero is the divisor.
Re:Ways of Implementing a System Call by DonHopkins on Friday January 17, 2020 @03:45AM (#22072976)
An elegant, brilliant idea. What could possibly go wrong? ;)

How about floating point division by zero? Then you could use floating point syscall numbers! SWOON

Call it the NaNix kernel.

"To infinity, and beyond!!!"

Re:Ways of Implementing a System Call by yason on Friday January 17, 2020 @05:47AM (#22073586)
Brilliant! For example, something like 180.7 could then be understood by the kernel to "userland wants to call 70% open and 30% unlink" in one go!
Re:Ways of Implementing a System Call by rrmm on Friday January 17, 2020 @06:17AM (#22073724)
You could probably build an academic career on "fractional interpolation of parameterized system calls".
Re:Ways of Implementing a System Call by davedx on Friday January 17, 2020 @08:50AM (#22074567)
Quantum computing supremacy!
Re:Ways of Implementing a System Call by DonHopkins on Friday January 17, 2020 @12:14PM (#22076655)
Quantum Objects: Maybe that's what "Quajects" in Alexia Massalin’s Synthesis Kernel actually represent!

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.29....

p. 51: Chapter 4, Kernel Structure

All things should be made as simple as possible, but no simpler. -Albert Einstein

4.1 Quajects

Quajects are the building blocks out of which all Synthesis kernel services are composed. The name is derived from the term "object" of Object-Oriented (O-O) systems, which they strongly resemble [32]. The similarity is strong, but the difference is significant. Like objects, quajects encapsulate data and provide a well-defined interface to access it. Unlike objects, quajects use a code-synthesis implementation to achieve high performance, but lack high-level language support and inheritance.

Kernel quajects can be broadly classified into four kinds: thread, memory, I/O, and device. Thread quajects encapsulate the unit of execution, memory quajects the unit of data storage, I/O quajects the unit of data movement, and device quajects the machine's interfaces to the outside world. Each kind of quaject is defined and implemented independently.

Re:Ways of Implementing a System Call by kccqzy on Friday January 17, 2020 @08:27PM (#22081505)
That might not work. Integer division by zero is defined to raise #DE, incidentally the very first in the interrupt vector. Floating point division by zero silently produces infinity or NaN without informing the supervisor.
Re:Ways of Implementing a System Call by bicolao on Friday January 17, 2020 @04:06AM (#22073092)
> What could possibly go wrong? ;)

It's not a bug, it's a feature. This adds.. ehem.. a new dimension to integer numbers (or even complex numbers, we'll call them supercomplex numbers).

Re:Ways of Implementing a System Call by etaioinshrdlu on Friday January 17, 2020 @02:51AM (#22072715)
> Modulate the CPU temperature by running code. The OS decodes the signal. Use message passing that involves OFDM, LDPC, ASN.1, and digital signatures.

I like how you mixed this in with real suggestions.

Re:Ways of Implementing a System Call by kragen on Friday January 17, 2020 @02:56AM (#22072733)
It's an excellent suggestion if the code you're trying to communicate with is not actually the kernel, but rather other code on the machine that the kernel is attempting to prevent you from communicating with. Except for the ASN.1 part. That's never a good idea.
Re:Ways of Implementing a System Call by SAI_Peregrinus on Friday January 17, 2020 @09:24AM (#22074802)
> Except for the ASN.1 part. That's never a good idea.

Don't kink-shame the ITU-T! They're just sadomasochistic, that's all...

Re:Ways of Implementing a System Call by waterhouse on Friday January 17, 2020 @04:00AM (#22073061)
Or code not on the machine. I remember: "PowerHammer: Exfiltrating Data from Air-Gapped Computers Through Power Lines" https://news.ycombinator.com/item?id=16821513
Re:Ways of Implementing a System Call by EGreg on Friday January 17, 2020 @04:17AM (#22073149)
Re:Ways of Implementing a System Call by dfox on Friday January 17, 2020 @08:01AM (#22074211)
Nothing from that list is sane i386 syscall mechanism :).

(Which given the fact that the list contains undocumented and obscure 0xf1 icebp and not documented 0xcc int3 seems to be the intention)

Re:Ways of Implementing a System Call by int_19h on Friday January 17, 2020 @04:01AM (#22073068)
Finally, a perfect application for INTERCAL.
Re:Ways of Implementing a System Call by fredoralive on Friday January 17, 2020 @04:15AM (#22073140)
Is PC-AT style "get the keyboard controller to reset the CPU, then have special BIOS code detect situation and jump to your code?" still available in modern systems? Real mode is sortof a supervisor mode.

Of course you would have to make the KBC low level accessible to user mode which may cause issue processing legacy input devices. Plus having to reinitialise protected mode every system call might cause some efficiency issues.

Re:Ways of Implementing a System Call by dfox on Friday January 17, 2020 @11:58AM (#22076451)
IIRC enough of the KBC is still present that this might actually work, another question is whether modern UEFI firmware actually handles the SW-induced reboot.

As for entering and exiting protected mode: that is in fact surprisingly fast operation assuming that all the relevant data structures are still in place. In fact DOS XMS managers (and VxD-based Windows) switch between PM with vm86, true real mode and various unreal-ish (ie. real mode with weird values in descriptor shadow registers) modes quite regularly.

Re:Ways of Implementing a System Call by Hello71 on Friday January 17, 2020 @07:47AM (#22074120)
actually, Linux uses at least two of these:

for security reasons (ASLR), the vsyscall page is implemented on modern kernels by unmapping the page, trapping the page fault, and emulating the system call.

the recently introduced io_uring interface provides an interface to set up a buffer ring which is asynchronously polled by the kernel for system calls to execute.

Re:Ways of Implementing a System Call by Hello71 on Friday January 17, 2020 @11:39AM (#22076177)
oh, and of course if you count the vdso as "making a syscall", then three: page fault, polling, and reverse polling.