Hello my beloved.

2022-03-09 Thread Mrs. Latifa Rassim Mohamad
Greetings dears,

Hello my dear Good evening from here this evening, how are you doing
today? My name is Mrs.  Latifa Rassim Mohamad from Saudi Arabia, I
have something very important and serious i will like to discuss with
you privately, so i hope this is your private email?

Mrs. Latifa Rassim Mohamad.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 3/3] makedumpfile: use cycle detection when parsing the prink log_buf

2022-03-09 Thread David Wysochanski
On Mon, Mar 7, 2022 at 12:23 PM Philipp Rudo  wrote:
>
> The old printk mechanism (> v3.5.0 and < v5.10.0) had a fixed size
> buffer (log_buf) that contains all messages. The location for the next
> message is stored in log_next_idx. In case the log_buf runs full
> log_next_idx wraps around and starts overwriting old messages at the
> beginning of the buffer. The wraparound is denoted by a message with
> msg->len == 0.
>
> Following the behavior described above blindly in makedumpfile is
> dangerous as e.g. a memory corruption could overwrite (parts of) the
> log_buf. If the corruption adds a message with msg->len == 0 this leads
> to an endless loop when dumping the dmesg with makedumpfile appending
> the messages up to the corruption over and over again to the output file
> until file system is full. Fix this by using cycle detection and aboard
> once one is detected.
>
> While at it also verify that the index is within the log_buf and thus
> guard against corruptions with msg->len != 0.
>
> Fixes: 36c2458 ("[PATCH] --dump-dmesg fix for post 3.5 kernels.")
> Reported-by: Audra Mitchell 
> Suggested-by: Dave Wysochanski 
> Signed-off-by: Philipp Rudo 
> ---
>  makedumpfile.c | 42 --
>  1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/makedumpfile.c b/makedumpfile.c
> index edf128b..2738d16 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -15,6 +15,7 @@
>   */
>  #include "makedumpfile.h"
>  #include "print_info.h"
> +#include "detect_cycle.h"
>  #include "dwarf_info.h"
>  #include "elf_info.h"
>  #include "erase_info.h"
> @@ -5528,10 +5529,11 @@ dump_dmesg()
> unsigned long index, log_buf, log_end;
> unsigned int log_first_idx, log_next_idx;
> unsigned long long first_idx_sym;
> +   struct detect_cycle *dc = NULL;
> unsigned long log_end_2_6_24;
> unsigned  log_end_2_6_25;
> char *log_buffer = NULL, *log_ptr = NULL;
> -   char *idx;
> +   char *idx, *next_idx;
>

Would be clearer to call the above "next_ptr" rather than "next_idx"
(as far as I know 'index' refers to 32-bit quantities).
Same comment about the "idx" variable, maybe "ptr"?



> /*
>  * log_end has been changed to "unsigned" since linux-2.6.25.
> @@ -5679,12 +5681,47 @@ dump_dmesg()
> goto out;
> }
> idx = log_buffer + log_first_idx;
> +   dc = dc_init(idx, log_buffer, log_next);
> while (idx != log_buffer + log_next_idx) {
> log_ptr = log_from_idx(idx, log_buffer);
> if (!dump_log_entry(log_ptr, info->fd_dumpfile,
> info->name_dumpfile))
> goto out;
> -   idx = log_next(idx, log_buffer);
> +   if (dc_next(dc, (void **) _idx)) {
> +   unsigned long len;
> +   char *first;
> +
> +   /* Clear everything we have already 
> written... */
> +   ftruncate(info->fd_dumpfile, 0);
> +   lseek(info->fd_dumpfile, 0, SEEK_SET);
> +

I'm not sure I understand why you're doing this.

> +   /* ...and only write up to the corruption. */
> +   dc_find_start(dc, (void **) , );
> +   idx = log_buffer + log_first_idx;
> +   while (len) {

I don't think this is correct.  It looks like "len" is the length of
the loop segment, correct?
But don't you want to print the whole buffer until the corruption?
That means you need to print both the non-loop segment plus the loop segment.
With the 'while(len)' you're only printing # of entries == loop segment.
Look at the diagram here:
https://listman.redhat.com/archives/crash-utility/2018-July/007582.html



> +   log_ptr = log_from_idx(idx, 
> log_buffer);
> +   if (!dump_log_entry(log_ptr,
> +   info->fd_dumpfile,
> +   
> info->name_dumpfile))
> +   goto out;
> +   idx = log_next(idx, log_buffer);
> +   len--;
> +   }
> +   ERRMSG("Cycle when parsing dmesg 
> detected.\n");
> +   ERRMSG("The printk log_buf is most likely 
> corrupted.\n");
> +   ERRMSG("log_buf = 0x%lx, idx = 0x%lx\n", 
> log_buf, idx - log_buffer);
> +   close_files_for_creating_dumpfile();
> +   goto out;
> +   }
> +   

Re: [PATCH 2/3] makedumpfile: use pointer arithmetics for dump_dmesg

2022-03-09 Thread David Wysochanski
On Mon, Mar 7, 2022 at 12:23 PM Philipp Rudo  wrote:
>
> When parsing the printk buffer for the old printk mechanism (> v3.5.0+ and
> < 5.10.0) a log entry is currently specified by the offset into the
> buffer where the entry starts. Change this to use a pointers instead.
> This is done in preparation for using the new cycle detection mechanism.
>
> Signed-off-by: Philipp Rudo 
> ---
>  makedumpfile.c | 25 +++--
>  1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 7ed9756..edf128b 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -5482,13 +5482,10 @@ dump_log_entry(char *logptr, int fp, const char 
> *file_name)
>   * get log record by index; idx must point to valid message.
>   */
>  static char *
> -log_from_idx(unsigned int idx, char *logbuf)
> +log_from_idx(char *logptr, char *logbuf)

How about "log_from_ptr" since 'idx' has special name and you're
changing this to a ptr now?

>  {
> -   char *logptr;
> unsigned int msglen;
>
> -   logptr = logbuf + idx;
> -
> /*
>  * A length == 0 record is the end of buffer marker.
>  * Wrap around and return the message at the start of
> @@ -5502,14 +5499,13 @@ log_from_idx(unsigned int idx, char *logbuf)
> return logptr;
>  }
>
> -static long
> -log_next(unsigned int idx, char *logbuf)
> +static void *
> +log_next(void *_logptr, void *_logbuf)
>  {
> -   char *logptr;
> +   char *logptr = _logptr;
> +   char *logbuf = _logbuf;
> unsigned int msglen;
>
> -   logptr = logbuf + idx;
> -
> /*
>  * A length == 0 record is the end of buffer marker. Wrap around and
>  * read the message at the start of the buffer as *this* one, and
> @@ -5519,10 +5515,10 @@ log_next(unsigned int idx, char *logbuf)
> msglen = USHORT(logptr + OFFSET(printk_log.len));
> if (!msglen) {
> msglen = USHORT(logbuf + OFFSET(printk_log.len));
> -   return msglen;
> +   return logbuf + msglen;
> }
>
> -   return idx + msglen;
> +   return logptr + msglen;
>  }
>
>  int
> @@ -5530,11 +5526,12 @@ dump_dmesg()
>  {
> int log_buf_len, length_log, length_oldlog, ret = FALSE;
> unsigned long index, log_buf, log_end;
> -   unsigned int idx, log_first_idx, log_next_idx;
> +   unsigned int log_first_idx, log_next_idx;
> unsigned long long first_idx_sym;
> unsigned long log_end_2_6_24;
> unsigned  log_end_2_6_25;
> char *log_buffer = NULL, *log_ptr = NULL;
> +   char *idx;
>
> /*
>  * log_end has been changed to "unsigned" since linux-2.6.25.
> @@ -5681,8 +5678,8 @@ dump_dmesg()
> ERRMSG("Can't open output file.\n");
> goto out;
> }
> -   idx = log_first_idx;
> -   while (idx != log_next_idx) {
> +   idx = log_buffer + log_first_idx;
> +   while (idx != log_buffer + log_next_idx) {

I would find another name other than "idx" here, maybe just "ptr"?


> log_ptr = log_from_idx(idx, log_buffer);
> if (!dump_log_entry(log_ptr, info->fd_dumpfile,
> info->name_dumpfile))
> --
> 2.35.1
>


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec