Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
android_frameworks_native
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
halogenOS
android_frameworks_native
Commits
c23f1b73
Commit
c23f1b73
authored
1 year ago
by
Keith Mok
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "File size seal for memory mapped region" into tm-dev
parents
f7f5abfb
f2c1d9d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/binder/MemoryHeapBase.cpp
+2
-2
2 additions, 2 deletions
libs/binder/MemoryHeapBase.cpp
libs/binder/tests/binderMemoryHeapBaseUnitTest.cpp
+9
-4
9 additions, 4 deletions
libs/binder/tests/binderMemoryHeapBaseUnitTest.cpp
with
11 additions
and
6 deletions
libs/binder/MemoryHeapBase.cpp
+
2
−
2
View file @
c23f1b73
...
...
@@ -73,8 +73,8 @@ MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name)
ALOGV
(
"MemoryHeapBase: Attempting to force MemFD"
);
fd
=
memfd_create_region
(
name
?
name
:
"MemoryHeapBase"
,
size
);
if
(
fd
<
0
||
(
mapfd
(
fd
,
true
,
size
)
!=
NO_ERROR
))
return
;
const
int
SEAL_FLAGS
=
((
mFlags
&
READ_ONLY
)
?
F_SEAL_FUTURE_WRITE
:
0
)
|
((
mFlags
&
MEMFD_ALLOW_SEALING
)
?
0
:
F_SEAL_SEAL
);
const
int
SEAL_FLAGS
=
((
mFlags
&
READ_ONLY
)
?
F_SEAL_FUTURE_WRITE
:
0
)
|
F_SEAL_GROW
|
F_SEAL_SHRINK
|
((
mFlags
&
MEMFD_ALLOW_SEALING
)
?
0
:
F_SEAL_SEAL
);
if
(
SEAL_FLAGS
&&
(
fcntl
(
fd
,
F_ADD_SEALS
,
SEAL_FLAGS
)
==
-
1
))
{
ALOGE
(
"MemoryHeapBase: MemFD %s sealing with flags %x failed with error %s"
,
name
,
SEAL_FLAGS
,
strerror
(
errno
));
...
...
This diff is collapsed.
Click to expand it.
libs/binder/tests/binderMemoryHeapBaseUnitTest.cpp
+
9
−
4
View file @
c23f1b73
...
...
@@ -35,7 +35,8 @@ TEST(MemoryHeapBase, MemfdSealed) {
"Test mapping"
);
int
fd
=
mHeap
->
getHeapID
();
EXPECT_NE
(
fd
,
-
1
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_SEAL
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_GROW
|
F_SEAL_SHRINK
|
F_SEAL_SEAL
);
EXPECT_EQ
(
ftruncate
(
fd
,
4096
),
-
1
);
}
TEST
(
MemoryHeapBase
,
MemfdUnsealed
)
{
...
...
@@ -45,7 +46,8 @@ TEST(MemoryHeapBase, MemfdUnsealed) {
"Test mapping"
);
int
fd
=
mHeap
->
getHeapID
();
EXPECT_NE
(
fd
,
-
1
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
0
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_GROW
|
F_SEAL_SHRINK
);
EXPECT_EQ
(
ftruncate
(
fd
,
4096
),
-
1
);
}
TEST
(
MemoryHeapBase
,
MemfdSealedProtected
)
{
...
...
@@ -55,7 +57,9 @@ TEST(MemoryHeapBase, MemfdSealedProtected) {
"Test mapping"
);
int
fd
=
mHeap
->
getHeapID
();
EXPECT_NE
(
fd
,
-
1
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_SEAL
|
F_SEAL_FUTURE_WRITE
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_GROW
|
F_SEAL_SHRINK
|
F_SEAL_SEAL
|
F_SEAL_FUTURE_WRITE
);
EXPECT_EQ
(
ftruncate
(
fd
,
4096
),
-
1
);
}
TEST
(
MemoryHeapBase
,
MemfdUnsealedProtected
)
{
...
...
@@ -66,7 +70,8 @@ TEST(MemoryHeapBase, MemfdUnsealedProtected) {
"Test mapping"
);
int
fd
=
mHeap
->
getHeapID
();
EXPECT_NE
(
fd
,
-
1
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_FUTURE_WRITE
);
EXPECT_EQ
(
fcntl
(
fd
,
F_GET_SEALS
),
F_SEAL_GROW
|
F_SEAL_SHRINK
|
F_SEAL_FUTURE_WRITE
);
EXPECT_EQ
(
ftruncate
(
fd
,
4096
),
-
1
);
}
#else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment