Skip to contentSkip to conversation

seccomp.2: Note that memory area is read-only

PATCH Michael Kerrisk (man-pages) 3 participants 4 messages Apr 18, 2015 – Apr 19, 2015 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Kees,

Ping!

Cheers,

Michael

Quoted 39 lines · Michael Kerrisk (man-pages)

Hi Kees,

I recently was asked about the point below, and had to go check the code to be sure, since the man page said nothing. It would be good to have a confirmation: the seccomp_data buffer supplied to a seccomp BPF program is read-only, right? (That is, one can't write to the buffer in order to change the arguments that a system call actually receives.)

A small man page patch below.

Cheers,

Michael

man2/seccomp.2 +1 -2
@@ -232,15 +232,15 @@ struct sock_filter {            /* Filter block */
 };
 .fi
 .in
 
 When executing the instructions, the BPF program operates on the
 system call information made available (i.e., use the
 .BR BPF_ABS
-addressing mode) as a buffer of the following form:
+addressing mode) as a (read-only) buffer of the following form:
 
 .in +4n
 .nf
 struct seccomp_data {
     int   nr;                   /* System call number */
     __u32 arch;                 /* AUDIT_ARCH_* value
                                    (see <linux/audit.h>) */
 
 
--

Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Michael Kerrisk (man-pages)

Hi Kees,

I recently was asked about the point below, and had to go check the code to be sure, since the man page said nothing. It would be good to have a confirmation: the seccomp_data buffer supplied to a seccomp BPF program is read-only, right? (That is, one can't write to the buffer in order to change the arguments that a system call actually receives.)

That's correct. If BPF even allows changing the data, it's not copied back to the syscall when it runs. Anything wanting to do things like that would need to use ptrace to catch the call an directly modify the registers before continuing with the call.

Quoted 2 lines

A small man page patch below.

Looks good, thanks!

-Kees

Quoted 30 lines

Cheers,

Michael

man2/seccomp.2 +1 -2
@@ -232,15 +232,15 @@ struct sock_filter {            /* Filter block */
 };
 .fi
 .in
 
 When executing the instructions, the BPF program operates on the
 system call information made available (i.e., use the
 .BR BPF_ABS
-addressing mode) as a buffer of the following form:
+addressing mode) as a (read-only) buffer of the following form:
 
 .in +4n
 .nf
 struct seccomp_data {
     int   nr;                   /* System call number */
     __u32 arch;                 /* AUDIT_ARCH_* value
                                    (see <linux/audit.h>) */
 
 
--

Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Signature · 6 lines
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 10 lines · Kees Cook
Quoted 7 lines · Michael Kerrisk (man-pages)

Hi Kees,

I recently was asked about the point below, and had to go check the code to be sure, since the man page said nothing. It would be good to have a confirmation: the seccomp_data buffer supplied to a seccomp BPF program is read-only, right? (That is, one can't write to the buffer in order to change the arguments that a system call actually receives.)

Quoted 4 lines

That's correct. If BPF even allows changing the data, it's not copied back to the syscall when it runs. Anything wanting to do things like that would need to use ptrace to catch the call an directly modify the registers before continuing with the call.

Today BPF programs can only read from seccomp_data buffer. I think it would be an interesting feature to allow overwrite of syscall arguments by the program on the fly... sometime in the future.

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Kees Cook
Quoted 16 lines · Kees Cook
Quoted 7 lines · Michael Kerrisk (man-pages)

Hi Kees,

I recently was asked about the point below, and had to go check the code to be sure, since the man page said nothing. It would be good to have a confirmation: the seccomp_data buffer supplied to a seccomp BPF program is read-only, right? (That is, one can't write to the buffer in order to change the arguments that a system call actually receives.)

That's correct. If BPF even allows changing the data, it's not copied back to the syscall when it runs. Anything wanting to do things like that would need to use ptrace to catch the call an directly modify the registers before continuing with the call.

Quoted 1 line
Quoted 3 lines
Quoted 1 line

A small man page patch below.

Looks good, thanks!

Thanks, Kees!

Cheers,

Michael

Quoted 31 lines
Quoted 22 lines
man2/seccomp.2 +1 -2
@@ -232,15 +232,15 @@ struct sock_filter {            /* Filter block */
 };
 .fi
 .in
 
 When executing the instructions, the BPF program operates on the
 system call information made available (i.e., use the
 .BR BPF_ABS
-addressing mode) as a buffer of the following form:
+addressing mode) as a (read-only) buffer of the following form:
 
 .in +4n
 .nf
 struct seccomp_data {
     int   nr;                   /* System call number */
     __u32 arch;                 /* AUDIT_ARCH_* value
                                    (see <linux/audit.h>) */
 
 
--
Quoted 3 lines

Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

--
Kees Cook
Chrome OS Security

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html