Linux containers in 500 lines of code

Relatd: I’ve used Linux containers directly and indirectly for years, but I wanted to become more familiar with them. So I wrote some code. This used to be 500 lines of code, I swear, but I’ve revised it some since publishing; I’ve ended up with about 70 lines more. I wanted specifically to find a minimal set of restrictions to run untrusted code. This isn’t how you should approach containers on anything with any exposure: you should restrict everything you can. But I think it’s important to know which permissions are categorically unsafe! ...

1 de noviembre de 2016 · 1 min · 98 palabras · Nacho Cano

The curious case of the switch statement

The earliest incarnation I can find is in ALGOL 58. The original description of ALGOL 58 is a fascinating read — it’s written like a math paper, with literal text in italics and heavy use of subscripts. Character classes are even named by Greek letters, with λ representing letters and so on. The example program at the end is completely incomprehensible, with almost every variable being a single letter and labels forming their own entire column on the left side. I guess that last bit came from FORTRAN. ...

22 de septiembre de 2016 · 1 min · 92 palabras · Nacho Cano

How to C in 2016

The first rule of C is don’t write C if you can avoid it. If you must write in C, you should follow modern rules. C has been around since the early 1970s. People have ”learned C” at various points during its evolution, but knowledge usually get stuck after learning, so everybody has a different set of things they believe about C based on the year(s) they first started learning. ...

7 de febrero de 2016 · 1 min · 74 palabras · Nacho Cano

¿Cuál es el origen de “Hello world”?

Brian Kernighan, autor de uno de los libros de programación más famosos de la historia: C Progamming Language (1978). Previamente, también habría escrito en 1973 un libro llamado A Tutorial Introduction to the Programming Language B, en el cual introdujo por primera vez el ejemplo del famoso “Hello World” » Nicolás Rivera | hipertextual.com

7 de febrero de 2016 · 1 min · 54 palabras · Nacho Cano

Reflections on Trusting Trust

You can’t trust code that you did not totally create yourself. (Especially code from companies that employ people like me.) No amount of source-level verification or scrutiny will protect you from using untrusted code. In demonstrating the possibility of this kind of attack, I picked on the C compiler. I could have picked on any program-handling program such as an assembler, a loader, or even hardware microcode. As the level of program gets lower, these bugs will be harder and harder to detect. A well installed microcode bug will be almost impossible to detect. ...

15 de agosto de 2014 · 1 min · 99 palabras · Nacho Cano

Why NULL points to 0?

A few years ago I would answer the above question with ”because NULL is defined as a void pointer to 0”, which is only half correct (and close to being wrong). The answer to this question is much more complicated and thus much more interesting. Let’s start with checking what the C standards (or actually drafts of the standards) say about the (in)famous NULL ptr. The green/yellow/orange colors mark the part that caught my attention. I’ll leave the C++0x case for another time (C++0x introduces the nullptr of std::nullptr_t type btw). For TL;DR scroll down, I summarize the points anyway. ...

26 de junio de 2012 · 1 min · 102 palabras · Nacho Cano

Limitando el número de procesos por usuario

Mediante el comando ulimit podemos consultar y controlar el valor de los recursos disponibles para la consola y los procesos que puedan ser iniciados desde ella. Las diferentes opciones que acepta este comando son: -a All current limits are reported -b The maximum socket buffer size -c The maximum size of core files created -d The maximum size of a process’s data segment -e The maximum scheduling priority ("nice") -f The maximum size of files written by the shell and its children -i The maximum number of pending signals -l The maximum size that may be locked into memory -m The maximum resident set size (many systems do not honor this limit) -n The maximum number of open file descriptors (most systems do not allow this value to be set) -p The pipe size in 512-byte blocks (this may not be set) -q The maximum number of bytes in POSIX message queues -r The maximum real-time scheduling priority -s The maximum stack size -t The maximum amount of cpu time in seconds -u The maximum number of processes available to a single user -v The maximum amount of virtual memory available to the shell and, on some systems, to its children -x The maximum number of file locks -T The maximum number of threads Para consultar todos los valores asignados actualmente: ...

1 de agosto de 2011 · 3 min · 628 palabras · Nacho Cano

Endianness

“Endianicidad” designa el formato en el que se almacenan los datos de más de un byte en un ordenador. El sistema big-endian adoptado por Motorola entre otros, consiste en representar los bytes en el orden “natural”, así el valor hexadecimal 0x4A3B2C1D se codificaría en memoria en la secuencia {4A, 3B, 2C, 1D}. En el sistema little-endian adoptado por Intel, entre otros, el mismo valor se codificaría como {1D, 2C, 3B, 4A}, de manera que de este modo se hace más intuitivo el acceso a datos, porque se efectúa fácilmente de manera incremental de menos relevante a más relevante (siempre se opera con incrementos de contador en la memoria). ...

30 de julio de 2011 · 2 min · 400 palabras · Nacho Cano

¿Un keylogger en Ubuntu?

El comando xinput permite configurar y probar dispositivos de entrada para las XWindow. Podemos obtener un listado de los dispositivos de entrada: $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=15 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ Sleep Button id=9 [slave keyboard (3)] ↳ Laptop_Integrated_Webcam_2M id=10 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)] ↳ Dell WMI hotkeys id=13 [slave keyboard (3)] También podemos obtener más información de algún dispositivo en concreto, por ejemplo, del teclado, cuyo identificador, en mi caso, es el 11: ...

22 de julio de 2011 · 4 min · 649 palabras · Nacho Cano

inception

Inception en C: $ git clone https://github.com/karthick18/inception.git

14 de marzo de 2011 · 1 min · 7 palabras · Nacho Cano