-
Notifications
You must be signed in to change notification settings - Fork 603
i#7588 drsyscall: fix a boundary condition bug in drsyscall_iterate_records. #7736
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
Open
ivankyluk
wants to merge
8
commits into
master
Choose a base branch
from
i7588-drsyscall-reader-terminate-prematurely
base: master
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.
+233
−4
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
416c1dd
Change the trailing space to ( ).
ivankyluk 29a70f7
Fix formatting issue in drsyscall_record_lib.c.
ivankyluk 97551de
Change aflags_read and aflags_w2r from uint to ptr_uint_t.
ivankyluk ba265a4
Merge branch 'master' into i7588-drsyscall-reader-terminate-prematurely
ivankyluk 9a78366
Replace address constants with 0x[0-9a-f]+.
ivankyluk ab5a2b7
Change the CI test to verify we write and read the same syscall records.
ivankyluk 3ce17b9
Cast address to uintptr_t to address pointer-to-int-cast error.
ivankyluk a0a27fd
Incorporate review comments.
ivankyluk 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
29 changes: 29 additions & 0 deletions
29
clients/drcachesim/tests/offline-drsyscall-record-test.templatex
This file contains hidden or 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,29 @@ | ||
| #define FILE_NO 0x2 | ||
| #define SIZE 0x1f4c | ||
ivankyluk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #if defined(X86) && defined(X64) | ||
| # define ADDRESS 0x402000 | ||
ivankyluk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # define CONTENT_ADDRESS 0x0000000000402000 | ||
| # define SYSCALL_WRITE 1 | ||
| # define SYSCALL_EXIT_GROUP 231 | ||
| #elif defined(AARCH64) | ||
| # define ADDRESS 0x411000 | ||
| # define CONTENT_ADDRESS 0x0000000000411000 | ||
| # define SYSCALL_WRITE 64 | ||
| # define SYSCALL_EXIT_GROUP 94 | ||
| #else | ||
| # error Unsupported architecture | ||
| #endif | ||
| .* | ||
| syscall: SYSCALL_WRITE, timestamp: [0-9]+ | ||
| pre-syscall ordinal 0, value FILE_NO | ||
| pre-syscall ordinal 1, value ADDRESS | ||
| pre-syscall ordinal 2, value SIZE | ||
| memory content address CONTENT_ADDRESS, size SIZE | ||
| (\n|.)*30303030 30303030 3030300a( ) | ||
| post-syscall ordinal 0, value FILE_NO | ||
| post-syscall ordinal 1, value ADDRESS | ||
| post-syscall ordinal 2, value SIZE | ||
| return value SIZE | ||
| syscall end: SYSCALL_WRITE, timestamp: [0-9]+ | ||
| syscall: SYSCALL_EXIT_GROUP, timestamp: [0-9]+ | ||
| pre-syscall ordinal 0, value 0x0 | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,61 @@ | ||
| /* ********************************************************** | ||
| * Copyright (c) 2025 Google, Inc. All rights reserved. | ||
| * **********************************************************/ | ||
|
|
||
| /* | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * * Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * * Neither the name of Google, Inc. nor the names of its contributors may be | ||
| * used to endorse or promote products derived from this software without | ||
| * specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
| * DAMAGE. | ||
| */ | ||
|
|
||
| /* | ||
| * This test is designed to test the boundary condition when a syscall record ends exactly | ||
| * at the end of the buffer for drsyscall_iterate_records. The current buffer size for | ||
| * drsyscall_iterate_records is 8192. A write syscall has ten sycall recrods: one | ||
| * DRSYS_SYSCALL_NUMBER_TIMESTAMP record, three DRSYS_PRECALL_PARAM records, one | ||
| * DRSYS_MEMORY_CONTENT record, three DRSYS_POSTCALL_PARAM records, one DRSYS_RETURN_VALUE | ||
| * record, and one DRSYS_RECORD_END_TIMESTAMP record. Each record has 18 bytes. To align | ||
| * the end of the DRSYS_RECORD_END_TIMESTAMP at the end of the drsyscall_iterate_records | ||
| * buffer, we call write with size 8192 - 10 * 18 = 8012 bytes. | ||
| */ | ||
| /* This is a statically-linked app. */ | ||
| .global _start | ||
|
|
||
| .align 6 | ||
| _start: | ||
| mov w0, #2 // stderr | ||
| adr x1, block | ||
| mov w2, #8012 // sizeof(block) | ||
| mov w8, #64 // SYS_write | ||
| svc #0 | ||
| mov w0, #0 // status | ||
| mov w8, #94 // SYS_exit_group | ||
| svc #0 | ||
|
|
||
| .data | ||
| .align 6 | ||
| block: | ||
| .fill 8011, 1, 0x30 // Create 8011 '0' characters | ||
| .string "\n" |
This file contains hidden or 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,64 @@ | ||
| /* ********************************************************** | ||
| * Copyright (c) 2025 Google, Inc. All rights reserved. | ||
| * **********************************************************/ | ||
|
|
||
| /* | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * * Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * * Neither the name of Google, Inc. nor the names of its contributors may be | ||
| * used to endorse or promote products derived from this software without | ||
| * specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
| * DAMAGE. | ||
| */ | ||
|
|
||
| /* | ||
| * This test is designed to test the boundary condition when a syscall record ends exactly | ||
| * at the end of the buffer for drsyscall_iterate_records. The current buffer size for | ||
| * drsyscall_iterate_records is 8192. A write syscall has ten sycall recrods: one | ||
| * DRSYS_SYSCALL_NUMBER_TIMESTAMP record, three DRSYS_PRECALL_PARAM records, one | ||
| * DRSYS_MEMORY_CONTENT record, three DRSYS_POSTCALL_PARAM records, one DRSYS_RETURN_VALUE | ||
| * record, and one DRSYS_RECORD_END_TIMESTAMP record. Each record has 18 bytes. To align | ||
| * the end of the DRSYS_RECORD_END_TIMESTAMP at the end of the drsyscall_iterate_records | ||
| * buffer, we call write with size 8192 - 10 * 18 = 8012 bytes. | ||
ivankyluk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| /* This is a statically-linked app. */ | ||
| .text | ||
| .globl _start | ||
| .type _start, @function | ||
|
|
||
| .align 8 | ||
| _start: | ||
| and rsp, -16 // align stack pointer to cache line | ||
| mov rdi, 2 // stderr | ||
| lea rsi, block | ||
| mov rdx, 8012 // sizeof(block) | ||
| mov eax, 1 // SYS_write | ||
| syscall | ||
| mov rdi, 0 // exit code | ||
| mov eax, 231 // SYS_exit_group | ||
| syscall | ||
|
|
||
| .data | ||
| .align 8 | ||
| block: | ||
| .fill 8011, 1, 0x30 // Create 8011 '0' characters | ||
| .string "\n" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.