-
Notifications
You must be signed in to change notification settings - Fork 71
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
Return the actual number of bytes written to through command buffer #287
Conversation
d1378dc
to
d9008ec
Compare
The `Write` function returned the number of bytes written to the internal command response buffer in the simulator. Depending on the type of command executed against the TPM, this would usually result in a different number of bytes being written than the original input. The fix is useful if one wants to wrap the io.ReadWriterCloser functions with implementations that perform strict checks. An example is using an io.MultiWriter to capture the bytes sent to the TPM for debugging purposes, which will fail if the number of bytes written does not equal the original length of the input bytes.
d9008ec
to
2d2eb44
Compare
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.
Nice catch, I'm surprised it took so long for us to catch this.
simulator/simulator.go
Outdated
if err != nil { | ||
return 0, err | ||
} | ||
if n != len(resp) { | ||
return 0, fmt.Errorf("expected %d bytes to be written to command response buffer, but actual number is %d", len(resp), n) | ||
} |
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.
We don't need this error checking here, bytes.Buffer will always return a nil error and a length of the input buffer (see https://pkg.go.dev/bytes#Buffer.Write).
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.
Ah, nice 😄 Fixed in 63181f2.
/gcbrun |
Use region in spec to create attestation service rest client google#281 Parse EFI App state from the TCG event log google#277 Increase default systemd wait timeout to 900s google#276 Use same env var formatting logic on the launcher as server google#253 Fix image pulling in launcher google#282 Bump version and fix a kernel cmd issue google#291 Return the actual number of bytes written to through command buffer google#287 Fix lint issues after using golangci-lint-1.52.2 google#296 Add image tests and test automation google#275 Update go-sev-guest to v0.4.2 google#278 Update to go-sev-guest v0.4.5 google#279 Add proper debug license and logging to launcher google#280 Upgrade to go-sev-guest v0.5.0 google#283 Import go-sev-guest v0.5.2 google#284 Add override test for workload env vars and cmd google#286 Add test workload code, check OIDC claims, and validate launch policy checks google#288 Bump golang.org/x/net in /launcher google#290 Add RELEASING instructions google#187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client google#281 Parse EFI App state from the TCG event log google#277 Bug Fixes: Increase default systemd wait timeout to 900s google#276 Use same env var formatting logic on the launcher as server google#253 Fix image pulling in launcher google#282 Bump version and fix a kernel cmd issue google#291 Return the actual number of bytes written to through command buffer google#287 Fix lint issues after using golangci-lint-1.52.2 google#296 Other Changes: Add image tests and test automation google#275 Update go-sev-guest to v0.4.2 google#278 Update to go-sev-guest v0.4.5 google#279 Add proper debug license and logging to launcher google#280 Upgrade to go-sev-guest v0.5.0 google#283 Import go-sev-guest v0.5.2 google#284 Add override test for workload env vars and cmd google#286 Add test workload code, check OIDC claims, and validate launch policy checks google#288 Bump golang.org/x/net in /launcher google#290 Add RELEASING instructions google#187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client #281 Parse EFI App state from the TCG event log #277 Bug Fixes: Increase default systemd wait timeout to 900s #276 Use same env var formatting logic on the launcher as server #253 Fix image pulling in launcher #282 Bump version and fix a kernel cmd issue #291 Return the actual number of bytes written to through command buffer #287 Fix lint issues after using golangci-lint-1.52.2 #296 Other Changes: Add image tests and test automation #275 Update go-sev-guest to v0.4.2 #278 Update to go-sev-guest v0.4.5 #279 Add proper debug license and logging to launcher #280 Upgrade to go-sev-guest v0.5.0 #283 Import go-sev-guest v0.5.2 #284 Add override test for workload env vars and cmd #286 Add test workload code, check OIDC claims, and validate launch policy checks #288 Bump golang.org/x/net in /launcher #290 Add RELEASING instructions #187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client google#281 Parse EFI App state from the TCG event log google#277 Bug Fixes: Increase default systemd wait timeout to 900s google#276 Use same env var formatting logic on the launcher as server google#253 Fix image pulling in launcher google#282 Bump version and fix a kernel cmd issue google#291 Return the actual number of bytes written to through command buffer google#287 Fix lint issues after using golangci-lint-1.52.2 google#296 Other Changes: Add image tests and test automation google#275 Update go-sev-guest to v0.4.2 google#278 Update to go-sev-guest v0.4.5 google#279 Add proper debug license and logging to launcher google#280 Upgrade to go-sev-guest v0.5.0 google#283 Import go-sev-guest v0.5.2 google#284 Add override test for workload env vars and cmd google#286 Add test workload code, check OIDC claims, and validate launch policy checks google#288 Bump golang.org/x/net in /launcher google#290 Add RELEASING instructions google#187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client #281 Parse EFI App state from the TCG event log #277 Bug Fixes: Increase default systemd wait timeout to 900s #276 Use same env var formatting logic on the launcher as server #253 Fix image pulling in launcher #282 Bump version and fix a kernel cmd issue #291 Return the actual number of bytes written to through command buffer #287 Fix lint issues after using golangci-lint-1.52.2 #296 Other Changes: Add image tests and test automation #275 Update go-sev-guest to v0.4.2 #278 Update to go-sev-guest v0.4.5 #279 Add proper debug license and logging to launcher #280 Upgrade to go-sev-guest v0.5.0 #283 Import go-sev-guest v0.5.2 #284 Add override test for workload env vars and cmd #286 Add test workload code, check OIDC claims, and validate launch policy checks #288 Bump golang.org/x/net in /launcher #290 Add RELEASING instructions #187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client #281 Parse EFI App state from the TCG event log #277 Bug Fixes: Increase default systemd wait timeout to 900s #276 Use same env var formatting logic on the launcher as server #253 Fix image pulling in launcher #282 Bump version and fix a kernel cmd issue #291 Return the actual number of bytes written to through command buffer #287 Fix lint issues after using golangci-lint-1.52.2 #296 Other Changes: Add image tests and test automation #275 Update go-sev-guest to v0.4.2 #278 Update to go-sev-guest v0.4.5 #279 Add proper debug license and logging to launcher #280 Upgrade to go-sev-guest v0.5.0 #283 Import go-sev-guest v0.5.2 #284 Add override test for workload env vars and cmd #286 Add test workload code, check OIDC claims, and validate launch policy checks #288 Bump golang.org/x/net in /launcher #290 Add RELEASING instructions #187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
Breaking Changes: New Features: Use region in spec to create attestation service rest client google#281 Parse EFI App state from the TCG event log google#277 Bug Fixes: Increase default systemd wait timeout to 900s google#276 Use same env var formatting logic on the launcher as server google#253 Fix image pulling in launcher google#282 Bump version and fix a kernel cmd issue google#291 Return the actual number of bytes written to through command buffer google#287 Fix lint issues after using golangci-lint-1.52.2 google#296 Other Changes: Add image tests and test automation google#275 Update go-sev-guest to v0.4.2 google#278 Update to go-sev-guest v0.4.5 google#279 Add proper debug license and logging to launcher google#280 Upgrade to go-sev-guest v0.5.0 google#283 Import go-sev-guest v0.5.2 google#284 Add override test for workload env vars and cmd google#286 Add test workload code, check OIDC claims, and validate launch policy checks google#288 Bump golang.org/x/net in /launcher google#290 Add RELEASING instructions google#187 https://github.com/google/go-tpm-tools/compare/53cab1a...5dd1056?expand=1
The
Write
function returned the number of bytes written to the internal command response buffer. Depending on the type of command executed against the TPM, this would usually result in a different number of bytes being written than the original input.The fix is useful if one wants to wrap the
io.ReadWriterCloser
functions with implementations that perform strict checks. An example is using anio.MultiWriter
to capture the bytes sent to the TPM for debugging purposes, which will fail if the number of bytes written does not equal the original length of the input bytes.