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