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