aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2022-04-12 13:38:17 -0700
committerHeschi Kreinick <heschi@google.com>2022-05-09 20:17:54 +0000
commitc0599c5b781de023974519194df6b0c4ebb0adff (patch)
tree675bdd63cba92ded18bfe82f293331a8b5cc0801
parent2d6881b91a9bc62d55db30bf4546f929d52072be (diff)
downloadgo-c0599c5b781de023974519194df6b0c4ebb0adff.tar.gz
go-c0599c5b781de023974519194df6b0c4ebb0adff.zip
[release-branch.go1.18] syscall: check correct group in Faccessat
The Faccessat call checks the user, group, or other permission bits of a file to see if the calling process can access it. The test to see if the group permissions should be used was made with the wrong group id, using the process's group id rather than the file's group id. Fix this to use the correct group id. No test since we cannot easily change file permissions when not running as root and the test is meaningless if running as root. For #52313 Fixes #52440 Change-Id: I4e2c84754b0af7830b40fd15dedcbc58374d75ee Reviewed-on: https://go-review.googlesource.com/c/go/+/399539 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit f66925e854e71e0c54b581885380a490d7afa30c) Reviewed-on: https://go-review.googlesource.com/c/go/+/401079 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Tatiana Bradley <tatiana@golang.org> Run-TryBot: Tatiana Bradley <tatiana@golang.org> Auto-Submit: Tatiana Bradley <tatiana@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
-rw-r--r--src/syscall/syscall_linux.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
index e3891b0855..f32020ca6c 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
@@ -109,7 +109,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
gid = Getgid()
}
- if uint32(gid) == st.Gid || isGroupMember(gid) {
+ if uint32(gid) == st.Gid || isGroupMember(int(st.Gid)) {
fmode = (st.Mode >> 3) & 7
} else {
fmode = st.Mode & 7