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