Commit graph

111,873 commits

Message SHA1
clatd: x86-32 allow socketcall()
32-bit x86 has a crazy networking calling convention and instead of using
individual system calls has a single multiplexed socketcall()

bionic hasn't finished transitioning to the individual calls yet
which were added to Linux kernels around the 4.10-4.14-ish timeframe.

This does open a bit of security hole, since it effectively allows
all 20-ish networking system calls, but oh well, better than constantly
allowing & logging.

I don't think we'll ever want to enable KILL mode on x86-32 any way.

Test: TreeHugger
Flag: EXEMPT mainline & disabled code
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7228132cfbf716592607d010f64d5adeeb4419aa

Maciej Żenczykowski   commited 2025-08-05 12:14:42 -07:00
2d26f46559
bpf: put canonicalized section name in bpf_prog_def
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8bc5c888f982dc872ac68840ae6c136a798384d9

Maciej Żenczykowski   commited 2025-08-05 12:14:24 -07:00
adb0f9e2a4
Merge changes I17432e14,Iaeb8db2c,Id381a721 into main
* changes:
  NetBpfLoad: remove spurious explicit pin location from pinProg()
  bpf: switch progs from using 'pin_prefix' to 'pin_location'
  bpf/progs: automate function name determination from prog section name

Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-05 09:41:19 -07:00
911747b01f
Merge "OWNERS: satk -> larsberg" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-05 00:52:02 -07:00
56da309bcb
Merge "OWNERS: satk -> larsberg" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-05 00:50:55 -07:00
bdf8ee6c87
NetBpfLoad: remove spurious explicit pin location from pinProg()
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I17432e1495e776afd33df63037c092dc544e36e2

Maciej Żenczykowski   commited 2025-08-04 18:06:05 -07:00
283689d321
bpf: switch progs from using 'pin_prefix' to 'pin_location'
Note: I discovered that C considers:
  char s[4] = "abcd";
a valid initialization without a terminating NULL, resulting
in an invalid string.

(Specifically pinned programs had a '\1' as their last char
due to little endian encoding of the next field in the array
of prog def structs)

The simplest workaround appears to be to explicitly add a "\0"

That results in a string/array that ends with 2 NULLs,
and the compiler will at most *strip* the final one.

ie.
  char s[4] = "abcd\0";
fails to compile.

Obviously:
  char s[100] = "abcd\0";
also does the right thing, since it 0-pads with or without the extra null.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iaeb8db2cd4750f8521a971382b9f9f9f216195b2

Maciej Żenczykowski   commited 2025-08-04 18:02:51 -07:00
0be5b17e61
bpf: remove spurious/unused {offload,test}@mainline.c
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6d138416dcbff643ef3d31e06f8573867b849027

Maciej Żenczykowski   commited 2025-08-04 18:00:47 -07:00
c67da55167
bpf/progs: automate function name determination from prog section name
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id381a721bfeabdca3b513d71b805546b09617273

Maciej Żenczykowski   commited 2025-08-04 18:00:47 -07:00
5b7b9f10dc
bpf_{,net_}helpers: change return from 'int' to 'long'
This is to match upstream kernel include/uapi/linux/bpf.h

Since bpf is 64-bit, so long is the appropriate width type,
and not int which is only 32-bit

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2685ec1e9e85aab09615d40c6c518b0251308835

Maciej Żenczykowski   commited 2025-08-04 18:00:47 -07:00
2a23092b41
bpf_helpers: make *all* eBPF programs return long not int
BPF is a 64-bit architecture, so this makes more sense:
int is 32-bits, while long is 64-bits.

In practice this doesn't do much, but it does make sure
the top 32-bits of the 64-bit R0 register are well defined.

I think this might matter when we try to introduce function calls,
as per Linux Kernel eBPF uapi we have (for example):

  long (*callback_fn)(struct bpf_map *map, const void *key, void *value, void *ctx);
  long bpf_for_each_map_elem(struct bpf_map *map, void *callback_fn, void *callback_ctx, u64 flags);

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0abad90043eff8f8d99c2c29988dd5ce2fef9927

Maciej Żenczykowski   commited 2025-08-04 18:00:47 -07:00
b68add6b56
Merge changes I7542726b,I2d75fb51 into main
* changes:
  NetBpfLoad: remove parsing of "foo/" prefixes
  bpf: rename 'progs' section to '.android_progs'

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 17:19:01 -07:00
e0ba74dc2f
Merge "NetBpfLoad: remove spurious BPF_FS_PATH" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 16:39:05 -07:00
ac378e4e5e
Merge "NetBpfLoad: loadAllObjects - introduce libbpf bool" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 16:07:47 -07:00
abe6bbd2a2
Merge changes Ie996de3f,Ibda074cc,I7c89482e,I718e6eaa into main
* changes:
  NetBpfLoad: make loadObject() return bool
  NetBpfLoad: remove comments in loadAllObjects()
  NetBpfLoad: make loadAllObjects() return a bool
  NetBpfLoad: make loadObject take a fully specified .o path

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 16:06:11 -07:00
e4a43af2e2
Merge "bpf_prog_def: populate program type and attach_type automatically" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-04 15:12:37 -07:00
f81d507f6a
NetBpfLoad: remove parsing of "foo/" prefixes
in favour of just using the info from the prog definition
which was calculated at compilation time.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7542726b4c671177b30f79e90361b2dffdb38ac2

Maciej Żenczykowski   commited 2025-08-04 15:09:29 -07:00
371079226d
NetBpfLoad: remove spurious BPF_FS_PATH
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia2b748bd7b4712505af0e6a33822517b5cceb06f

Maciej Żenczykowski   commited 2025-08-04 15:07:05 -07:00
94f38014ff
bpf: rename 'progs' section to '.android_progs'
(this matches what we did for maps)

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2d75fb519f00471a6f1e6b0ffded9f327ecae7b4

Maciej Żenczykowski   commited 2025-08-04 15:07:05 -07:00
eb55711799
Merge "bpf: noop: make DEFINE_BPF_PROG* macros take (foo, "bar") instead of current ("foo/bar")" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 15:02:54 -07:00
c25b0191ad
Merge "NetBpfLoad: make 2 slashes abort" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 14:59:44 -07:00
0049e589de
Merge "bpf: noop: replace second / with _" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-04 14:53:11 -07:00
b1009e65cf
NetBpfLoad: loadAllObjects - introduce libbpf bool
(for ease of testing non-libbpf code path)

Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I98927b328753914359136ae3f4a723f42256d0a0

Maciej Żenczykowski   commited 2025-08-04 14:08:56 -07:00
9c0cd85f66
NetBpfLoad: make loadObject() return bool
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie996de3fba55f8ddfdc46d20161a87ad9194bf73

Maciej Żenczykowski   commited 2025-08-04 14:08:56 -07:00
0e53637637
NetBpfLoad: remove comments in loadAllObjects()
This is already documented at:
  //packages/modules/Connectivity/bpf/progs/include/bpf_helpers.h
which is the more logical location, since we're trying
to merge all the .o's into 1 per kernel version.

Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibda074ccbbf6efdf36dffd481d953ef38b421637

Maciej Żenczykowski   commited 2025-08-04 14:08:46 -07:00
575c67e61e
NetBpfLoad: make loadAllObjects() return a bool
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7c89482e9a567f5f6587508b77f398d6e9873d27

Maciej Żenczykowski   commited 2025-08-04 14:08:30 -07:00
e4a5161d63
NetBpfLoad: make loadObject take a fully specified .o path
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I718e6eaa2527d246edcc3265420bbfaf72191df1

Maciej Żenczykowski   commited 2025-08-04 14:08:30 -07:00
c4f8517a7f
bpf_prog_def: populate program type and attach_type automatically
Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I27461c7930b744202a9c23f8aba6bd47c00a8d06

Maciej Żenczykowski   commited 2025-08-04 13:02:06 -07:00
498c983f35
bpf: noop: make DEFINE_BPF_PROG* macros take (foo, "bar") instead of current ("foo/bar")
This gives us access to the program type during compile time.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iba6cb294b1c4ea054f7fcd208fcc2355149e00f9

Maciej Żenczykowski   commited 2025-08-04 13:02:06 -07:00
948e9beac9
NetBpfLoad: make 2 slashes abort
This cannot happen (it's a .c misconfig if it does)

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5d82c7bb8c0214f5ffcc0ce391daddb9fe6a3295

Maciej Żenczykowski   commited 2025-08-04 13:02:06 -07:00
806087d4a1
bpf: noop: replace second / with _
This is a noop, because this operation is already done by NetBpfLoad itself:

  NetBpfLoad.cpp-434: // convert all slashes to underscores
  NetBpfLoad.cpp:435: std::replace(name.begin(), name.end(), '/', '_');

The first / is meaningful because it is used for section lookup
on strings with / terminators (and must match libbpf)

Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie3cacebfcbe317d23a884aa3ab46ac02e8b70a8b

Maciej Żenczykowski   commited 2025-08-04 13:02:06 -07:00
3263f9e8e9
Merge "simplify netjniutils" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-04 11:52:15 -07:00
b8a76f540c
OWNERS: satk -> larsberg
(to match reporting chain changes)

Test: TreeHugger
Flag: EXEMPT OWNERS file change
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifa379646dc3dc1634401478f8b4d57c7605e7435

Maciej Żenczykowski   commited 2025-08-04 11:26:02 -07:00
24b1907e3d
OWNERS: satk -> larsberg
(to match reporting chain changes)

Test: TreeHugger
Flag: EXEMPT OWNERS file change
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0722e6083e9ed148198e779fca218ec9cab03013

Maciej Żenczykowski   commited 2025-08-04 11:26:01 -07:00
569534cb37
Merge "Conditionally set notifyForDescendants for settings observer" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-08-04 01:05:46 -07:00
1ce55f3028
Merge "Add test for ingress to VPN address filtering" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-03 19:36:25 -07:00
a26cea6c1e
Merge "make Struct expose a new parse method that takes a raw byte array" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-01 19:59:09 -07:00
eb7d854d5f
Merge "Lower tethering IPv6 MTU to 1400 (to match newly clamped RA)" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-01 18:10:56 -07:00
65f78293ed
Merge changes If62b1de1,I159e4e7a,I8a86efdc,I8c055224,Icc938136 into main
* changes:
  NetBpfLoad: introduce ElfObject struct (class)
  NetBpfLoad: move getSymNameByIdx() & getSymOffsetByName() up
  NetBpfLoad: make writeFile() return bool
  NetBpfLoad: simplify createDir()
  NetBpfLoad: make doLoad() and thus main() return diff error codes

Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-01 18:10:23 -07:00
fe6ea6bf44
Lower tethering IPv6 MTU to 1400 (to match newly clamped RA)
Bug: 432676104
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3674036bf28454bc57dcfeead9ff5f2917046939

Maciej Żenczykowski   commited 2025-08-01 16:34:16 -07:00
18fe2434db
simplify netjniutils
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic1c3207ef3a800f1e5d2da846b1f010f64a0e18f

Maciej Żenczykowski   commited 2025-08-01 16:08:12 -07:00
f14dc8c26f
NetBpfLoad: introduce ElfObject struct (class)
(prep work for improving loader performance)

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If62b1de1020b89a28e06cad45153281e2ffcd6e0

Maciej Żenczykowski   commited 2025-08-01 14:53:31 -07:00
6e910b728d
NetBpfLoad: move getSymNameByIdx() & getSymOffsetByName() up
so that elf object related functions are next to each other

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I159e4e7ad96e3764206546f9f8c69ff156bcf790

Maciej Żenczykowski   commited 2025-08-01 14:53:27 -07:00
ce6cb1dacf
NetBpfLoad: make writeFile() return bool
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8a86efdca9140d6f50ebd7ed507897fda20e952c

Maciej Żenczykowski   commited 2025-08-01 14:53:22 -07:00
f1ac608fb0
NetBpfLoad: simplify createDir()
We go to a lot of trouble to return error codes, but
we never actually care about anything besides pass/fail.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c0552246f1050813cca372a280b2302c701d617

Maciej Żenczykowski   commited 2025-08-01 14:53:18 -07:00
164488de05
NetBpfLoad: make doLoad() and thus main() return diff error codes
Sometimes *all* we see is the return code of the binary printed
out by init when we terminate with failure.  Unique codes will
make debugging easier.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Icc93813674af2855b2d9f378a1accac48b403aa3

Maciej Żenczykowski   commited 2025-08-01 14:53:06 -07:00
49a6fbbe60
Merge "Clamp the advertised IPv6 MTU to 1280-1400" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-01 14:05:36 -07:00
53eef4fe97
Clamp the advertised IPv6 MTU to 1280-1400
RaParams is populated with the upstream IPv4 MTU, rather than the IPv6
or route MTU. This change clamps that value between 1280 and 1400. 1280
as it is the minimum IPv6 MTU and 1400 to keep QUIC working. A follow up
change could improve on this by either adding the IPv6 MTU to
LinkProperties, or (possibly better) binding and connecting a UDP socket
to determine the MTU. Note that at that point the MTU in the Tether6Key
should also be fixed.

Test: TH
Flag: EXEMPT low risk
Bug: 432676104
Change-Id: I1d900039caf84c58cd04fdb52bdeaf2d1b846268

Patrick Rohr   commited 2025-08-01 12:48:46 -07:00
bd3d103436
Delete unused cc_library_shared
Test: TH
Flag: EXEMPT mainline
Change-Id: I1409e8edbe1d6b2d55341daf394fc5c7386ed3d6

Patrick Rohr   commited 2025-08-01 11:32:53 -07:00
53e9e75a1a
Merge "Revert "Introduce BLE advertiser wrapper for unit tests."" into main
Chen Wang   authored and   Android (Google) Code Review   commited 2025-08-01 10:54:55 -07:00
672392609b