Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
b5356a59
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b5356a59
编写于
8月 12, 2014
作者:
J
jiangli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8044269: Analysis of archive files.
Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
上级
aded2ae7
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
69 addition
and
6 deletion
+69
-6
src/share/vm/classfile/classLoader.cpp
src/share/vm/classfile/classLoader.cpp
+10
-1
src/share/vm/classfile/classLoader.hpp
src/share/vm/classfile/classLoader.hpp
+1
-0
src/share/vm/memory/filemap.cpp
src/share/vm/memory/filemap.cpp
+37
-3
src/share/vm/memory/filemap.hpp
src/share/vm/memory/filemap.hpp
+7
-2
src/share/vm/memory/metaspaceShared.cpp
src/share/vm/memory/metaspaceShared.cpp
+5
-0
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
+5
-0
src/share/vm/runtime/globals.hpp
src/share/vm/runtime/globals.hpp
+4
-0
未找到文件。
src/share/vm/classfile/classLoader.cpp
浏览文件 @
b5356a59
...
...
@@ -84,6 +84,7 @@ typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *siz
typedef
jboolean
(
JNICALL
*
ReadEntry_t
)(
jzfile
*
zip
,
jzentry
*
entry
,
unsigned
char
*
buf
,
char
*
namebuf
);
typedef
jboolean
(
JNICALL
*
ReadMappedEntry_t
)(
jzfile
*
zip
,
jzentry
*
entry
,
unsigned
char
**
buf
,
char
*
namebuf
);
typedef
jzentry
*
(
JNICALL
*
GetNextEntry_t
)(
jzfile
*
zip
,
jint
n
);
typedef
jint
(
JNICALL
*
Crc32_t
)(
jint
crc
,
const
jbyte
*
buf
,
jint
len
);
static
ZipOpen_t
ZipOpen
=
NULL
;
static
ZipClose_t
ZipClose
=
NULL
;
...
...
@@ -92,6 +93,7 @@ static ReadEntry_t ReadEntry = NULL;
static
ReadMappedEntry_t
ReadMappedEntry
=
NULL
;
static
GetNextEntry_t
GetNextEntry
=
NULL
;
static
canonicalize_fn_t
CanonicalizeEntry
=
NULL
;
static
Crc32_t
Crc32
=
NULL
;
// Globals
...
...
@@ -632,9 +634,11 @@ void ClassLoader::load_zip_library() {
ReadEntry
=
CAST_TO_FN_PTR
(
ReadEntry_t
,
os
::
dll_lookup
(
handle
,
"ZIP_ReadEntry"
));
ReadMappedEntry
=
CAST_TO_FN_PTR
(
ReadMappedEntry_t
,
os
::
dll_lookup
(
handle
,
"ZIP_ReadMappedEntry"
));
GetNextEntry
=
CAST_TO_FN_PTR
(
GetNextEntry_t
,
os
::
dll_lookup
(
handle
,
"ZIP_GetNextEntry"
));
Crc32
=
CAST_TO_FN_PTR
(
Crc32_t
,
os
::
dll_lookup
(
handle
,
"ZIP_CRC32"
));
// ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
if
(
ZipOpen
==
NULL
||
FindEntry
==
NULL
||
ReadEntry
==
NULL
||
GetNextEntry
==
NULL
)
{
if
(
ZipOpen
==
NULL
||
FindEntry
==
NULL
||
ReadEntry
==
NULL
||
GetNextEntry
==
NULL
||
Crc32
==
NULL
)
{
vm_exit_during_initialization
(
"Corrupted ZIP library"
,
path
);
}
...
...
@@ -644,6 +648,11 @@ void ClassLoader::load_zip_library() {
// This lookup only works on 1.3. Do not check for non-null here
}
int
ClassLoader
::
crc32
(
int
crc
,
const
char
*
buf
,
int
len
)
{
assert
(
Crc32
!=
NULL
,
"ZIP_CRC32 is not found"
);
return
(
*
Crc32
)(
crc
,
(
const
jbyte
*
)
buf
,
len
);
}
// PackageInfo data exists in order to support the java.lang.Package
// class. A Package object provides information about a java package
// (version, vendor, etc.) which originates in the manifest of the jar
...
...
src/share/vm/classfile/classLoader.hpp
浏览文件 @
b5356a59
...
...
@@ -215,6 +215,7 @@ class ClassLoader: AllStatic {
// to avoid confusing the zip library
static
bool
get_canonical_path
(
char
*
orig
,
char
*
out
,
int
len
);
public:
static
int
crc32
(
int
crc
,
const
char
*
buf
,
int
len
);
// Used by the kernel jvm.
static
void
update_class_path_entry_list
(
char
*
path
,
bool
check_for_duplicates
);
...
...
src/share/vm/memory/filemap.cpp
浏览文件 @
b5356a59
...
...
@@ -177,7 +177,14 @@ bool FileMapInfo::init_from_file(int fd) {
fail_continue
(
"The shared archive file has the wrong version."
);
return
false
;
}
_file_offset
=
(
long
)
n
;
size_t
len
=
lseek
(
fd
,
0
,
SEEK_END
);
struct
FileMapInfo
::
FileMapHeader
::
space_info
*
si
=
&
_header
.
_space
[
MetaspaceShared
::
mc
];
if
(
si
->
_file_offset
>=
len
||
len
-
si
->
_file_offset
<
si
->
_used
)
{
fail_continue
(
"The shared archive file has been truncated."
);
return
false
;
}
_file_offset
=
n
;
return
true
;
}
...
...
@@ -268,6 +275,7 @@ void FileMapInfo::write_region(int region, char* base, size_t size,
si
->
_capacity
=
capacity
;
si
->
_read_only
=
read_only
;
si
->
_allow_exec
=
allow_exec
;
si
->
_crc
=
ClassLoader
::
crc32
(
0
,
base
,
(
jint
)
size
);
write_bytes_aligned
(
base
,
(
int
)
size
);
}
...
...
@@ -292,14 +300,15 @@ void FileMapInfo::write_bytes(const void* buffer, int nbytes) {
// Align file position to an allocation unit boundary.
void
FileMapInfo
::
align_file_position
()
{
long
new_file_offset
=
align_size_up
(
_file_offset
,
os
::
vm_allocation_granularity
());
size_t
new_file_offset
=
align_size_up
(
_file_offset
,
os
::
vm_allocation_granularity
());
if
(
new_file_offset
!=
_file_offset
)
{
_file_offset
=
new_file_offset
;
if
(
_file_open
)
{
// Seek one byte back from the target and write a byte to insure
// that the written file is the correct length.
_file_offset
-=
1
;
if
(
lseek
(
_fd
,
_file_offset
,
SEEK_SET
)
<
0
)
{
if
(
lseek
(
_fd
,
(
long
)
_file_offset
,
SEEK_SET
)
<
0
)
{
fail_stop
(
"Unable to seek."
,
NULL
);
}
char
zero
=
0
;
...
...
@@ -406,6 +415,19 @@ char* FileMapInfo::map_region(int i) {
return
base
;
}
bool
FileMapInfo
::
verify_region_checksum
(
int
i
)
{
if
(
!
VerifySharedSpaces
)
{
return
true
;
}
const
char
*
buf
=
_header
.
_space
[
i
].
_base
;
size_t
sz
=
_header
.
_space
[
i
].
_used
;
int
crc
=
ClassLoader
::
crc32
(
0
,
buf
,
(
jint
)
sz
);
if
(
crc
!=
_header
.
_space
[
i
].
_crc
)
{
fail_continue
(
"Checksum verification failed."
);
return
false
;
}
return
true
;
}
// Unmap a memory region in the address space.
...
...
@@ -457,8 +479,20 @@ bool FileMapInfo::initialize() {
return
true
;
}
int
FileMapInfo
::
compute_header_crc
()
{
char
*
header
=
(
char
*
)
&
_header
;
// start computing from the field after _crc
char
*
buf
=
(
char
*
)
&
_header
.
_crc
+
sizeof
(
int
);
size_t
sz
=
sizeof
(
FileMapInfo
::
FileMapHeader
)
-
(
buf
-
header
);
int
crc
=
ClassLoader
::
crc32
(
0
,
buf
,
(
jint
)
sz
);
return
crc
;
}
bool
FileMapInfo
::
validate
()
{
if
(
VerifySharedSpaces
&&
compute_header_crc
()
!=
_header
.
_crc
)
{
fail_continue
(
"Header checksum verification failed."
);
return
false
;
}
if
(
_header
.
_version
!=
current_version
())
{
fail_continue
(
"The shared archive file is the wrong version."
);
return
false
;
...
...
src/share/vm/memory/filemap.hpp
浏览文件 @
b5356a59
...
...
@@ -54,7 +54,7 @@ private:
bool
_file_open
;
int
_fd
;
long
_file_offset
;
size_t
_file_offset
;
// FileMapHeader describes the shared space data in the file to be
// mapped. This structure gets written to a file. It is not a class, so
...
...
@@ -62,12 +62,14 @@ private:
struct
FileMapHeader
{
int
_magic
;
// identify file type.
int
_crc
;
// header crc checksum.
int
_version
;
// (from enum, above.)
size_t
_alignment
;
// how shared archive should be aligned
int
_obj_alignment
;
// value of ObjectAlignmentInBytes
struct
space_info
{
int
_file_offset
;
// sizeof(this) rounded to vm page size
int
_crc
;
// crc checksum of the current space
size_t
_file_offset
;
// sizeof(this) rounded to vm page size
char
*
_base
;
// copy-on-write base address
size_t
_capacity
;
// for validity checking
size_t
_used
;
// for setting space top on read
...
...
@@ -104,6 +106,8 @@ public:
}
static
int
current_version
()
{
return
_current_version
;
}
int
compute_header_crc
();
void
set_header_crc
(
int
crc
)
{
_header
.
_crc
=
crc
;
}
void
populate_header
(
size_t
alignment
);
bool
validate
();
void
invalidate
();
...
...
@@ -136,6 +140,7 @@ public:
void
write_bytes_aligned
(
const
void
*
buffer
,
int
count
);
char
*
map_region
(
int
i
);
void
unmap_region
(
int
i
);
bool
verify_region_checksum
(
int
i
);
void
close
();
bool
is_open
()
{
return
_file_open
;
}
ReservedSpace
reserve_shared_memory
();
...
...
src/share/vm/memory/metaspaceShared.cpp
浏览文件 @
b5356a59
...
...
@@ -585,6 +585,7 @@ void VM_PopulateDumpSharedSpace::doit() {
// Pass 2 - write data.
mapinfo
->
open_for_write
();
mapinfo
->
set_header_crc
(
mapinfo
->
compute_header_crc
());
mapinfo
->
write_header
();
mapinfo
->
write_space
(
MetaspaceShared
::
ro
,
_loader_data
->
ro_metaspace
(),
true
);
mapinfo
->
write_space
(
MetaspaceShared
::
rw
,
_loader_data
->
rw_metaspace
(),
false
);
...
...
@@ -863,9 +864,13 @@ bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) {
// Map each shared region
if
((
_ro_base
=
mapinfo
->
map_region
(
ro
))
!=
NULL
&&
mapinfo
->
verify_region_checksum
(
ro
)
&&
(
_rw_base
=
mapinfo
->
map_region
(
rw
))
!=
NULL
&&
mapinfo
->
verify_region_checksum
(
rw
)
&&
(
_md_base
=
mapinfo
->
map_region
(
md
))
!=
NULL
&&
mapinfo
->
verify_region_checksum
(
md
)
&&
(
_mc_base
=
mapinfo
->
map_region
(
mc
))
!=
NULL
&&
mapinfo
->
verify_region_checksum
(
mc
)
&&
(
image_alignment
==
(
size_t
)
max_alignment
()))
{
// Success (no need to do anything)
return
true
;
...
...
src/share/vm/runtime/arguments.cpp
浏览文件 @
b5356a59
...
...
@@ -3581,6 +3581,11 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
return
JNI_ENOMEM
;
}
// Set up VerifySharedSpaces
if
(
FLAG_IS_DEFAULT
(
VerifySharedSpaces
)
&&
SharedArchiveFile
!=
NULL
)
{
VerifySharedSpaces
=
true
;
}
// Delay warning until here so that we've had a chance to process
// the -XX:-PrintWarnings flag
if
(
needs_hotspotrc_warning
)
{
...
...
src/share/vm/runtime/globals.hpp
浏览文件 @
b5356a59
...
...
@@ -3745,6 +3745,10 @@ class CommandLineFlags {
product(bool, UseSharedSpaces, true, \
"Use shared spaces for metadata") \
\
product(bool, VerifySharedSpaces, false, \
"Verify shared spaces (false for default archive, true for " \
"archive specified by -XX:SharedArchiveFile)") \
\
product(bool, RequireSharedSpaces, false, \
"Require shared spaces for metadata") \
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录