<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/include/linux/jump_label.h, branch v6.6.132</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.132</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.132'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2023-06-05T07:57:20+00:00</updated>
<entry>
<title>locking/atomic: treewide: use raw_atomic*_&lt;op&gt;()</title>
<updated>2023-06-05T07:57:20+00:00</updated>
<author>
<name>Mark Rutland</name>
<email>mark.rutland@arm.com</email>
</author>
<published>2023-06-05T07:01:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0f613bfa8268a89be25f2b6b58fc6fe8ccd9a2ba'/>
<id>urn:sha1:0f613bfa8268a89be25f2b6b58fc6fe8ccd9a2ba</id>
<content type='text'>
Now that we have raw_atomic*_&lt;op&gt;() definitions, there's no need to use
arch_atomic*_&lt;op&gt;() definitions outside of the low-level atomic
definitions.

Move treewide users of arch_atomic*_&lt;op&gt;() over to the equivalent
raw_atomic*_&lt;op&gt;().

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland &lt;mark.rutland@arm.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Link: https://lore.kernel.org/r/20230605070124.3741859-19-mark.rutland@arm.com
</content>
</entry>
<entry>
<title>jump_label: Prevent key-&gt;enabled int overflow</title>
<updated>2022-12-01T23:53:05+00:00</updated>
<author>
<name>Dmitry Safonov</name>
<email>dima@arista.com</email>
</author>
<published>2022-11-23T17:38:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=eb8c507296f6038d46010396d91b42a05c3b64d9'/>
<id>urn:sha1:eb8c507296f6038d46010396d91b42a05c3b64d9</id>
<content type='text'>
1. With CONFIG_JUMP_LABEL=n static_key_slow_inc() doesn't have any
   protection against key-&gt;enabled refcounter overflow.
2. With CONFIG_JUMP_LABEL=y static_key_slow_inc_cpuslocked()
   still may turn the refcounter negative as (v + 1) may overflow.

key-&gt;enabled is indeed a ref-counter as it's documented in multiple
places: top comment in jump_label.h, Documentation/staging/static-keys.rst,
etc.

As -1 is reserved for static key that's in process of being enabled,
functions would break with negative key-&gt;enabled refcount:
- for CONFIG_JUMP_LABEL=n negative return of static_key_count()
  breaks static_key_false(), static_key_true()
- the ref counter may become 0 from negative side by too many
  static_key_slow_inc() calls and lead to use-after-free issues.

These flaws result in that some users have to introduce an additional
mutex and prevent the reference counter from overflowing themselves,
see bpf_enable_runtime_stats() checking the counter against INT_MAX / 2.

Prevent the reference counter overflow by checking if (v + 1) &gt; 0.
Change functions API to return whether the increment was successful.

Signed-off-by: Dmitry Safonov &lt;dima@arista.com&gt;
Acked-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>jump_label: make initial NOP patching the special case</title>
<updated>2022-06-24T07:48:55+00:00</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ardb@kernel.org</email>
</author>
<published>2022-06-15T15:41:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7e6b9db27de9f69a705c1a046d45882c768e16c3'/>
<id>urn:sha1:7e6b9db27de9f69a705c1a046d45882c768e16c3</id>
<content type='text'>
Instead of defaulting to patching NOP opcodes at init time, and leaving
it to the architectures to override this if this is not needed, switch
to a model where doing nothing is the default. This is the common case
by far, as only MIPS requires NOP patching at init time. On all other
architectures, the correct encodings are emitted by the compiler and so
no initial patching is needed.

Signed-off-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Acked-by: Mark Rutland &lt;mark.rutland@arm.com&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20220615154142.1574619-4-ardb@kernel.org
</content>
</entry>
<entry>
<title>jump_label: mips: move module NOP patching into arch code</title>
<updated>2022-06-24T07:48:55+00:00</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ardb@kernel.org</email>
</author>
<published>2022-06-15T15:41:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fdfd42892f311e2b3695852036e5be23661dc590'/>
<id>urn:sha1:fdfd42892f311e2b3695852036e5be23661dc590</id>
<content type='text'>
MIPS is the only remaining architecture that needs to patch jump label
NOP encodings to initialize them at load time. So let's move the module
patching part of that from generic code into arch/mips, and drop it from
the others.

Signed-off-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20220615154142.1574619-3-ardb@kernel.org
</content>
</entry>
<entry>
<title>jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds</title>
<updated>2022-05-27T10:34:44+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2022-05-02T10:30:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=656d054e0a15ec327bd82801ccd58201e59f6896'/>
<id>urn:sha1:656d054e0a15ec327bd82801ccd58201e59f6896</id>
<content type='text'>
When building x86_64 with JUMP_LABEL=n it's possible for
instrumentation to sneak into noinstr:

vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section

Switch to arch_ prefixed atomic to avoid the explicit instrumentation.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
</content>
</entry>
<entry>
<title>jump_label: Refactor #ifdef of struct static_key</title>
<updated>2022-02-16T14:57:58+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2022-02-13T16:57:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cd27ccfc727e99352321c0c75012ab9c5a90321e'/>
<id>urn:sha1:cd27ccfc727e99352321c0c75012ab9c5a90321e</id>
<content type='text'>
Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20220213165717.2354046-2-masahiroy@kernel.org
</content>
</entry>
<entry>
<title>jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}</title>
<updated>2022-02-16T14:57:58+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2022-02-13T16:57:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fe65deb56e552a8c9bf7f27860dbdeac12a36116'/>
<id>urn:sha1:fe65deb56e552a8c9bf7f27860dbdeac12a36116</id>
<content type='text'>
Commit 3821fd35b58d ("jump_label: Reduce the size of struct static_key")
introduced the union to struct static_key.

It is more natual to set JUMP_TYPE_* to the .type field without casting.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20220213165717.2354046-1-masahiroy@kernel.org
</content>
</entry>
<entry>
<title>jump_label: Free jump_entry::key bit1 for build use</title>
<updated>2021-05-12T12:54:55+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2021-05-06T19:34:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5af0ea293d78c8b8f0b87ae2b13f7ac584057bc3'/>
<id>urn:sha1:5af0ea293d78c8b8f0b87ae2b13f7ac584057bc3</id>
<content type='text'>
Have jump_label_init() set jump_entry::key bit1 to either 0 ot 1
unconditionally. This makes it available for build-time games.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20210506194157.906893264@infradead.org
</content>
</entry>
<entry>
<title>jump_label, x86: Introduce jump_entry_size()</title>
<updated>2021-05-12T12:54:55+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2021-05-06T19:33:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fa5e5dc39669b4427830c546ede8709323b8276c'/>
<id>urn:sha1:fa5e5dc39669b4427830c546ede8709323b8276c</id>
<content type='text'>
This allows architectures to have variable sized jumps.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20210506194157.786777050@infradead.org
</content>
</entry>
<entry>
<title>jump_label: Provide CONFIG-driven build state defaults</title>
<updated>2021-04-08T12:05:19+00:00</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2021-04-01T23:23:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0d66ccc1627013c95f1e7ef10b95b8451cd7834e'/>
<id>urn:sha1:0d66ccc1627013c95f1e7ef10b95b8451cd7834e</id>
<content type='text'>
As shown in the comment in jump_label.h, choosing the initial state of
static branches changes the assembly layout. If the condition is expected
to be likely it's inline, and if unlikely it is out of line via a jump.

A few places in the kernel use (or could be using) a CONFIG to choose the
default state, which would give a small performance benefit to their
compile-time declared default. Provide the infrastructure to do this.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20210401232347.2791257-2-keescook@chromium.org

</content>
</entry>
</feed>
