Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: why bpf_helpers.h declares _license="GPL"? #1804

Closed
oriolarcas opened this issue Jun 8, 2018 · 1 comment
Closed

Question: why bpf_helpers.h declares _license="GPL"? #1804

oriolarcas opened this issue Jun 8, 2018 · 1 comment

Comments

@oriolarcas
Copy link
Contributor

Disclaimer: totally in favor of GPL, just curious, but I didn't find any documentation or issues about this.

I noticed that bpf_helpers.h declares char _license[4] SEC("license") = "GPL". I stumbled upon this because it conflicted with my own identical declaration of _license.

My question is: why GPL?

One possible answer would be "because eBPF helpers need it". Well, some need a GPL-compatible license, for instance bpf_probe_read(). But some not, for instance bpf_get_prandom_u32() or bpf_get_smp_processor_id() (which is supported in BCC but not documented, I think). Thus, using helpers not necessarily implies requiring GPL compatibility. The gpl_only field discriminates which eBPF helpers require it.

A second issue is the license itself. The kernel doesn't require GPL, but GPL-compatibility, which currently is defined as GPL, BSD/GPL, MIT/GPL or MPL/GPL. I am not a lawyer, maybe I am wrong here and "GPL" is just fine...

Finally, the helpers header is incompatible with programs that declare their own license, even if it already is GPL.

I'm not sure if it can be inconvenient to license code without a proper warning. BCC itself is not GPL, it is Apache 2.0, so its C headers don't force GPL. Is there some warning in the documentation that I missed? Is it possible that some users will discover that their eBPF program was licensed under GPL without their knowledge?

So, tentative suggestions:

  • Technically, BCC should allow the eBPF program to select if it needs a license, and in that case which one.
  • It would be interesting to document which eBPF helpers require GPL-compatibility, like the awesome BPF features by Linux kernel version.

Anyway, I understand that this is a low priority discussion now, and that it is much more convenient to have eBPF programs that just work.

Thanks!

Oriol

@oriolarcas
Copy link
Contributor Author

oriolarcas commented Jun 11, 2018

Update: this is becoming an issue, in my opinion.

I detected the following issues, correct me if I'm wrong:

  • It should be an issue that BCC automatically licenses the code under GPL. There are plentiful of eBPF programs that can run without GPL compatibility (48/63 helpers don't require GPL).
  • It should be an issue that BCC specifically chooses GPL, and not other GPL-compatible licenses.
  • It should be an issue that the BCC C headers (helpers.c and proto.h) are licensed under Apache 2.0 if the eBPF program is GPL. It should be worse if the BCC headers simultaneously announce Apache 2.0 and GPL licenses, which sounds incompatible to me (at least Apache 2.0 and GPL v2).

I suggest removing the automatic licensing from helpers.h, letting the user decide what license to use (and getting an error if the kernel rejects the eBPF program).

I also suggest changing the BCC C headers from Apache 2.0 to LGPL, which would allow to compile GPL and non-GPL programs.

oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 12, 2018
The helpers.h header specifies the eBPF program license as 'GPL'. However,
other GPL-compatible licenses are possible (e.g., Dual BSD/GPL) or even
proprietary licenses (e.g., cachetop can run with a proprietary license).

With this commit, the user can specify an EBPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DEBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the eBPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify an BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

See all the GPL-compatible license strings at:

https://github.com/torvalds/linux/blob/v4.17/include/linux/module.h#L172
oriolarcas pushed a commit to oriolarcas/bcc that referenced this issue Jun 13, 2018
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).

With this commit, the user can specify a BPF_LICENSE macro:

  b = BPF(text=bpf_text, cflags=['-DBPF_LICENSE=Custom license'])

Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:

  cannot call GPL only function from proprietary program

Updated the documentation with BPF_LICENSE description, licensing error
description, and licenses for each helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant