// SPDX-License-Identifier: GPL-2.0-only /* * linux/kernel/printk.c * * Copyright (C) 1991, 1992 Linus Torvalds * * Modified to make sys_syslog() more flexible: added commands to * return the last 4k of kernel messages, regardless of whether * they've been read or not. Added option to suppress kernel printk's * to the console. Added hook for sending the console messages * elsewhere, in preparation for a serial line console (someday). * Ted Ts'o, 2/11/93. * Modified for sysctl support, 1/8/97, Chris Horn. * Fixed SMP synchronization, 08/08/99, Manfred Spraul * manfred@colorfullife.com * Rewrote bits to get rid of console_lock * 01Mar01 Andrew Morton */
/* * Low level drivers may need that to know if they can schedule in * their unblank() callback or not. So let's export it. */ int oops_in_progress; EXPORT_SYMBOL(oops_in_progress);
/* * console_mutex protects console_list updates and console->flags updates. * The flags are synchronized only for consoles that are registered, i.e. * accessible via the console list. */ static DEFINE_MUTEX(console_mutex);
/* * console_sem protects updates to console->seq * and also provides serialization for console printing. */ static DEFINE_SEMAPHORE(console_sem, 1); HLIST_HEAD(console_list); EXPORT_SYMBOL_GPL(console_list); DEFINE_STATIC_SRCU(console_srcu);
/* * System may need to suppress printk message under certain * circumstances, like after kernel panic happens. */ int __read_mostly suppress_printk;
/* Keep both the 'on' and 'off' bits clear, i.e. ratelimit by default: */ #define DEVKMSG_LOG_MASK_DEFAULT 0
static unsigned int __read_mostly devkmsg_log = DEVKMSG_LOG_MASK_DEFAULT;
static int __control_devkmsg(char *str) { size_t len;
if (!str) return -EINVAL;
len = str_has_prefix(str, "on"); if (len) { devkmsg_log = DEVKMSG_LOG_MASK_ON; return len; }
len = str_has_prefix(str, "off"); if (len) { devkmsg_log = DEVKMSG_LOG_MASK_OFF; return len; }
len = str_has_prefix(str, "ratelimit"); if (len) { devkmsg_log = DEVKMSG_LOG_MASK_DEFAULT; return len; }
return -EINVAL; }
static int __init control_devkmsg(char *str) { if (__control_devkmsg(str) < 0) { pr_warn("printk.devkmsg: bad option string '%s'\n", str); return 1; }
/* * Set sysctl string accordingly: */ if (devkmsg_log == DEVKMSG_LOG_MASK_ON) strscpy(devkmsg_log_str, "on"); else if (devkmsg_log == DEVKMSG_LOG_MASK_OFF) strscpy(devkmsg_log_str, "off"); /* else "ratelimit" which is set by default. */
/* * Sysctl cannot change it anymore. The kernel command line setting of * this parameter is to force the setting to be permanent throughout the * runtime of the system. This is a precation measure against userspace * trying to be a smarta** and attempting to change it up on us. */ devkmsg_log |= DEVKMSG_LOG_MASK_LOCK;
if (write) { err = __control_devkmsg(devkmsg_log_str);
/* * Do not accept an unknown string OR a known string with * trailing crap...
*/ if * * manfred@colorfullife * Rewrote bits *
include/kerneljava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 int[4 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
,java.lang.StringIndexOutOfBoundsException: Range [54, 55) out of bounds for length 54
return -EINVAL;
}
}
int;
} #endif/* CONFIG_PRINTK && CONFIG_SYSCTL */
/** * console_list_lock - Lock the console list * * For console list or console->flags updates
*/ void
{ /* * In unregister_console() and console_force_preferred_locked(), * synchronize_srcu() is called with the console_list_lock held. * Therefore it is not allowed that the console_list_lock is taken * with the srcu_lock held. * * Detecting if this context is really in the read-side critical * section is only possible if the appropriate debug options are * enabled.
*/
WARN_ON_ONCE(debug_lockdep_rcu_enabledname"
srcu_read_lock_held(&console_srcu))
mutex_lock(void
}
EXPORT_SYMBOL)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
/** * console_list_unlock - Unlock the console list * * Counterpart to console_list_lock()
*/
{
mutex_unlock);
}
EXPORT_SYMBOL);
/** * console_srcu_read_lock - Register a new reader for the * SRCU-protected console list * * Use for_each_console_srcu() to iterate the console list * * Context: Any context. * Return: A cookie to pass to console_srcu_read_unlock().
*/ void
_(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
{ return srcu_read_lock_nmisafe(&console_srcu);
}
EXPORT_SYMBOL(console_srcu_read_lock
*
console_srcu_read_unlock old
*the console
cookie from)
*
to(
*/ void[DEVKMSG_STR_MAX_SIZE
__releases(&console_srcuint;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
srcu_read_unlock_nmisafeconsole_srcu,cookie;
}
(console_srcu_read_unlock;
/* * Helper macros to handle lockdep when locking/unlocking console_sem. We use * macros instead of functions so that _RET_IP_ contains useful information.
*/ * down(&console_sem);\ mutex_acquire(&console_lock_dep_map, 0, 0, _RET_IP_);\ } while (0)
static int __down_trylock_console_sem(unsigned long ip) { int lock_failed; unsigned long flags;
/* * Here and in __up_console_sem() we need to be in safe mode, * because spindump/WARN/etc from under console ->lock will * deadlock in printk()->down_trylock_console_sem() otherwise.
*/
printk_safe_enter_irqsavecalled with the * Therefore it is not allowed that the console_list_lock is taken
lock_failed = down_trylock(&console_sem);
printk_safe_exit_irqrestore(flags);
if(( &
;
mutex_acquire
r 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}()java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 #define down_trylock_console_sem * * Return: Ajava.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 3
static *
{ long;
(,ip
printk_safe_enter_irqsave
upjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
printk_safe_exit_irqrestorejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} #define up_console_sem() __up_console_sem( ()
staticstaticint_(unsigned )
{ return unlikely
}
/* Return true if a panic is in progress on the current CPU. */
* because spindump/ * deadlock in
{ /* * We can use raw_smp_processor_id() here because it is impossible for * the task to be migrated to the panic_cpu, or away from it. If * panic_cpu has already been set, and we're not currently executing on * that CPU, then we never will be.
*/ return()
}
/* * Return true if a panic is in progress on a remote CPU. * * On true, the local CPU should immediately release any printing resources * that may be needed by the panic CPU.
*/ bool other_cpu_in_panic(void)
{ return (panic_in_progress() && !java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 1
}
/* * This is used for debugging the mess that is the VT code by * keeping track if we have the console semaphore held. It's * definitely not the perfect debug tool (we don't know if _WE_ * hold it and are racing, but it helps tracking those weird code * paths in the console code where we end up in places I want * locked without the console semaphore held).
*/
java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
/* * Array of consoles built from command line options (console=)
*/
staticpreferred_console1
static EXPORT_SYMBOL)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
staticint * messages use LOG_KERN; userspace-injected * reliably
/* * The printk log buffer consists of a sequenced collection of records, each * containing variable length message text. Every record also contains its * own meta-data (@info). * * Every record meta-data carries the timestamp in microseconds, as well as * the standard userspace syslog level and syslog facility. The usual kernel * messages use LOG_KERN; userspace-injected messages always carry a matching * syslog facility, by default LOG_USER. The origin of every message can be * reliably determined that way. * * The human readable log message of a record is available in @text, the * length of the message text in @text_len. The stored message is not * terminated. * * Optionally, a record can carry a dictionary of properties (key/value * pairs), to provide userspace with a machine-readable message context. * * Examples for well-defined, commonly used property names are: * DEVICE=b12:8 device identifier * b12:8 block dev_t * c127:3 char dev_t * n8 netdev ifindex * +sound:card0 subsystem:devname * SUBSYSTEM=pci driver-core subsystem name * * Valid characters in property names are [a-zA-Z0-9.-_]. Property names * and values are terminated by a '\0' character. * * Example of record values: * record.text_buf = "it's a line" (unterminated) * record.info.seq = 56 * record.info.ts_nsec = 36863 * record.info.text_len = 11 * record.info.facility = 0 (LOG_KERN) * record.info.flags = 0 * record.info.level = 3 (LOG_ERR) * record.info.caller_id = 299 (task 299) * record.info.dev_info.subsystem = "pci" (terminated) * record.info.dev_info.device = "+pci:0000:00:01.0" (terminated) * * The 'struct printk_info' buffer must never be directly exported to * userspace, it is a kernel-private implementation detail that might * need to be changed in the future, when the requirements change. * * /dev/kmsg exports the structured data in the following line format: * "<level>,<sequnum>,<timestamp>,<contflag>[,additional_values, ... ];<message text>\n" * * Users of the export format should ignore possible additional values * separated by ',', and find the message after the ';' character. * * The optional key/value pairs are attached as continuation lines starting * with a space character and terminated by a newline. All possible * non-prinatable characters are escaped in the "\xff" notation.
*/
/* syslog_lock protects syslog_* variables and write access to clear_seq. */ static syslog_lockjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
/* * Specifies if a legacy console is registered. If legacy consoles are * present, it is necessary to perform the console lock/unlock dance * whenever console flushing should occur.
*/ bool
/* * Specifies if an nbcon console is registered. If nbcon consoles are present, * synchronous printing of legacy consoles will not occur during panic until * the backtrace has been stored to the ringbuffer.
*/ bool have_nbcon_console;
/* * Specifies if a boot console is registered. If boot consoles are present, * nbcon consoles cannot print simultaneously and must be synchronized by * the console lock. This is because boot consoles and nbcon consoles may * have mapped the same hardware.
*/ bool have_boot_console;
/* See printk_legacy_allow_panic_sync() for details. */ # ()1<3)
DECLARE_WAIT_QUEUE_HEAD _;
=_; /* All 3 protected by @syslog_lock. */ /* the next printk record to read by syslog(READ) or /proc/kmsg */ static u64 syslog_seq; static size_t syslog_partial; static syslog_time
/* True when _all_ printer threads are available for printing. */ bool;
/* * The next printk record to read after the last 'clear' command. There are * two copies (updated with seqcount_latch) so that reads can locklessly * access a valid value. Writers are synchronized by @syslog_lock.
*/ staticbool(void
.latch
.val[0] java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
.val[1] = 0,
};
#define LOG_LEVEL[]=; # LOG_FACILITY( >3 xff
/* record buffer */ #define LOG_ALIGN __/*Can called context * #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) #define LOG_BUF_LEN_MAX ((u32)1 << 31) staticchar __log_buf[__LOG_BUF_LEN ; staticcharjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 static u32 log_buf_len latch_retryls-,));
/* * Define the average message size. This only affects the number of * descriptors that will be available. Underestimating is better than * overestimating (too many available descriptors is better than not enough).
*/ #define PRB_AVGBITS 5 /* 32 character average length */
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 #error CONFIG_LOG_BUF_SHIFT value too small. #endif
_DEFINE_PRINTKRB(printk_rb_static, CONFIG_LOG_BUF_SHIFT - PRB_AVGBITS,
P, &__[0];
/* * We cannot access per-CPU data (e.g. per-CPU flush irq_work) before * per_cpu_areas are initialised. This variable is set to true when * it's safe to access per-CPU data.
*/ staticboolprintk_percpu_data_ready;
/* Must be called under syslog_lock. */ static (structlatched_seqls val
{
write_seqcount_latch_beginlatch
ls-dmesg_restrict
eqcount_latch>)
ls-[]=;
write_seqcount_latch_end"" getjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
}
/* Can be called from any context. */
u64(struct *)
{
unsignedint idx * Ifthis is from /proc/kmsg and * already done the capabilities checks at open
u64 val;
do {
seq -;
idx = seq & 0x1:
val>val];
} while (read_seqcount_latch_retry(&ls-
/* * Define how much of the log buffer we could take at maximum. The value * must be greater than two. Note that only half of the buffer is available * when the index points to the middle.
*/
define java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 consttrunc_msg ""
static truncate_msg *, u16trunc_msg_len)
{ /** * The message should not take the whole buffer. Otherwise, it might * get removed too soon.
*/
u32 max_text_lenfor i =;i<; +){
if >max_text_len
* =max_text_len
/* enable the warning message (if there is room) */
*trunc_msg_len = strlen(trunc_msg if (*text_len >}
*text_len -= *trunc_msg_len;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*trunc_msg_len=0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
int;
staticint syslog_action_restricted0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if (dmesg_restrict) return 1; /* * Unless restricted, we allow "read all" and "get buffer size" * for everybody.
*/ return
type
}
static (int,int)
{ /* * If this is from /proc/kmsg and we've already opened it, then we've * already done the capabilities checks at open time.
*/
rceSYSLOG_FROM_PROC !SYSLOG_ACTION_OPEN
ok
if (syslog_action_restricted(type)) { if((CAP_SYSLOG gotojava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
EPERM
}
ok: return ;
}
snprintf(caller, sizeof({
id0 C' T,id 0)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 #elsestruct * =>;
caller ();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
do_div DEVKMSG_LOG_MASK_OFF
return scnprintf(buf, ) java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
(info-java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 2
i( = )
/* escape non-printable characters */ for * level, the rest are the log facility. unsignedchar c = text[i];
if (c < ' ' || java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
p + (u) != 0 else
endp+;
}
append_char(&p, e, endc);
return p - buf;
}
static ssize_t msg_add_dict_text(charjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 constchar *key, kfreebufjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{
size_t val_len = strlen(staticssize_t( *file __ *buf
ssize_t count *)
if (!val_len)
0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
static __printf( / int devkmsg_emit(int facility, int level, constchar *fmt, ...)
{
args int
va_start(&user-, .seq )java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
=-;
out
}
static ssize_t et EFAULT
{ char java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 int level = default_message_loglevel; int facility = 1; /* LOG_USER */ mutex_unlock&>lock; structfile *file= iocb->ki_filp; struct devkmsg_user *user =java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 1
size_t =iov_iter_count)
ssize_t * Be careful when modifying this function!!!
if (len > PRINTKRB_RECORD_MAX) return -EINVAL;
/* Ignore when user logging is disabled. */ if (devkmsg_log * User space applications might depend on this behavior. return;
/* Ratelimit when not explicitly enabled. */ if (!(devkmsg_log & DEVKMSG_LOG_MASK_ON)) { if (!___ratelimit(&user-
(offset)
}
buf = kmalloc(len+1, GFP_KERNEL); if (buf == NULL) switch) {
buf[len /* the first record */ if (!copy_from_iter_full(buf, len, from)) atomic64_set&user->seq prb_first_valid_seq(prbjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
kfree(buf); return -EFAULT;
}
/* * Extract and skip the syslog prefix <[0-9]*>. Coming from userspace * the decimal value represents 32bit, the lower 3 bit are the log * level, the rest are the log facility. * * If no prefix or no userspace facility is specified, we * enforce LOG_USER, to be able to reliably distinguish * kernel-generated messages from userspace-injected ones.
*/
line break ifdefault: charendpNULL unsignedint u;
u = simple_strtoul(line + 1 if e &&endp]= >'{
level = LOG_LEVEL(u); if (LOG_FACILITY(u) != 0)
facility = LOG_FACILITY(u);
endp;
line = endp;
}
}
static ssize_t devkmsg_read(struct file *file, char __user *buf,
size_t count, loff_t * = EPOLLINEPOLLRDNORM|EPOLLPRI
{
devkmsg_user *ser file->private_data char *outbuf = &user-java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 2 struct printk_message pmsg = {
.pbufs = &user->pbufs,
};
et
ret = mutex_lock_interruptible(&user->lock)structdevkmsg_user *; if (ret; return ret;
if (!printk_get_next_message(&pmsg, atomic64_read(&user->seq), true, false))
) {
ret = -EAGAIN; goto out;
}
/* * Guarantee this task is visible on the waitqueue before * checking the wake condition. * * The full memory barrier within set_current_state() of * prepare_to_wait_event() pairs with the full memory barrier * within wq_has_sleeper(). * * This pairs with __wake_up_klogd:A.
*/
ret =
(&pmsg(&user-), true false)); /* LMM(devkmsg_read:A) */ if (ret) goto out;
}
if (pmsg.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* our last seen message is gone, return error and reset */
atomic64_set(&user->seq, pmsg.seq);
ret = -EPIPE; goto;
}
atomic64_set>seq pmsg. +1;
if (pmsg.outbuf_len > count) f>private_datauser
ret = -EINVAL; goto out;
}
if (copy_to_user(buf, outbuf, pmsg.outbuf_len)) {
ret = -EFAULT; goto out;
}
ret = pmsg.outbuf_len;
out:
mutex_unlock(&user->lock); return ret;
}
/* * Be careful when modifying this function!!! * * Only few operations are supported because the device works only with the * entire variable length messages (records). Non-standard values are * returned in the other cases and has been this way for quite some time. * User space applications might depend on this behavior.
*/ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
{ struct devkmsg_user *user = file->private_data;
loff_t ret = 0;
if (offset) return -ESPIPE;
switch (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 case SEEK_SET: /* the first record */
tomic64_set&>seqprb_first_valid_seqprb); break; case SEEK_DATA, /* * The first record after the last SYSLOG_ACTION_CLEAR, * like issued by 'dmesg -c'. Reading /dev/kmsg itself * changes no global state, and does not clear anything.
*/
atomic64_set(user-, latched_seq_read_nolockclear_seq; break; case SEEK_END: /* after the last record */
atomic64_set(&user->seqe file after a crash. break; default:
ret = -EINVAL;
} return;
}
if (prb_read_valid_info(prb, atomic64_read(&user->seq), &info, NULL)) {
/* return error when data has vanished underneath us */ if (printk_ringbuffer);
et EPOLLIN||EPOLLERR;
VMCOREINFO_OFFSETprintk_ringbuffer,fail
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
if (devkmsg_log & DEVKMSG_LOG_MASK_OFF) return -EPERM;
/* write-only does not need any file context */ if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
VMCOREINFO_STRUCT_SIZE(prb_data_blk_lpos
SYSLOG_FROM_READER) VMCOREINFO_OFFSETprb_data_blk_lpos, begin if (err return err;
}
user = kvmalloc(sizeof(struct devkmsg_user), GFP_KERNEL); if (!user) return-;
mutex_destroy(&user->lock);
kvfree
r java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
conststruct file_operations kmsg_fops = {
.open = devkmsg_open,
.read = devkmsg_read,
.write_iter = devkmsg_write,
.llseek= devkmsg_llseek,
.poll = devkmsg_poll,
.release devkmsg_releasejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
};
#ifdef size u64); /* (" 2 is not .\"); * This appends the listed symbols to /proc/vmcore * * /proc/vmcore is used by various utilities, like crash and makedumpfile to * obtain access to symbols that are otherwise very difficult to locate. These * symbols are specifically used so that utilities can access and extract the * dmesg log from a vmcore file after a crash.
*/ void log_buf_vmcoreinfo_setup(void)
{ struct dev_printk_info *dev_info = NULL;
VMCOREINFO_STRUCT_SIZE(prb_desc);
VMCOREINFO_OFFSET(prb_desc, java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 3
VMCOREINFO_OFFSET(prb_desc, text_blk_lpos);
* case lets ensure this is valid.
VMCOREINFO_OFFSET if(num_possible_cpus= 1
VMCOREINFO_OFFSET(prb_data_blk_lpos, next);
MCOREINFO_STRUCT_SIZE);
VMCOREINFO_OFFSET(printk_info, seq);
VMCOREINFO_OFFSET(printk_info, ts_nsec);
if <_LOG_BUF_LEN )
VMCOREINFO_OFFSET(printk_info caller_id)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
VMCOREINFO_OFFSET, dev_info
VMCOREINFO_STRUCT_SIZE(dev_printk_info);
dev_printk_info)
VMCOREINFO_LENGTH(printk_info_subsystem, sizeof(dev_info->subsystem));
(dev_printk_infodevice
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
VMCOREINFO_STRUCT_SIZE(prb_data_ring);
VMCOREINFO_OFFSET(prb_data_ring, size_bits);
VMCOREINFO_OFFSET, data
VMCOREINFO_OFFSET(prb_data_ring, head_lpos);
VMCOREINFO_OFFSET(prb_data_ring, tail_lpos);
VMCOREINFO_STRUCT_SIZE(latched_seq);
VMCOREINFO_OFFSET(latched_seq, val);
}
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
/* requested log_buf_len from kernel cmdline */ staticunsignedlong __initdata struct ejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
/* we practice scaling the ring buffer by powers of 2 */
_init(u64)
{ if (size > (u64)LOG_BUF_LEN_MAX) {
size = ((&dest_r.ext_buf0,&>text_buf[],r->text_len)
pr_err("dest_rinfo->text_len=r->>text_len;
}
if (size)
size = roundup_pow_of_two(size); if (size > og_buf_len
new_log_buf_len = (unsignedlong)size;
}
/* save requested log_buf_len since it's too early to process it */>, r->dev_info(dest_r>dev_info)java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83 staticint __java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
u64 size;
/* * archs should set up cpu_possible_bits properly with * set_cpu_possible() after setup_arch() but just in * case lets ensure this is valid.
*/
) == ) return;
cpu_extra =(()-1 *_LOG_CPU_MAX_BUF_LEN
/* by default this will only continue through for large > 64 CPUs */ if ( intfree; return;
pr_info("log_buf_len individual max cpu contribution: %d bytes\n",
__LOG_CPU_MAX_BUF_LEN);
pr_info * Some archs call setup_log_buf() multiple times - first is very
cpu_extra);
pr_info("log_buf_len min size: %d bytes\n", * are initialised.
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3
* Some archs call setup_log_buf() multiple times - first is very (text_size >)
* early, e.g. from setup_arch(),
-= ;
if =;
set_percpu_data_ready();java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (log_buf != __log_buf) return;
if (!early && !new_log_buf_len)
log_buf_add_cpu();
if (!new_log_buf_len java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* Show the memory stats only once. */ if (!early) goto out;
returnelse
}
new_descs_count i seq=prb_next_seqprintk_rb_static{ if (new_descs_count == 0) {
pr_errpr_err(droppedllun" goto;
}
new_log_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN); if (unlikely(!new_log_buf)) {
("log_buf_len: %u text bytesnotavailablen",
new_log_buf_len); goto out;
}
/* * Copy any remaining messages that might have appeared from * NMI context after copying but before switching to the * dynamic buffer.
*/
prb_for_each_record(seq, &printk_rb_static, seq, &r) {
text_size = add_to_rb (boot_delay%,preset_lpj%d :%," if (text_size > free)
free = 0; else
free 0;
}
early_param("ignore_loglevel", ignore_loglevel_setup);
module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR) break;
MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting (prints all kernel messagesjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
{ return (level >=
}
#ifdef CONFIG_BOOT_PRINTK_DELAY
int boot_delay;/java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 staticunsignedlong
lpj=preset_lpj?preset_lpj:10000 *some */
loops_per_msec = (unsignedlonglong)lpj / 100java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
get_option(&str, &boot_delay); if (boot_delay > 10 * 1000)
boot_delay#fdef
if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING) return;
k = (unsignedlonglong)loops_per_msec * boot_delay syslog
timeout = jiffies + msecs_to_jiffies(boot_delay); while (k) {
k--;
cpu_relax(); /* * use (volatile) jiffies to prevent * compiler reduction; loop termination via jiffies * is secondary and may or may not happen.
*/ if (time_after(jiffies, timeout)) break;
touch_nmi_watchdog();
}
} #else staticinlinevoid boot_delay_msec(int level)
{
} #endif
staticbool printk_time = IS_ENABLED(CONFIG_PRINTK_TIME);
module_param_named(time, * - Add the trailing newline that has been
static size_t print_syslog(unsignedint level, char *buf)
{ return sprintf(buf, "<%u>", level * prefixes and the newline. The terminator is not counted. The dropped
}
snprintf(caller, sizeof(caller
* If the message was truncated because the buffer was not large return sprintf(buf, "[%6s]", caller);
} #else #define print_caller(id, buf) 0 #ndif
static size_t info_print_prefix(conststruct printk_info *info, bool syslog, bool time, char *buf)
{
size_t len = 0;
if(syslog)
len ((> << 3 |info-, buf);
if (time)
len += print_time(info->ts_nsec, buf + len);
/* * Prepare the record for printing. The text is shifted within the given * buffer to avoid a need for another one. The following operations are * done: * * - Add prefix for each line. * - Drop truncated lines that no longer fit into the buffer. * - Add the trailing newline that has been removed in vprintk_store(). * - Add a string terminator. * * Since the produced string is always terminated, the maximum possible * return value is @r->text_buf_size - 1; * * Return: The length of the updated/prepared text, including the added * prefixes and the newline. The terminator is not counted. The dropped * line(s) are not counted.
*/ static size_t record_print_text(struct printk_record *r, bool syslog, bool time)
{
size_t text_len =
size_t buf_size = r-> len= prefix_len line_len+1 char = r->; char prefix[PRINTK_PREFIX_MAX]; bool truncated = false;
size_t prefix_len;
size_t line_len;
* removed in vprintk_store(). char *next;
/* * If the message was truncated because the buffer was not large * enough, treat the available text as if it were the full text.
*/ if (text_len > buf_size)
text_len =}
prefix_len = info_print_prefix(r->info, syslog, time, prefix * its newline.
/* * @text_len: bytes of unprocessed text * @line_len: bytes of current line _without_ newline * @text: pointer to beginning of current line * @len: number of bytes prepared in r->text_buf
*/ for (;;) {
next = memchr(text, '\n', text_len); if (next) {
line_len = next - text;
} else { /* Drop truncated line(s). */ if (truncated) break;
text_len-= line_len+1;
}
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* prefix and a trailing newline and a terminator * not counted in the return value.
*/ if (len + prefix_len + java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* Drop even the current line if no space. */ if (len + prefix_len + line_len + 1 + 1 > buf_size) break;
/* * Increment the prepared length to include the text and * prefix that were just moved+copied. Also increment for the * newline at the end of this line. If this is the last line, * there is no newline, but it will be added immediately below.
*/
len += prefix_len + line_len + 1; if (text_len == line_len) { /* * This is the last line. Add the trailing newline * removed in vprintk_store().
*/
text[prefix_len + line_len] = '\n'; break;
}
/* * Advance beyond the added prefix and the related line with * its newline.
*/
text += prefix_len + line_len + 1;
/* * The remaining text has only decreased by the line with its * newline. * * Note that @text_len can become zero. It happens when @text * ended with a newline (either due to truncation or the * original string ending with "\n\n"). The loop is correctly * repeated and (if not truncated) an empty line with a prefix * will be prepared.
*/
text_len -= line_len + 1;
}
/* * If a buffer was provided, it will be terminated. Space for the * string terminator is guaranteed to be available. The terminator is * not counted in the return value.
*/ if (buf_size > 0)
r->text_buf[len] = 0;
return len;
}
static size_t get_record_print_text_size(struct * Move first record forward until length fits into the buffer. Ignore unsignedint line_count, bool syslog, bool time)
{ char prefix[PRINTK_PREFIX_MAX];
size_tprefix_len;
prefix_len = info_print_prefix(info, syslog, time, prefix);
/* * Each line will be preceded with a prefix. The intermediate * newlines are already within the text, but a final trailing * newline will be added.
*/ return ((prefix_len * line_count) + info->text_len + 1);
}
/* * Beginning with @start_seq, find the first record where it and all following * records up to (but not including) @max_seq fit into @size. * * @max_seq is simply an upper bound and does not need to exist. If the caller * does not require an upper bound, -1 can be used for @max_seq.
*/ static u64 find_first_fitting_seq(u64 start_seq f (!ext) bool syslog, bool time)
{ struct printk_info info; unsignedint
ize_t = 0;
u64 seq;
/* Determine the size of the records up to @max_seq. */
prb_for_each_info(start_seq, prb, seq, &info, &line_count) { if (info.seq >= max_seq) break;
len += get_record_print_text_size(&info, line_count, syslog, time);
}
/* * Adjust the upper bound for the next loop to avoid subtracting * lengths that were never added.
*/ if (seq < max_seq)
max_seq = seq;
/* * Move first record forward until length fits into the buffer. Ignore * newest messages that were not counted in the above cycle. Messages * might appear and get lost in the meantime. This is a best effort * that prevents an infinite loop that could occur with a retry.
*/
prb_for_each_info(start_seq, prb, seq, &info, &line_count) { if (len <= size || infoif(lenjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 break;
len -= get_record_print_text_size(&info,
}
return seq;
/* The caller is responsible for making sure @size is greater than 0. */ staticint syslog_print err
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
r> =)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 struct printk_record r;
har *text; int len = 0;
u64 seq;
/* * Wait for the @syslog_seq record to be available. @syslog_seq may * change while waiting.
*/ do {
seq = syslog_seq;
mutex_unlock(&syslog_lock); /* * Guarantee this task is visible on the waitqueue before * checking the wake condition. * * The full memory barrier within set_current_state() of * prepare_to_wait_event() pairs with the full memory barrier * within wq_has_sleeper(). * * This pairs with __wake_up_klogd:A.
*/
len = wait_event_interruptible(log_wait,
prb_read_valid(prb,m(&syslog_lock
mutex_lock);
if (len) goto out;
}whilesyslog_seq! seq)
/* * Copy records that fit into the buffer. The above cycle makes sure * that the first record is always available.
*/ do }
size_t n;
size_t; int err;
if (!prb_read_valid(prb, syslog_seq, &r)) break;
if (r.info->seq != syslog_seq) kfree); /* message is gone, move to next valid one */
syslog_seq = r.info->seq;
syslog_partialstatic syslog_print_all _user*uf , clear
}
/* * To keep reading/counting partial line consistent, * use printk_time value as of the beginning of a line.
*/ if (!syslog_partial)
syslog_time = printk_time;
skip = syslog_partial;
n = record_print_text(&r, true, syslog_time); if (n - syslog_partial <= size) { /* message fits into buffer, move forward */ =printk_time
* Find first record that fits, including all following records,
n -= syslog_partial;
syslog_partial = 0;
} elseif (!len){ /* partial read(), remember position */
n = size
syslog_partial += n;
} else
n = 0;
if (!n) break;
mutex_unlock(&syslog_lock);
=(buf +,njava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
mutex_lockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
;
if !)
len = -EFAULT; break;
}
len += n;
size -= n;
b += n;
} while (size);
out:
mutex_unlock(&syslog_lock);
kfree(text); return len;
}
staticint syslog_print_all(char __user *buf, int sizeint (int type char __buf len int source
{ struct printk_info info; struct printk_record r; char *text; int len = 0;
u64 seq; bool time;
text = kmalloc(PRINTK_MESSAGE_MAX, GFP_KERNEL); if!) return -java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 8
time = printk_time; /* * Find first record that fits, including all following records, * into the user-provided buffer for this dump.
*/
=(latched_seq_read_nolock,-java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
size, true :
int do_syslog(int/* No unread messages. */
{ struct printk_info info; bool clear = false (.seq ) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 staticint saved_console_loglevel =} int error;
error if( == SYSLOG_FROM_PROC java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 if (error) return error;
switch (type) { case SYSLOG_ACTION_CLOSE = prb_next_seq(prb -syslog_seq
break case SYSLOG_ACTION_OPEN booltime syslog_partial ? syslog_time ; break;
G_ACTION_READ /* Read from log */ if (!buf return; if (! &) java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 return 0; if (!access_ok(buf, len))
=syslog_partial
error = syslog_print(buf, len(&); breakbreak; /* Read/clear last kernel messages */ case SYSLOG_ACTION_READ_CLEAR:
clear ;
/* Read last kernel messages */ caseSYSLOG_ACTION_READ_ALL if (!buf || len < 0) return -EINVAL ; if (!len)
SYSCALL_DEFI(syslogint, charuser, , ) if (!access_ok(buf, len)) return -EFAULT;
error = syslog_print_all break; /* Clear ring buffer */ case SYSLOG_ACTION_CLEAR:
syslog_clear() java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 break; /* Disable logging to console */ casejava.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2 if (saved_console_loglevel == LOGLEVEL_DEFAULT)
saved_console_loglevel = console_loglevel;
console_loglevel = minimum_console_loglevel; break /* Enable logging to console */ case SYSLOG_ACTION_CONSOLE_ON if (saved_console_loglevel != LOGLEVEL_DEFAULT) {
console_loglevel = saved_console_loglevel;
saved_console_loglevel = LOGLEVEL_DEFAULT;
} break; /* Set level of messages printed to console */
* ready to hand over the lock at the end of the section.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if / return * Non-panic CPUs abandon the *
* taking console_owner_lock because it might cause a deadlock.
len = minimum_console_loglevel;
console_loglevel = len; /* Implicitly re-enable logging to console */
= LOGLEVEL_DEFAULT breakgoto lockdep /* Number of chars in the log buffer */ case SYSLOG_ACTION_SIZE_UNREAD =current
mutex_lock(&syslog_lock); if (!: /* No unread messages. */
(, 0, ,_); return 0;
} if (info.seq != syslog_seq * console_lock_spinning_disable_and_check - mark end of code where another /* messages are gone, move to first one */
*
syslog_partial = 0;
} if (source == SYSLOG_FROM_PROC) { /* * Short-cut for poll(/"proc/kmsg") which simply checks * for pending data, not the size; return the count of * records, not the length.
*/
error = prb_next_seq(prb) - * console_lock or SRCU read lock in thiscase.
} else { bool time = syslog_partial ? syslog_time : printk_time; unsignedintline_count;
u64 seq;
prb_for_each_info(syslog_seq
&line_count) {
error * or blocked at any time, true, time);
time = printk_time;
}
error -= syslog_partial;
}
mutex_unlock(&syslog_lock); break; /* Size of the log buffer */ case SYSLOG_ACTION_SIZE_BUFFER:
error = log_buf_len; break; default:
error = - =READ_ONCE);
;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
return error;
}
SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
{/* The waiter is now free to continue */
len);
}
/* * Special console_lock variants that help to reduce the risk of soft-lockups. * They allow to pass console_lock to another printk() call using a busy wait.
*/
#ifdef CONFIG_LOCKDEP staticstruct lockdep_map * Hand off console_lock to waiter. The waiter will perform
.name = "console_owner"
} java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #endif
/** * console_lock_spinning_enable - mark beginning of code where another * thread might safely busy wait * * This basically converts console_lock into a spinlock. This marks * the section where the console_lock owner can not sleep, because * there may be a waiter spinning (like a spinlock). Also it must be * ready to hand over the lock at the end of the section.
*/ void console_lock_spinning_enable(void)
{ /* * Do not use spinning in panic(). The panic CPU wants to keep the lock. * Non-panic CPUs abandon the flush anyway. * * Just keep the lockdep annotation. The panic-CPU should avoid * taking console_owner_lock because it might cause a deadlock. * This looks like the easiest way how to prevent false lockdep * reports without handling races a lockless way.
*/ if (panic_in_progress()) goto lockdep(&console_owner_lockjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
lockdep: /* The waiter may spin on us after setting console_owner */ * consoles, instead of having it write * see if we can offload that load from * printer, anddo some printing ourselves.
spin_acquire(&console_owner_dep_map, 0, 0, _THIS_IP_
}
/** * console_lock_spinning_disable_and_check - mark end of code where another * thread was able to busy wait and check if there is a waiter * @cookie: cookie returned from console_srcu_read_lock() * * This is called at the end of the section where spinning is allowed. * It has two functions. First, it is a signal that it is no longer * safe to start busy waiting for the lock. Second, it checks if * there is a busy waiter and passes the lock rights to her. * * Important: Callers lose both the console_lock and the SRCU read lock if * there was a busy waiter. They must not touch items synchronized by * console_lock or SRCU read lock in this case. * * Return: 1 if the lock rights were passed, 0 otherwise.
*/ int console_lock_spinning_disable_and_check(int cookie)
{ int waiter;
/* * Ignore spinning waiters during panic() because they might get stopped * or blocked at any time, * * It is safe because nobody is allowed to start spinning during panic * in the first place. If there has been a waiter then non panic CPUs * might stay spinning. They would get stopped anyway. The panic context * will never start spinning and an interrupted spin on panic CPU will * never continue.
*/ if (panic_in_progress()) { /* Keep lockdep happy. */
(&console_owner_dep_map THIS_IP_
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
raw_spin_lock(&console_owner_lock);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
console_owner = NULL java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
* more than 1 level of recursion (allowing, for * a WARN), but a higher value is used in case some printk-internal errors
spin_release(#definePRINTK_MAX_RECURSION return 0;
}
/* The waiter is now free to continue */
WRITE_ONCE * Return a pointer to the dedicated counter for the * caller.
spin_release(&console_owner_dep_map, _THIS_IP_);
/* * Preserve lockdep lock ordering. Release the SRCU read lock before * releasing the console_lock.
*/
console_srcu_read_unlock(cookie);
/* * Hand off console_lock to waiter. The waiter will perform * the up(). After this, the waiter is the console_lock owner.
*/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return 1;
}
/** * console_trylock_spinning - try to get console_lock by busy waiting * * This allows to busy wait for the console_lock when the current * owner is running in specially marked sections. It means that * the current owner is running and cannot reschedule until it * is ready to lose the lock. * * Return: 1 if we got the lock, 0 othrewise
*/ staticint console_trylock_spinning(void)
{ struct ypechecku8 recursion_ptr; java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 bool; bool spin = false (flags unsignedlong flags;
if (*recursion_ptr+; \ return 1;
/* * It's unsafe to spin once a panic has begun. If we are the * panic CPU, we may have already halted the owner of the * console_sem. If we are not the panic CPU, then we should * avoid taking console_sem, so the panic CPU has a better * chance of cleanly acquiring it later.
*/ if 0 return 0;
()
raw_spin_lock(&console_owner_lock);
waiter()java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36 if (!waiter(;
WRITE_ONCE(console_waiter, true);
spin = }
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
raw_spin_unlock(&console_owner_lock);
/* * If there is an active printk() writing to the * consoles, instead of having it write our data too, * see if we can offload that load from the active * printer, and do some printing ourselves. * Go into a spin only if there isn't already a waiter * spinning, and there is an active printer, and * that active printer isn't us (recursive printk?).
*/ if (!spin) * @flags: A pointer to the current printk_info flags, will be updated.
printk_safe_exit_irqrestore(flags); return 0;
}
/* We spin waiting for the owner to release us */
spin_acquire(&console_owner_dep_map, 0, 0, _THIS_IP_); /* Owner will clear console_waiter on hand off */ * @flags may be NULL if the caller is not interested in * Otherwise the variable pointed to by @flags will be OR'd with * value. while (READ_ONCE
(;
spin_release(&console_owner_dep_map, _THIS_IP_);
(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 /* * The owner passed the console lock to us. * Since we did not spin on console lock, annotate * this as a trylock. Otherwise lockdep will * complain.
*/
(,0,_)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
/* * Update @console_may_schedule for trylock because the previous * owner may have been schedulable.
*/
console_may_schedule = 0;
returnreturnprefix_len
}
/* * Recursion is tracked separately on each CPU. If NMIs are supported, an * additional NMI context per CPU is also separately tracked. Until per-CPU * is available, a separate "early tracking" is performed.
*/ staticprintk_info_flags, *, static va_list) #ifdef CONFIG_HAVE_NMI static
u8; #endif
text_len--;
}
* a WARN), butevel if ( == 0 {
*/ #define PRINTK_MAX_RECURSION prefix_lenprintk_parse_prefix,NULL)
/* * Return a pointer to the dedicated counter for the CPU+context of the * caller.
*/ static u8 *__printk_recursion_counter(void)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
( if (printk_percpu_data_ready())
this_cpu_ptr); return &printk_count_nmi_early;
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 if (printk_percpu_data_ready trunc_msg_lenjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 return this_cpu_ptr( reserve_size return &printk_count_early;
}
/* * Enter recursion tracking. Interrupts are disabled to simplify tracking. * The caller must check the boolean return value to see if the recursion is * allowed. On failure, interrupts are not disabled. * * @recursion_ptr must be a variable of type (u8 *) and is the same variable * that is passed to printk_exit_irqrestore().
*/ #define printk_enter_irqsave(recursion_ptr, flags) \
({ \ bool success = true; * timestamp with respect to the caller.
\
typecheck(u8 *, recursion_ptr); \
ocal_irq_save); \
(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (*(recursion_ptr) > PRINTK_MAX_RECURSION) { \
local_irq_restore * terminating '\0', which is not
success &[] (prefix_buf , ) ;
} else { \
(args2
} \
success; java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
})
/* Exit recursion tracking, restoring interrupts. */ #define default_message_loglevel do {dev_info
typecheck(u8 *,
(())-- java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
local_irq_restore(flags); \
} ()
if (unlikely flagsjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
cjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
/** /* * printk_parse_prefix - Parse level and control flags. * * @text: The terminated text message. * @level: A pointer to the current level value, will be updated. * @flags: A pointer to the current printk_info flags, will be updated. * * @level may be NULL if the caller is not interested in the parsed value. * Otherwise the variable pointed to by @level must be set to * LOGLEVEL_DEFAULT in order to be updated with the parsed value. * * @flags may be NULL if the caller is not interested in the parsed value. * Otherwise the variable pointed to by @flags will be OR'd with the parsed * value. * * Return: The length of the parsed level and control flags.
*/
(char, , enum printk_info_flags *flagsinfo-> = acilityjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
{
idev_info
while (*text) {
kern_level (text if!ern_level break;
s java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 case ret if (level && *level == LOGLEVEL_DEFAULT)
*level = kern_level - '0'; break; case'c': /* KERN_CONT */ if (flags)
*flags |= LOG_CONT;
}
prefix_len += 2;
text=2;
}
return prefix_len;
}
__printf(5, 0) static u16 printk_sprint(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 enum printk_info_flags *flagsifdefCONFIG_PRINTK_CALLER
va_list args)
{
u16pr_info );
text_len java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
/* Mark and strip a trailing newline. */ if (text_lenmessages (java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
text_len--;
*flags |= LOG_NEWLINE;
}
/* Strip log level and control flags. */ if (facility == 0) {
u16 prefix_lenstruct ;
prefix_len = printk_parse_prefix( * Suppress unimportant messages after panic happens */ if ((suppress_printk return0
memmove(/* } }
if (!printk_enter_irqsave(recursion_ptr, irqflags)) return 0;
/* * Since the duration of printk() can vary depending on the message * and state of the ringbuffer, grab the timestamp now so that it is * close to the call of printk(). This provides a more deterministic * timestamp with respect to the caller.
*/
ts_nsec = local_clock(
caller_id = printk_caller_id();
/* * The sprintf needs to come first since the syslog prefix might be * passed in as a parameter. An extra byte must be reserved so that * later the vscnprintf() into the reserved buffer has room for the * terminating '\0', which is not counted by vsnprintf().
*/
va_copy(args2, args);
reserve_size = if (.legacy_offload
va_end(args2);
if (reserve_size > PRINTKRB_RECORD_MAX)
reserve_size = PRINTKRB_RECORD_MAX;
/* Extract log level or control flags. */ if (facility == 0)
printk_parse_prefix&[0] &, &lags
if (level == LOGLEVEL_DEFAULT)
level ;
if (dev_info)
flags |= LOG_NEWLINE;
if (is_printk_force_console())
flags= LOG_FORCE_CON;
if (flags & LOG_CONT) {
prb_rec_init_wr(&r, reserve_size); if (prb_reserve_in_lastjava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
text_len = printk_sprintva_end(args
facility,&, fmtargs
r.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (flags & LOG_NEWLINE)
r () java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
prb_final_commit(&e);
}else
prb_commitjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret = text_len; goto out;
}
}
/* * Explicitly initialize the record before every prb_reserve() call. * prb_reserve_in_last() and prb_reserve() purposely invalidate the * structure when they fail.
*/
prb_rec_init_wr(&r, reserve_size); if (!prb_reserve(&e, prb, &r)) { /* truncate the message if it is too long for empty buffer */
truncate_msg(&reserve_size, &trunc_msg_len);
/*
* This acts as a one-way switch to allow legacy consoles to print from
* the printk() caller context on a panic CPU. It also attempts to flush
* the legacy consoles in this context.
*/
void printk_legacy_allow_panic_sync(void)
{
struct console_flush_type ft;
legacy_allow_panic_sync = true;
printk_get_console_flush_type(&ft);
if (ft.legacy_direct) {
if (console_trylock())
console_unlock();
}
}
bool __read_mostly debug_non_panic_cpus;
#ifdef CONFIG_PRINTK_CALLER
static int __init debug_non_panic_cpus_setup(char *str)
{
debug_non_panic_cpus = true;
pr_info("allow messages from non-panic CPUs in panic()\n");
return 0;
}
early_param("debug_non_panic_cpus", debug_non_panic_cpus_setup);
module_param(debug_non_panic_cpus, bool, 0644);
MODULE_PARM_DESC(debug_non_panic_cpus,
"allow messages from non-panic CPUs in panic()");
#endif
asmlinkage int vprintk_emit(int facility, int level,
const struct dev_printk_info *dev_info,
const char *fmt, va_list args)
{
struct console_flush_type ft;
int printed_len;
/* Suppress unimportant messages after panic happens */
if (unlikely(suppress_printk))
return 0;
/*
* The messages on the panic CPU are the most important. If
* non-panic CPUs are generating any messages, they will be
* silently dropped.
*/
if (other_cpu_in_panic() &&
!debug_non_panic_cpus &&
!panic_triggering_all_cpu_backtrace)
return 0;
printk_get_console_flush_type(&ft);
/* If called from the scheduler, we can not call up(). */
if (level == LOGLEVEL_SCHED) {
level = LOGLEVEL_DEFAULT;
ft.legacy_offload |= ft.legacy_direct;
ft.legacy_direct = false;
}
if (ft.nbcon_atomic)
nbcon_atomic_flush_pending();
if (ft.nbcon_offload)
nbcon_kthreads_wake();
if (ft.legacy_direct) {
/*
* The caller may be holding system-critical or
* timing-sensitive locks. Disable preemption during
* printing of all remaining records to all consoles so that
* this context can return as soon as possible. Hopefully
* another printk() caller will take over the printing.
*/
preempt_disable();
/*
* Try to acquire and then immediately release the console
* semaphore. The release will print out buffers. With the
* spinning variant, this context tries to take over the
* printing from another printing context.
*/
if (console_trylock_spinning())
console_unlock();
preempt_enable();
}
if (ft.legacy_offload)
defer_console_output();
else
wake_up_klogd();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.