<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/lib/vsprintf.c, branch v6.1.2</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.1.2</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.1.2'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-10-10T18:24:19+00:00</updated>
<entry>
<title>Merge tag 'printk-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux</title>
<updated>2022-10-10T18:24:19+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2022-10-10T18:24:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b520410654103086ccc0d339c0ff645d4c4dd697'/>
<id>urn:sha1:b520410654103086ccc0d339c0ff645d4c4dd697</id>
<content type='text'>
Pull printk updates from Petr Mladek:

 - Initialize pointer hashing using the system workqueue. It avoids
   taking locks in printk()/vsprintf() code path

 - Misc code clean up

* tag 'printk-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
  printk: Mark __printk percpu data ready __ro_after_init
  printk: Remove bogus comment vs. boot consoles
  printk: Remove write only variable nr_ext_console_drivers
  printk: Declare log_wait properly
  printk: Make pr_flush() static
  lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready.
  lib/vsprintf: Remove static_branch_likely() from __ptr_to_hashval().
  lib/vnsprintf: add const modifier for param 'bitmap'
</content>
</entry>
<entry>
<title>Merge branch 'for-6.1-hash-pointer-init' into for-linus</title>
<updated>2022-10-04T13:55:44+00:00</updated>
<author>
<name>Petr Mladek</name>
<email>pmladek@suse.com</email>
</author>
<published>2022-10-04T13:55:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=da743a92e5895eb1b225de7d9806274fdbd43061'/>
<id>urn:sha1:da743a92e5895eb1b225de7d9806274fdbd43061</id>
<content type='text'>
</content>
</entry>
<entry>
<title>lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready.</title>
<updated>2022-09-29T11:44:51+00:00</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2022-09-27T10:49:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6f0ac3b52a9075b7291a72fb338d08491c1f0a64'/>
<id>urn:sha1:6f0ac3b52a9075b7291a72fb338d08491c1f0a64</id>
<content type='text'>
The printk code invokes vnsprintf in order to compute the complete
string before adding it into its buffer. This happens in an IRQ-off
region which leads to a warning on PREEMPT_RT in the random code if the
format strings contains a %p for pointer printing. This happens because
the random core acquires locks which become sleeping locks on PREEMPT_RT
which must not be acquired with disabled interrupts and or preemption
disabled.
By default the pointers are hashed which requires a random value on the
first invocation (either by printk or another user which comes first.

One could argue that there is no need for printk to disable interrupts
during the vsprintf() invocation which would fix the just mentioned
problem. However printk itself can be invoked in a context with
disabled interrupts which would lead to the very same problem.

Move the initialization of ptr_key into a worker and schedule it from
subsys_initcall(). This happens early but after the workqueue subsystem
is ready. Use get_random_bytes() to retrieve the random value if the RNG
core is ready, otherwise schedule a worker in two seconds and try again.

Another advantage is that it removes a lock from the vsprintf() code path.
It prevents a possible deadlock when printk("%p", ptr) is called under
the lock taken in get_random_bytes().

Reported-by: Mike Galbraith &lt;efault@gmx.de&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Acked-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
[pmladek@suse.com: Added a note about the it prevented a possible deadlock in printk().]
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20220927104912.622645-3-bigeasy@linutronix.de
</content>
</entry>
<entry>
<title>lib/vsprintf: Remove static_branch_likely() from __ptr_to_hashval().</title>
<updated>2022-09-29T11:44:27+00:00</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2022-09-27T10:49:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e4279b599863dd1aa71fb8e35bffa943545bbaeb'/>
<id>urn:sha1:e4279b599863dd1aa71fb8e35bffa943545bbaeb</id>
<content type='text'>
Using static_branch_likely() to signal that ptr_key has been filled is a
bit much given that it is not a fast path.

Replace static_branch_likely() with bool for condition and a memory
barrier for ptr_key.

Suggested-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20220927104912.622645-2-bigeasy@linutronix.de
</content>
</entry>
<entry>
<title>vsprintf: add new `%pA` format specifier</title>
<updated>2022-09-28T07:00:20+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2021-07-03T15:38:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=787983da77185d355564b0436f7b4eaa40b8904b'/>
<id>urn:sha1:787983da77185d355564b0436f7b4eaa40b8904b</id>
<content type='text'>
This patch adds a format specifier `%pA` to `vsprintf` which formats
a pointer as `core::fmt::Arguments`. Doing so allows us to directly
format to the internal buffer of `printf`, so we do not have to use
a temporary buffer on the stack to pre-assemble the message on
the Rust side.

This specifier is intended only to be used from Rust and not for C, so
`checkpatch.pl` is intentionally unchanged to catch any misuse.

Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Petr Mladek &lt;pmladek@suse.com&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Co-developed-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Co-developed-by: Wedson Almeida Filho &lt;wedsonaf@google.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@google.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Co-developed-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/vnsprintf: add const modifier for param 'bitmap'</title>
<updated>2022-08-25T08:09:03+00:00</updated>
<author>
<name>Jian Shen</name>
<email>shenjian15@huawei.com</email>
</author>
<published>2022-08-16T14:45:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=dc453dd89daacdc0da6d66234aa27e417df7edcd'/>
<id>urn:sha1:dc453dd89daacdc0da6d66234aa27e417df7edcd</id>
<content type='text'>
There is no modification for param bitmap in function
bitmap_string() and bitmap_list_string(), so add const
modifier for it.

Signed-off-by: Jian Shen &lt;shenjian15@huawei.com&gt;
Signed-off-by: Guangbin Huang &lt;huangguangbin2@huawei.com&gt;
Reviewed-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Reviewed-by: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20220816144557.30779-1-huangguangbin2@huawei.com
</content>
</entry>
<entry>
<title>random: remove rng_has_arch_random()</title>
<updated>2022-06-10T09:29:48+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-06-08T08:31:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e052a478a7daeca67664f7addd308ff51dd40654'/>
<id>urn:sha1:e052a478a7daeca67664f7addd308ff51dd40654</id>
<content type='text'>
With arch randomness being used by every distro and enabled in
defconfigs, the distinction between rng_has_arch_random() and
rng_is_initialized() is now rather small. In fact, the places where they
differ are now places where paranoid users and system builders really
don't want arch randomness to be used, in which case we should respect
that choice, or places where arch randomness is known to be broken, in
which case that choice is all the more important. So this commit just
removes the function and its one user.

Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt; # for vsprintf.c
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: remove mostly unused async readiness notifier</title>
<updated>2022-05-19T14:54:15+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-05-15T13:06:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6701de6c51c172b5de5633374479503c81fefc0b'/>
<id>urn:sha1:6701de6c51c172b5de5633374479503c81fefc0b</id>
<content type='text'>
The register_random_ready_notifier() notifier is somewhat complicated,
and was already recently rewritten to use notifier blocks. It is only
used now by one consumer in the kernel, vsprintf.c, for which the async
mechanism is really overly complex for what it actually needs. This
commit removes register_random_ready_notifier() and unregister_random_
ready_notifier(), because it just adds complication with little utility,
and changes vsprintf.c to just check on `!rng_is_initialized() &amp;&amp;
!rng_has_arch_random()`, which will eventually be true. Performance-
wise, that code was already using a static branch, so there's basically
no overhead at all to this change.

Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Acked-by: Petr Mladek &lt;pmladek@suse.com&gt; # for vsprintf.c
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>random: remove get_random_bytes_arch() and add rng_has_arch_random()</title>
<updated>2022-05-19T14:54:15+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-05-14T11:09:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=248561ad25a8ba4ecbc7df42f9a5a82fd5fbb4f6'/>
<id>urn:sha1:248561ad25a8ba4ecbc7df42f9a5a82fd5fbb4f6</id>
<content type='text'>
The RNG incorporates RDRAND into its state at boot and every time it
reseeds, so there's no reason for callers to use it directly. The
hashing that the RNG does on it is preferable to using the bytes raw.

The only current use case of get_random_bytes_arch() is vsprintf's
siphash key for pointer hashing, which uses it to initialize the pointer
secret earlier than usual if RDRAND is available. In order to replace
this narrow use case, just expose whether RDRAND is mixed into the RNG,
with a new function called rng_has_arch_random(). With that taken care
of, there are no users of get_random_bytes_arch() left, so it can be
removed.

Later, if trust_cpu gets turned on by default (as most distros are
doing), this one use of rng_has_arch_random() can probably go away as
well.

Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Acked-by: Petr Mladek &lt;pmladek@suse.com&gt; # for vsprintf.c
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>lib/vsprintf: avoid redundant work with 0 size</title>
<updated>2022-03-25T02:06:44+00:00</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2022-03-25T01:09:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ef62c8ff1de437ec2e0582205c1293c7dbbc4484'/>
<id>urn:sha1:ef62c8ff1de437ec2e0582205c1293c7dbbc4484</id>
<content type='text'>
Patch series "mm/page_owner: Extend page_owner to show memcg information", v4.

While debugging the constant increase in percpu memory consumption on a
system that spawned large number of containers, it was found that a lot
of offline mem_cgroup structures remained in place without being freed.
Further investigation indicated that those mem_cgroup structures were
pinned by some pages.

In order to find out what those pages are, the existing page_owner
debugging tool is extended to show memory cgroup information and whether
those memcgs are offline or not.  With the enhanced page_owner tool, the
following is a typical page that pinned the mem_cgroup structure in my
test case:

  Page allocated via order 0, mask 0x1100cca(GFP_HIGHUSER_MOVABLE), pid 162970 (podman), ts 1097761405537 ns, free_ts 1097760838089 ns
  PFN 1925700 type Movable Block 3761 type Movable Flags 0x17ffffc00c001c(uptodate|dirty|lru|reclaim|swapbacked|node=0|zone=2|lastcpupid=0x1fffff)
    prep_new_page+0xac/0xe0
    get_page_from_freelist+0x1327/0x14d0
    __alloc_pages+0x191/0x340
    alloc_pages_vma+0x84/0x250
    shmem_alloc_page+0x3f/0x90
    shmem_alloc_and_acct_page+0x76/0x1c0
    shmem_getpage_gfp+0x281/0x940
    shmem_write_begin+0x36/0xe0
    generic_perform_write+0xed/0x1d0
    __generic_file_write_iter+0xdc/0x1b0
    generic_file_write_iter+0x5d/0xb0
    new_sync_write+0x11f/0x1b0
    vfs_write+0x1ba/0x2a0
    ksys_write+0x59/0xd0
    do_syscall_64+0x37/0x80
    entry_SYSCALL_64_after_hwframe+0x44/0xae
  Charged to offline memcg libpod-conmon-15e4f9c758422306b73b2dd99f9d50a5ea53cbb16b4a13a2c2308a4253cc0ec8.

So the page was not freed because it was part of a shmem segment.  That
is useful information that can help users to diagnose similar problems.

With cgroup v1, /proc/cgroups can be read to find out the total number
of memory cgroups (online + offline).  With cgroup v2, the cgroup.stat
of the root cgroup can be read to find the number of dying cgroups (most
likely pinned by dying memcgs).

The page_owner feature is not supposed to be enabled for production
system due to its memory overhead.  However, if it is suspected that
dying memcgs are increasing over time, a test environment with
page_owner enabled can then be set up with appropriate workload for
further analysis on what may be causing the increasing number of dying
memcgs.

This patch (of 4):

For *scnprintf(), vsnprintf() is always called even if the input size is
0.  That is a waste of time, so just return 0 in this case.

Note that vsnprintf() will never return -1 to indicate an error.  So
skipping the call to vsnprintf() when size is 0 will have no functional
impact at all.

Link: https://lkml.kernel.org/r/20220202203036.744010-1-longman@redhat.com
Link: https://lkml.kernel.org/r/20220202203036.744010-2-longman@redhat.com
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Reviewed-by: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Acked-by: Roman Gushchin &lt;guro@fb.com&gt;
Acked-by: Rafael Aquini &lt;aquini@redhat.com&gt;
Acked-by: Mike Rapoport &lt;rppt@linux.ibm.com&gt;
Cc: Roman Gushchin &lt;roman.gushchin@linux.dev&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@kernel.org&gt;
Cc: Vladimir Davydov &lt;vdavydov.dev@gmail.com&gt;
Cc: Petr Mladek &lt;pmladek@suse.com&gt;
Cc: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Cc: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Cc: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Ira Weiny &lt;ira.weiny@intel.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
