-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vitess: Fix CVE-2024-45339 [HIGH] #12173
Open
KavyaSree2610
wants to merge
9
commits into
microsoft:fasttrack/2.0
Choose a base branch
from
KavyaSree2610:kkaitepalli/CVE-2024-45339-vitess-2.0
base: fasttrack/2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+143
−24
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5c6433e
vitess: Fix CVE-2024-45339
a2eb854
Add reference link to CVE-2024-45339 patch
KavyaSree2610 4337ec7
Update SPECS/vitess/vitess.spec
KavyaSree2610 cad8ce9
Merge branch 'fasttrack/2.0' into kkaitepalli/CVE-2024-45339-vitess-2.0
jslobodzian f0c2664
vitess: fix p tests
4f6fc02
fix ptest
07b1144
remove deprecated tests
b93f5c5
Merge branch 'fasttrack/2.0' into kkaitepalli/CVE-2024-45339-vitess-2.0
KavyaSree2610 e83dd58
Merge branch 'fasttrack/2.0' into kkaitepalli/CVE-2024-45339-vitess-2.0
KavyaSree2610 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
From afd4339ec8682b92eb6bcc870d138106ffd5f58d Mon Sep 17 00:00:00 2001 | ||
From: kavyasree <[email protected]> | ||
Date: Fri, 31 Jan 2025 21:16:51 +0530 | ||
Subject: [PATCH] Patch CVE-2024-45339 | ||
|
||
Reference: https://github.com/golang/glog/pull/74 | ||
|
||
--- | ||
vendor/github.com/golang/glog/glog_file.go | 60 ++++++++++++++++------ | ||
1 file changed, 44 insertions(+), 16 deletions(-) | ||
|
||
diff --git a/vendor/github.com/golang/glog/glog_file.go b/vendor/github.com/golang/glog/glog_file.go | ||
index e7d125c..6d239fa 100644 | ||
--- a/vendor/github.com/golang/glog/glog_file.go | ||
+++ b/vendor/github.com/golang/glog/glog_file.go | ||
@@ -118,32 +118,53 @@ var onceLogDirs sync.Once | ||
// contains tag ("INFO", "FATAL", etc.) and t. If the file is created | ||
// successfully, create also attempts to update the symlink for that tag, ignoring | ||
// errors. | ||
-func create(tag string, t time.Time) (f *os.File, filename string, err error) { | ||
+func create(tag string, t time.Time, dir string) (f *os.File, filename string, err error) { | ||
+ if dir != "" { | ||
+ f, name, err := createInDir(dir, tag, t) | ||
+ if err == nil { | ||
+ return f, name, err | ||
+ } | ||
+ return nil, "", fmt.Errorf("log: cannot create log: %v", err) | ||
+ } | ||
+ | ||
onceLogDirs.Do(createLogDirs) | ||
if len(logDirs) == 0 { | ||
return nil, "", errors.New("log: no log dirs") | ||
} | ||
- name, link := logName(tag, t) | ||
var lastErr error | ||
for _, dir := range logDirs { | ||
- fname := filepath.Join(dir, name) | ||
- f, err := os.Create(fname) | ||
+ f, name, err := createInDir(dir, tag, t) | ||
if err == nil { | ||
- symlink := filepath.Join(dir, link) | ||
- os.Remove(symlink) // ignore err | ||
- os.Symlink(name, symlink) // ignore err | ||
- if *logLink != "" { | ||
- lsymlink := filepath.Join(*logLink, link) | ||
- os.Remove(lsymlink) // ignore err | ||
- os.Symlink(fname, lsymlink) // ignore err | ||
- } | ||
- return f, fname, nil | ||
+ return f, name, err | ||
} | ||
lastErr = err | ||
} | ||
return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr) | ||
} | ||
|
||
+func createInDir(dir, tag string, t time.Time) (f *os.File, name string, err error) { | ||
+ name, link := logName(tag, t) | ||
+ fname := filepath.Join(dir, name) | ||
+ // O_EXCL is important here, as it prevents a vulnerability. The general idea is that logs often | ||
+ // live in an insecure directory (like /tmp), so an unprivileged attacker could create fname in | ||
+ // advance as a symlink to a file the logging process can access, but the attacker cannot. O_EXCL | ||
+ // fails the open if it already exists, thus prevent our this code from opening the existing file | ||
+ // the attacker points us to. | ||
+ f, err = os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) | ||
+ if err == nil { | ||
+ symlink := filepath.Join(dir, link) | ||
+ os.Remove(symlink) // ignore err | ||
+ os.Symlink(name, symlink) // ignore err | ||
+ if *logLink != "" { | ||
+ lsymlink := filepath.Join(*logLink, link) | ||
+ os.Remove(lsymlink) // ignore err | ||
+ os.Symlink(fname, lsymlink) // ignore err | ||
+ } | ||
+ return f, fname, nil | ||
+ } | ||
+ return nil, "", err | ||
+} | ||
+ | ||
// flushSyncWriter is the interface satisfied by logging destinations. | ||
type flushSyncWriter interface { | ||
Flush() error | ||
@@ -247,6 +268,7 @@ type syncBuffer struct { | ||
names []string | ||
sev logsink.Severity | ||
nbytes uint64 // The number of bytes written to this file | ||
+ madeAt time.Time | ||
} | ||
|
||
func (sb *syncBuffer) Sync() error { | ||
@@ -254,9 +276,14 @@ func (sb *syncBuffer) Sync() error { | ||
} | ||
|
||
func (sb *syncBuffer) Write(p []byte) (n int, err error) { | ||
+ // Rotate the file if it is too large, but ensure we only do so, | ||
+ // if rotate doesn't create a conflicting filename. | ||
if sb.nbytes+uint64(len(p)) >= MaxSize { | ||
- if err := sb.rotateFile(time.Now()); err != nil { | ||
- return 0, err | ||
+ now := timeNow() | ||
+ if now.After(sb.madeAt.Add(1*time.Second)) || now.Second() != sb.madeAt.Second() { | ||
+ if err := sb.rotateFile(now); err != nil { | ||
+ return 0, err | ||
+ } | ||
} | ||
} | ||
n, err = sb.Writer.Write(p) | ||
@@ -274,7 +301,8 @@ const footer = "\nCONTINUED IN NEXT FILE\n" | ||
func (sb *syncBuffer) rotateFile(now time.Time) error { | ||
var err error | ||
pn := "<none>" | ||
- file, name, err := create(sb.sev.String(), now) | ||
+ file, name, err := create(sb.sev.String(), now, "") | ||
+ sb.madeAt = now | ||
|
||
if sb.file != nil { | ||
// The current log file becomes the previous log at the end of | ||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
Name: vitess | ||
Version: 17.0.7 | ||
Release: 3%{?dist} | ||
Release: 4%{?dist} | ||
Summary: Database clustering system for horizontal scaling of MySQL | ||
# Upstream license specification: MIT and Apache-2.0 | ||
License: MIT and ASL 2.0 | ||
|
@@ -27,6 +27,7 @@ Source0: %{name}-%{version}.tar.gz | |
# | ||
Source1: %{name}-%{version}-vendor.tar.gz | ||
Patch0: CVE-2024-45338.patch | ||
Patch1: CVE-2024-45339.patch | ||
BuildRequires: golang | ||
|
||
%description | ||
|
@@ -73,29 +74,24 @@ install -m 0755 -vd %{buildroot}%{_bindir} | |
install -m 0755 -vp ./bin/* %{buildroot}%{_bindir}/ | ||
|
||
%check | ||
go check -t go/cmd \ | ||
-d go/mysql \ | ||
-d go/mysql/endtoend \ | ||
-d go/sqltypes \ | ||
-d go/vt/hook \ | ||
-d go/vt/mysqlctl \ | ||
-d go/vt/srvtopo \ | ||
-t go/vt/topo \ | ||
-d go/vt/vtctld \ | ||
-d go/vt/vtgate/evalengine \ | ||
-d go/vt/vtqueryserver \ | ||
-d go/vt/vttablet/endtoend \ | ||
-t go/vt/vttablet/tabletmanager \ | ||
-t go/vt/vttablet/tabletserver \ | ||
-t go/vt/vttablet/worker \ | ||
-d go/vt/withddl \ | ||
-t go/vt/worker \ | ||
-d go/vt/workflow/reshardingworkflowgen \ | ||
-d go/vt/wrangler \ | ||
-d go/vt/wrangler/testlib \ | ||
-d go/vt/zkctl \ | ||
-d go/json2 \ | ||
-t go/test/endtoend | ||
go test -v ./go/cmd/... \ | ||
./go/mysql/... \ | ||
./go/mysql/endtoend/... \ | ||
./go/sqltypes/... \ | ||
./go/vt/hook/... \ | ||
./go/vt/mysqlctl/... \ | ||
./go/vt/srvtopo/... \ | ||
./go/vt/topo/... \ | ||
./go/vt/vtctld/... \ | ||
./go/vt/vtgate/evalengine/... \ | ||
./go/vt/vttablet/endtoend/... \ | ||
./go/vt/vttablet/tabletmanager/... \ | ||
./go/vt/vttablet/tabletserver/... \ | ||
./go/vt/wrangler/... \ | ||
./go/vt/wrangler/testlib/... \ | ||
./go/vt/zkctl/... \ | ||
./go/json2/... \ | ||
./go/test/endtoend/... | ||
|
||
%files | ||
%license LICENSE | ||
|
@@ -104,6 +100,9 @@ go check -t go/cmd \ | |
%{_bindir}/* | ||
|
||
%changelog | ||
* Fri Jan 31 2025 Kavya Sree Kaitepalli <[email protected]> - 17.0.7-4 | ||
- Add patch for CVE-2024-45339 | ||
|
||
* Thu Jan 02 2025 Sumedh Sharma <[email protected]> - 17.0.7-3 | ||
- Add patch for CVE-2024-45338. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)