Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25)

Issue 6458050: code review 6458050: syscall: return EINVAL when string arguments have NUL c... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by snaury
Modified:
12 years, 1 month ago
Reviewers:
yk
CC:
golang-dev, r, bradfitz, albert.strasheim, rsc, minux1
Visibility:
Public.

Description

syscall: return EINVAL when string arguments have NUL characters Since NUL usually terminates strings in underlying syscalls, allowing it when converting string arguments is a security risk, especially when dealing with filenames. For example, a program might reason that filename like "/root/..\x00/" is a subdirectory or "/root/" and allow access to it, while underlying syscall will treat "\x00" as an end of that string and the actual filename will be "/root/..", which might be unexpected. Returning EINVAL when string arguments have NUL in them makes sure this attack vector is unusable.

Patch Set 1 #

Patch Set 2 : diff -r 6f790a92b3d2 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 6f790a92b3d2 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 4 : diff -r 6f790a92b3d2 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 18f07a49fb53 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 6 : diff -r 18f07a49fb53 https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r 18f07a49fb53 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 8 : diff -r af9e9fe6bc5a https://go.googlecode.com/hg/ #

Total comments: 9

Patch Set 9 : diff -r af9e9fe6bc5a https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 10 : diff -r 9876d0195923 https://go.googlecode.com/hg/ #

Patch Set 11 : diff -r 9876d0195923 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2811 lines, -476 lines) Patch
M src/pkg/crypto/x509/root_windows.go View 1 2 3 4 5 6 7 8 2 chunks +6 lines, -2 lines 0 comments Download
M src/pkg/exp/winfsnotify/winfsnotify.go View 1 2 3 4 5 2 chunks +10 lines, -2 lines 0 comments Download
M src/pkg/mime/type_windows.go View 1 2 3 4 5 2 chunks +6 lines, -3 lines 0 comments Download
M src/pkg/os/error_test.go View 1 2 3 4 5 6 7 8 9 1 chunk +24 lines, -0 lines 0 comments Download
M src/pkg/os/file_windows.go View 1 2 3 4 5 2 chunks +10 lines, -3 lines 0 comments Download
M src/pkg/os/stat_windows.go View 1 2 3 4 5 2 chunks +10 lines, -2 lines 0 comments Download
M src/pkg/os/user/lookup_windows.go View 1 2 3 4 5 1 chunk +9 lines, -3 lines 0 comments Download
M src/pkg/path/filepath/symlink_windows.go View 1 2 3 4 5 2 chunks +8 lines, -2 lines 0 comments Download
M src/pkg/runtime/syscall_windows_test.go View 1 2 3 4 5 6 1 chunk +2 lines, -1 line 0 comments Download
M src/pkg/syscall/dll_windows.go View 1 2 3 4 5 2 chunks +10 lines, -2 lines 0 comments Download
M src/pkg/syscall/env_windows.go View 1 2 3 4 5 6 7 8 2 chunks +16 lines, -4 lines 0 comments Download
M src/pkg/syscall/exec_plan9.go View 1 2 3 4 5 6 7 8 9 10 5 chunks +50 lines, -8 lines 0 comments Download
M src/pkg/syscall/exec_unix.go View 1 2 3 4 5 6 7 8 9 10 5 chunks +54 lines, -10 lines 0 comments Download
M src/pkg/syscall/exec_windows.go View 1 2 3 4 5 3 chunks +16 lines, -4 lines 0 comments Download
M src/pkg/syscall/mksyscall.pl View 1 2 3 4 5 2 chunks +21 lines, -1 line 0 comments Download
M src/pkg/syscall/mksyscall_windows.pl View 1 2 3 4 5 3 chunks +23 lines, -2 lines 0 comments Download
M src/pkg/syscall/security_windows.go View 1 2 3 4 5 4 chunks +23 lines, -7 lines 0 comments Download
M src/pkg/syscall/syscall.go View 1 2 3 4 5 6 7 8 9 1 chunk +35 lines, -6 lines 0 comments Download
M src/pkg/syscall/syscall_darwin.go View 1 2 3 4 5 1 chunk +4 lines, -1 line 0 comments Download
M src/pkg/syscall/syscall_freebsd.go View 1 2 3 4 5 1 chunk +4 lines, -1 line 0 comments Download
M src/pkg/syscall/syscall_linux.go View 1 2 3 4 5 2 chunks +10 lines, -2 lines 0 comments Download
M src/pkg/syscall/syscall_linux_386.go View 1 2 3 4 5 1 chunk +5 lines, -1 line 0 comments Download
M src/pkg/syscall/syscall_plan9.go View 1 2 3 4 5 1 chunk +11 lines, -3 lines 0 comments Download
M src/pkg/syscall/syscall_windows.go View 1 2 3 4 5 6 7 8 9 10 7 chunks +78 lines, -14 lines 0 comments Download
M src/pkg/syscall/syscall_windows_test.go View 1 2 3 4 5 1 chunk +2 lines, -1 line 0 comments Download
M src/pkg/syscall/zsyscall_darwin_386.go View 1 2 3 4 5 29 chunks +197 lines, -32 lines 0 comments Download
M src/pkg/syscall/zsyscall_darwin_amd64.go View 1 2 3 4 5 29 chunks +197 lines, -32 lines 0 comments Download
M src/pkg/syscall/zsyscall_freebsd_386.go View 1 2 3 4 5 28 chunks +186 lines, -31 lines 0 comments Download
M src/pkg/syscall/zsyscall_freebsd_amd64.go View 1 2 3 4 5 28 chunks +186 lines, -31 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_386.go View 1 2 3 4 5 35 chunks +248 lines, -38 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_amd64.go View 1 2 3 4 5 36 chunks +254 lines, -39 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_arm.go View 1 2 3 4 5 36 chunks +254 lines, -39 lines 0 comments Download
M src/pkg/syscall/zsyscall_netbsd_386.go View 1 2 3 4 5 25 chunks +168 lines, -28 lines 0 comments Download
M src/pkg/syscall/zsyscall_netbsd_amd64.go View 1 2 3 4 5 25 chunks +168 lines, -28 lines 0 comments Download
M src/pkg/syscall/zsyscall_openbsd_386.go View 1 2 3 4 5 27 chunks +180 lines, -30 lines 0 comments Download
M src/pkg/syscall/zsyscall_openbsd_amd64.go View 1 2 3 4 5 27 chunks +180 lines, -30 lines 0 comments Download
M src/pkg/syscall/zsyscall_plan9_386.go View 1 2 3 4 5 9 chunks +64 lines, -21 lines 0 comments Download
M src/pkg/syscall/zsyscall_windows_386.go View 1 2 3 4 5 6 chunks +41 lines, -6 lines 0 comments Download
M src/pkg/syscall/zsyscall_windows_amd64.go View 1 2 3 4 5 6 chunks +41 lines, -6 lines 0 comments Download

Messages

Total messages: 42
snaury
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 1 month ago (2012-07-30 20:44:14 UTC) #1
snaury
On Tue, Jul 31, 2012 at 12:44 AM, <snaury@gmail.com> wrote: > syscall: return EINVAL when ...
12 years, 1 month ago (2012-07-30 20:47:04 UTC) #2
r
This is a pretty big change and I'm not convinced you need to work this ...
12 years, 1 month ago (2012-07-30 23:25:54 UTC) #3
bradfitz
On Mon, Jul 30, 2012 at 4:25 PM, <r@golang.org> wrote: > This is a pretty ...
12 years, 1 month ago (2012-07-30 23:36:42 UTC) #4
r
On Mon, Jul 30, 2012 at 4:36 PM, Brad Fitzpatrick <bradfitz@golang.org> wrote: > On Mon, ...
12 years, 1 month ago (2012-07-30 23:46:13 UTC) #5
r
http://codereview.appspot.com/6458050/diff/4001/src/pkg/syscall/syscall.go File src/pkg/syscall/syscall.go (right): http://codereview.appspot.com/6458050/diff/4001/src/pkg/syscall/syscall.go#newcode17 src/pkg/syscall/syscall.go:17: // StringByteSlice returns a NUL-terminated slice of bytes assuming ...
12 years, 1 month ago (2012-07-30 23:54:27 UTC) #6
r
Gri proposes option 4: 4) Since the returned []byte is different from the string anyway ...
12 years, 1 month ago (2012-07-31 00:17:16 UTC) #7
r
Okay I have convinced myself we need to do the error version. let's make it ...
12 years, 1 month ago (2012-07-31 01:05:09 UTC) #8
snaury
On Tue, Jul 31, 2012 at 3:54 AM, <r@golang.org> wrote: > http://codereview.appspot.com/6458050/diff/4001/src/pkg/syscall/syscall.go#newcode17 > src/pkg/syscall/syscall.go:17: // ...
12 years, 1 month ago (2012-07-31 05:30:42 UTC) #9
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-07-31 05:31:44 UTC) #10
snaury
On Tue, Jul 31, 2012 at 9:30 AM, Alexey Borzenkov <snaury@gmail.com> wrote: > There are ...
12 years, 1 month ago (2012-07-31 05:37:51 UTC) #11
r
You're right about avoiding range in the loop but I had a larger point: don't ...
12 years, 1 month ago (2012-07-31 05:45:40 UTC) #12
r
The versions of these functions that obsolete existing exported functions should be exported. I don't ...
12 years, 1 month ago (2012-07-31 05:46:57 UTC) #13
albert.strasheim
Hello Since the syscall package isn't exhaustive, there's probably quite a few syscall wrapper functions ...
12 years, 1 month ago (2012-07-31 06:16:26 UTC) #14
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-07-31 19:05:26 UTC) #15
r
http://codereview.appspot.com/6458050/diff/4004/src/pkg/syscall/syscall.go File src/pkg/syscall/syscall.go (right): http://codereview.appspot.com/6458050/diff/4004/src/pkg/syscall/syscall.go#newcode27 src/pkg/syscall/syscall.go:27: func SafeStringByteSlice(s string) (a []byte, err error) { This ...
12 years, 1 month ago (2012-07-31 19:49:56 UTC) #16
rsc
StringToByteSlice SGTM. I think StringByteSlice could check for NUL and panic (be a thin wrapper ...
12 years, 1 month ago (2012-07-31 19:53:06 UTC) #17
snaury
On Tue, Jul 31, 2012 at 11:53 PM, <rsc@golang.org> wrote: > StringToByteSlice SGTM. > > ...
12 years, 1 month ago (2012-07-31 20:10:14 UTC) #18
snaury
On Tue, Jul 31, 2012 at 11:49 PM, <r@golang.org> wrote: > > http://codereview.appspot.com/6458050/diff/4004/src/pkg/syscall/syscall.go > File ...
12 years, 1 month ago (2012-07-31 20:16:45 UTC) #19
r
The Windows naming problem is easily resolved by reversing the names of the new functions, ...
12 years, 1 month ago (2012-07-31 21:06:38 UTC) #20
snaury
On Wed, Aug 1, 2012 at 1:06 AM, Rob Pike <r@golang.org> wrote: > The Windows ...
12 years, 1 month ago (2012-07-31 21:28:05 UTC) #21
r
Let's leave the question of panic aside for this CL, which is big enough already. ...
12 years, 1 month ago (2012-07-31 22:46:34 UTC) #22
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-01 06:12:41 UTC) #23
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-01 18:56:30 UTC) #24
snaury
Now fixed a small typo in a windows test and successfully tested on windows/386. Also ...
12 years, 1 month ago (2012-08-01 19:35:59 UTC) #25
minux1
On 2012/08/01 19:35:59, snaury wrote: > Now fixed a small typo in a windows test ...
12 years, 1 month ago (2012-08-01 19:47:44 UTC) #26
r
http://codereview.appspot.com/6458050/diff/14003/src/pkg/syscall/syscall.go File src/pkg/syscall/syscall.go (right): http://codereview.appspot.com/6458050/diff/14003/src/pkg/syscall/syscall.go#newcode18 src/pkg/syscall/syscall.go:18: // containing the text of s. Please add here ...
12 years, 1 month ago (2012-08-01 20:24:11 UTC) #27
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org, minux.ma@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-01 20:46:45 UTC) #28
r
http://codereview.appspot.com/6458050/diff/3034/src/pkg/crypto/x509/root_windows.go File src/pkg/crypto/x509/root_windows.go (right): http://codereview.appspot.com/6458050/diff/3034/src/pkg/crypto/x509/root_windows.go#newcode102 src/pkg/crypto/x509/root_windows.go:102: if e != nil { just use err here ...
12 years, 1 month ago (2012-08-01 21:08:40 UTC) #29
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org, minux.ma@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-01 21:43:40 UTC) #30
rsc
approach looks good. i didn't read all the files. http://codereview.appspot.com/6458050/diff/14044/src/pkg/syscall/syscall.go File src/pkg/syscall/syscall.go (right): http://codereview.appspot.com/6458050/diff/14044/src/pkg/syscall/syscall.go#newcode19 src/pkg/syscall/syscall.go:19: ...
12 years, 1 month ago (2012-08-01 21:49:43 UTC) #31
snaury
On Thu, Aug 2, 2012 at 1:49 AM, <rsc@golang.org> wrote: > This should panic. On ...
12 years, 1 month ago (2012-08-01 21:54:01 UTC) #32
snaury
On 2012/08/01 21:49:43, rsc wrote: > This should panic. On the review someone said that ...
12 years, 1 month ago (2012-08-05 18:09:44 UTC) #33
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org, minux.ma@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-05 18:11:17 UTC) #34
snaury
Hello golang-dev@googlegroups.com, r@golang.org, bradfitz@golang.org, fullung@gmail.com, rsc@golang.org, minux.ma@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 1 month ago (2012-08-05 18:18:45 UTC) #35
rsc
LGTM
12 years, 1 month ago (2012-08-05 21:18:45 UTC) #36
rsc
*** Submitted as http://code.google.com/p/go/source/detail?r=86c7b6d67466 *** syscall: return EINVAL when string arguments have NUL characters Since ...
12 years, 1 month ago (2012-08-05 21:24:37 UTC) #37
yk
the commit breaks builds on Plan 9: go build runtime: fork/exec /go/pkg/tool/plan9_386/8g: bad arg in ...
12 years, 1 month ago (2012-08-06 10:08:50 UTC) #38
snaury
I think I understand why. On plan9 path separator is NUL, so in env embedded ...
12 years, 1 month ago (2012-08-06 11:58:02 UTC) #39
yk
The path separator is the same as on unix here. Here's what go -v -x ...
12 years, 1 month ago (2012-08-06 13:12:32 UTC) #40
snaury
On 2012/08/06 13:12:32, yarikos wrote: > The path separator is the same as on unix ...
12 years, 1 month ago (2012-08-06 17:01:56 UTC) #41
yk
12 years, 1 month ago (2012-08-07 07:40:49 UTC) #42
> Could you please see if http://codereview.appspot.com/6454104 fixes plan9
build?

yes, it does. 
Спасибо!
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b