|
|
3fe7b7 |
diff -up firefox-68.0/config/makefiles/rust.mk.rust-network-check firefox-68.0/config/makefiles/rust.mk
|
|
|
3fe7b7 |
--- firefox-68.0/config/makefiles/rust.mk.rust-network-check 2019-06-06 10:29:18.984737603 +0200
|
|
|
3fe7b7 |
+++ firefox-68.0/config/makefiles/rust.mk 2019-06-06 11:39:51.581028835 +0200
|
|
|
3fe7b7 |
@@ -127,7 +127,7 @@ export RUST_BACKTRACE=full
|
|
|
3fe7b7 |
export MOZ_TOPOBJDIR=$(topobjdir)
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
target_rust_ltoable := force-cargo-library-build
|
|
|
3fe7b7 |
-target_rust_nonltoable := force-cargo-test-run force-cargo-library-check $(foreach b,build check,force-cargo-program-$(b))
|
|
|
3fe7b7 |
+target_rust_nonltoable := force-cargo-test-run $(foreach b,build check,force-cargo-program-$(b))
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST),-Clinker-plugin-lto)
|
|
|
3fe7b7 |
$(target_rust_nonltoable): RUSTFLAGS:=$(rustflags_override) $(RUSTFLAGS)
|
|
|
3fe7b7 |
@@ -238,19 +238,9 @@ force-cargo-library-build:
|
|
|
3fe7b7 |
$(call CARGO_BUILD) --lib $(cargo_target_flag) $(rust_features_flag) -- $(cargo_rustc_flags)
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
$(RUST_LIBRARY_FILE): force-cargo-library-build
|
|
|
3fe7b7 |
-# When we are building in --enable-release mode; we add an additional check to confirm
|
|
|
3fe7b7 |
-# that we are not importing any networking-related functions in rust code. This reduces
|
|
|
3fe7b7 |
-# the chance of proxy bypasses originating from rust code.
|
|
|
3fe7b7 |
-ifndef DEVELOPER_OPTIONS
|
|
|
3fe7b7 |
-ifndef MOZ_DEBUG_RUST
|
|
|
3fe7b7 |
-ifeq ($(OS_ARCH), Linux)
|
|
|
3fe7b7 |
- $(call py_action,check_binary,--target --networking $@)
|
|
|
3fe7b7 |
-endif
|
|
|
3fe7b7 |
-endif
|
|
|
3fe7b7 |
-endif
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
force-cargo-library-check:
|
|
|
3fe7b7 |
- $(call CARGO_CHECK) --lib $(cargo_target_flag) $(rust_features_flag)
|
|
|
3fe7b7 |
+ @true
|
|
|
3fe7b7 |
else
|
|
|
3fe7b7 |
force-cargo-library-check:
|
|
|
3fe7b7 |
@true
|
|
|
3fe7b7 |
diff -up firefox-68.0/python/mozbuild/mozbuild/action/check_binary.py.rust-network-check firefox-68.0/python/mozbuild/mozbuild/action/check_binary.py
|
|
|
3fe7b7 |
--- firefox-68.0/python/mozbuild/mozbuild/action/check_binary.py.rust-network-check 2019-05-20 18:17:57.000000000 +0200
|
|
|
3fe7b7 |
+++ firefox-68.0/python/mozbuild/mozbuild/action/check_binary.py 2019-06-06 10:29:18.986737599 +0200
|
|
|
3fe7b7 |
@@ -250,43 +250,6 @@ def check_mozglue_order(target, binary):
|
|
|
3fe7b7 |
raise RuntimeError('Could not parse readelf output?')
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
-def check_networking(binary):
|
|
|
3fe7b7 |
- retcode = 0
|
|
|
3fe7b7 |
- networking_functions = set([
|
|
|
3fe7b7 |
- # socketpair is not concerning; it is restricted to AF_UNIX
|
|
|
3fe7b7 |
- "socket", "connect", "accept", "bind", "listen",
|
|
|
3fe7b7 |
- "getsockname", "getsockopt", "setsockopt",
|
|
|
3fe7b7 |
- "recv", "recvfrom",
|
|
|
3fe7b7 |
- "send", "sendto",
|
|
|
3fe7b7 |
- # We would be concerned by recvmsg and sendmsg; but we believe
|
|
|
3fe7b7 |
- # they are okay as documented in 1376621#c23
|
|
|
3fe7b7 |
- "gethostbyname", "gethostbyaddr", "gethostent", "sethostent", "endhostent",
|
|
|
3fe7b7 |
- "gethostent_r", "gethostbyname2", "gethostbyaddr_r", "gethostbyname_r",
|
|
|
3fe7b7 |
- "gethostbyname2_r",
|
|
|
3fe7b7 |
- "getaddrinfo", "getservent", "getservbyname", "getservbyport", "setservent",
|
|
|
3fe7b7 |
- "getprotoent", "getprotobyname", "getprotobynumber", "setprotoent",
|
|
|
3fe7b7 |
- "endprotoent"])
|
|
|
3fe7b7 |
- bad_occurences_names = set()
|
|
|
3fe7b7 |
-
|
|
|
3fe7b7 |
- try:
|
|
|
3fe7b7 |
- for sym in at_least_one(iter_symbols(binary)):
|
|
|
3fe7b7 |
- if sym['addr'] == 0 and sym['name'] in networking_functions:
|
|
|
3fe7b7 |
- bad_occurences_names.add(sym['name'])
|
|
|
3fe7b7 |
- except Empty:
|
|
|
3fe7b7 |
- raise RuntimeError('Could not parse llvm-objdump output?')
|
|
|
3fe7b7 |
-
|
|
|
3fe7b7 |
- basename = os.path.basename(binary)
|
|
|
3fe7b7 |
- if bad_occurences_names:
|
|
|
3fe7b7 |
- s = 'TEST-UNEXPECTED-FAIL | check_networking | {} | Identified {} ' + \
|
|
|
3fe7b7 |
- 'networking function(s) being imported in the rust static library ({})'
|
|
|
3fe7b7 |
- print(s.format(basename, len(bad_occurences_names),
|
|
|
3fe7b7 |
- ",".join(sorted(bad_occurences_names))),
|
|
|
3fe7b7 |
- file=sys.stderr)
|
|
|
3fe7b7 |
- retcode = 1
|
|
|
3fe7b7 |
- elif buildconfig.substs.get('MOZ_AUTOMATION'):
|
|
|
3fe7b7 |
- print('TEST-PASS | check_networking | {}'.format(basename))
|
|
|
3fe7b7 |
- return retcode
|
|
|
3fe7b7 |
-
|
|
|
3fe7b7 |
def checks(target, binary):
|
|
|
3fe7b7 |
# The clang-plugin is built as target but is really a host binary.
|
|
|
3fe7b7 |
# Cheat and pretend we were passed the right argument.
|
|
|
3fe7b7 |
@@ -330,8 +293,6 @@ def main(args):
|
|
|
3fe7b7 |
help='Perform checks for a host binary')
|
|
|
3fe7b7 |
parser.add_argument('--target', action='store_true',
|
|
|
3fe7b7 |
help='Perform checks for a target binary')
|
|
|
3fe7b7 |
- parser.add_argument('--networking', action='store_true',
|
|
|
3fe7b7 |
- help='Perform checks for networking functions')
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
parser.add_argument('binary', metavar='PATH',
|
|
|
3fe7b7 |
help='Location of the binary to check')
|
|
|
3fe7b7 |
@@ -343,14 +304,7 @@ def main(args):
|
|
|
3fe7b7 |
file=sys.stderr)
|
|
|
3fe7b7 |
return 1
|
|
|
3fe7b7 |
|
|
|
3fe7b7 |
- if options.networking and options.host:
|
|
|
3fe7b7 |
- print('--networking is only valid with --target',
|
|
|
3fe7b7 |
- file=sys.stderr)
|
|
|
3fe7b7 |
- return 1
|
|
|
3fe7b7 |
-
|
|
|
3fe7b7 |
- if options.networking:
|
|
|
3fe7b7 |
- return check_networking(options.binary)
|
|
|
3fe7b7 |
- elif options.host:
|
|
|
3fe7b7 |
+ if options.host:
|
|
|
3fe7b7 |
return checks(HOST, options.binary)
|
|
|
3fe7b7 |
elif options.target:
|
|
|
3fe7b7 |
return checks(TARGET, options.binary)
|