[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

filesys.c |   37 ++++++++++++++++++++++++++++---------

## Package
crash

## Files to modify
- filesys.c

## Target Source Code

### filesys.c

#### region() [lines 481-587]
```c
					break;
			}
		} while (i != start);
	}

	return searchdirs;
}

static int
build_kernel_directory(char *buf)
{
	char *p1, *p2;

	if (!strstr(kt->proc_version, "Linux version "))
		return FALSE;

	BZERO(buf, BUFSIZE);
	sprintf(buf, "/lib/modules/");

	p1 = &kt->proc_version[strlen("Linux version ")];
	p2 = &buf[strlen(buf)];

	while (*p1 != ' ')
		*p2++ = *p1++;

	strcat(buf, "/build");
	return TRUE;
}

static int
redhat_kernel_directory_v1(char *buf)
{
	char *p1, *p2;

	if (!strstr(kt->proc_version, "Linux version "))
		return FALSE;

	BZERO(buf, BUFSIZE);
	sprintf(buf, "/usr/src/redhat/BUILD/kernel-");

	p1 = &kt->proc_version[strlen("Linux version ")];
	p2 = &buf[strlen(buf)];

	while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))
		*p2++ = *p1++;

	strcat(buf, "/linux");
	return TRUE;
}

static int
redhat_kernel_directory_v2(char *buf)
{
        char *p1, *p2;

        if (!strstr(kt->proc_version, "Linux version "))
                return FALSE;

        BZERO(buf, BUFSIZE);
        sprintf(buf, "/usr/src/redhat/BUILD/kernel-");

        p1 = &kt->proc_version[strlen("Linux version ")];
        p2 = &buf[strlen(buf)];

        while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))
                *p2++ = *p1++;

        strcat(buf, "/linux-");

        p1 = &kt->proc_version[strlen("Linux version ")];
        p2 = &buf[strlen(buf)];

        while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))
                *p2++ = *p1++;

        return TRUE;
}

static int
redhat_debug_directory(char *buf)
{
        char *p1, *p2;

        if (!strstr(kt->proc_version, "Linux version "))
                return FALSE;

        BZERO(buf, BUFSIZE);
        sprintf(buf, "%s/", pc->redhat_debug_loc);

        p1 = &kt->proc_version[strlen("Linux version ")];
        p2 = &buf[strlen(buf)];

        while (*p1 != ' ')
                *p2++ = *p1++;

        return TRUE;
}

/*
 *  If a namelist was not entered, presume we're using the currently-running
 *  kernel.  Read its version string from /proc/version, and then look in
 *  the search directories for a kernel with the same version string embedded
 *  in it.
 */
static int
find_booted_kernel(void)
```

#### find_booted_kernel() [lines 116-197]
```c
			}
			if (!pc->dumpfile)
				check_live_arch_mismatch();
			if (!find_booted_kernel())
	                	program_usage(SHORT_FORM);
		}

		if (!pc->dumpfile) {
			pc->flags |= LIVE_SYSTEM;
			get_live_memory_source();
		}

		if ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0)
			error(FATAL, "%s: %s\n", pc->namelist, strerror(errno));
		else {
			close(pc->nfd);
			pc->nfd = -1;
		}

		if (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {
			memory_source_init();
			match_proc_version();
		}

	}

	memory_source_init();

	if (ACTIVE())
		proc_kcore_init(fp, UNUSED);

	if (CRASHDEBUG(1)) {
		fprintf(fp, "readmem: %s() ", readmem_function_name());
		if (ACTIVE()) {
			fprintf(fp, "-> %s ", pc->live_memsrc);
			if (pc->flags & MEMMOD)
				fprintf(fp, "(module)");
			else if (pc->flags & CRASHBUILTIN)
				fprintf(fp, "(built-in)");
		}
		fprintf(fp, "\n");
	}
}

/*
 *  Do whatever's necessary to handle the memory source.
 */
static void
memory_source_init(void)
{
	if (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))
		return;

	if (pc->flags & KERNEL_DEBUG_QUERY)
		return;

        if (LOCAL_ACTIVE()) {
		if (pc->mfd != -1)  /* already been here */
			return;

		if (!STREQ(pc->live_memsrc, "/dev/mem") &&
		     STREQ(pc->live_memsrc, pc->memory_device)) {
			if (memory_driver_init())
				return;

			error(INFO, "cannot initialize crash memory driver\n");
			error(INFO, "using /dev/mem\n\n");
			pc->flags &= ~MEMMOD;
			pc->flags |= DEVMEM;
			pc->readmem = read_dev_mem;
			pc->writemem = write_dev_mem;
			pc->live_memsrc = "/dev/mem";
		}

		if (STREQ(pc->live_memsrc, "/dev/mem")) {
	                if ((pc->mfd = open("/dev/mem", O_RDWR)) < 0) {
	                        if ((pc->mfd = open("/dev/mem", O_RDONLY)) < 0)
	                                error(FATAL, "/dev/mem: %s\n",
	                                        strerror(errno));
	                } else
	                        pc->flags |= MFD_RDWR;
		} else if (STREQ(pc->live_memsrc, "/proc/kcore")) {
```

## Upstream Fix
```diff
---
 filesys.c |   37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

--- a/filesys.c
+++ b/filesys.c
@@ -530,6 +530,8 @@ static int
 find_booted_kernel(void)
 {
 	char kernel[BUFSIZE];
+	char *kernel_unpacked;
+	char *real_kernel;
 	char buffer[BUFSIZE];
 	char **searchdirs;
 	int i, preferred, wrapped;
@@ -579,16 +581,25 @@ find_booted_kernel(void)
 			sprintf(kernel, "%s%s", searchdirs[i], dp->d_name);

 			if (mount_point(kernel) ||
-			    !file_readable(kernel) ||
-                            !is_elf_file(kernel))
+			    !file_readable(kernel))
 				continue;

+			if (is_compressed_kernel(kernel, &kernel_unpacked))
+				real_kernel = kernel_unpacked;
+			else {
+				kernel_unpacked = NULL;
+				real_kernel = kernel;
+			}
+
 			if (CRASHDEBUG(1))
 				fprintf(fp, "find_booted_kernel: check: %s\n",
 					kernel);

-			found = match_file_string(kernel, kt->proc_version, buffer);
-
+			if (!is_elf_file(real_kernel))
+				continue;
+
+			found = match_file_string(real_kernel, kt->proc_version, buffer);
+
 			if (found)
 				break;
 	        }
@@ -599,17 +610,25 @@ find_booted_kernel(void)
 	build_searchdirs(DESTROY, NULL);

 	if (found) {
-                if ((pc->namelist = (char *)malloc
-		    (strlen(kernel)+1)) == NULL)
+		if ((pc->namelist_orig = strdup(kernel)) == NULL)
+			error(FATAL, "booted kernel real name malloc: %s\n",
+				strerror(errno));
+		else if ((pc->namelist = strdup(real_kernel)) == NULL)
 			error(FATAL, "booted kernel name malloc: %s\n",
 				strerror(errno));
-                else {
-                        strcpy(pc->namelist, kernel);
+                else
 			if (CRASHDEBUG(1))
 				fprintf(fp, "find_booted_kernel: found: %s\n",
 					pc->namelist);
+			if (kernel_unpacked)
+				free(kernel_unpacked);
                         return TRUE;
-                }
+	}
+
+	if (kernel_unpacked) {
+		remove(kernel_unpacked);
+		if (kernel_unpacked)
+			free(kernel_unpacked);
 	}

 	error(INFO,

```

Generate a backported patch for the SUSE target version.

[Assistant]
---
 filesys.c |   37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

--- a/filesys.c
+++ b/filesys.c
@@ -530,6 +530,8 @@ static int
 find_booted_kernel(void)
 {
 	char kernel[BUFSIZE];
+	char *kernel_unpacked;
+	char *real_kernel;
 	char buffer[BUFSIZE];
 	char **searchdirs;
 	int i, preferred, wrapped;
@@ -579,16 +581,25 @@ find_booted_kernel(void)
 			sprintf(kernel, "%s%s", searchdirs[i], dp->d_name);

 			if (mount_point(kernel) ||
-			    !file_readable(kernel) ||
-                            !is_elf_file(kernel))
+			    !file_readable(kernel))
 				continue;

+			if (is_compressed_kernel(kernel, &kernel_unpacked))
+				real_kernel = kernel_unpacked;
+			else {
+				kernel_unpacked = NULL;
+				real_kernel = kernel;
+			}
+
 			if (CRASHDEBUG(1))
 				fprintf(fp, "find_booted_kernel: check: %s\n",
 					kernel);

-			found = match_file_string(kernel, kt->proc_version, buffer);
-
+			if (!is_elf_file(real_kernel))
+				continue;
+
+			found = match_file_string(real_kernel, kt->proc_version, buffer);
+
 			if (found)
 				break;
 	        }
@@ -599,17 +610,25 @@ find_booted_kernel(void)
 	build_searchdirs(DESTROY, NULL);

 	if (found) {
-                if ((pc->namelist = (char *)malloc
-		    (strlen(kernel)+1)) == NULL)
+		if ((pc->namelist_orig = strdup(kernel)) == NULL)
+			error(FATAL, "booted kernel real name malloc: %s\n",
+				strerror(errno));
+		else if ((pc->namelist = strdup(real_kernel)) == NULL)
 			error(FATAL, "booted kernel name malloc: %s\n",
 				strerror(errno));
-                else {
-                        strcpy(pc->namelist, kernel);
+                else
 			if (CRASHDEBUG(1))
 				fprintf(fp, "find_booted_kernel: found: %s\n",
 					pc->namelist);
+			if (kernel_unpacked)
+				free(kernel_unpacked);
                         return TRUE;
-                }
+	}
+
+	if (kernel_unpacked) {
+		remove(kernel_unpacked);
+		if (kernel_unpacked)
+			free(kernel_unpacked);
 	}

 	error(INFO,


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

From: Petr Tesarik <ptesarik@suse.cz>

## Package
crash

## Files to modify
- symbols.c

## Target Source Code

### symbols.c

#### symtab_init() [lines 161-255]
```c
 *  sorts, and stores, them in a static table for quick reference.
 */
void
symtab_init(void)
{
	char **matching;
  	long symcount;
  	void *minisyms;
  	unsigned int size;
	asymbol *sort_x;
	asymbol *sort_y;

  	if ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL)
		error(FATAL, "cannot open object file: %s\n", pc->namelist);

  	if (!bfd_check_format_matches(st->bfd, bfd_object, &matching))
		error(FATAL, "cannot determine object file format: %s\n",
			pc->namelist);
	/*
	 *  Check whether the namelist is a kerntypes file built by
	 *  dwarfextract, which places a magic number in e_version.
	 */
	if (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)
		pc->flags |= KERNTYPES;

	if (pc->flags & SYSMAP) {
		bfd_map_over_sections(st->bfd, section_header_info,
			VERIFY_SECTIONS);
		if ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==
		    (NO_SEC_LOAD|NO_SEC_CONTENTS)) {
			error(INFO, "%s: no text and data contents\n",
				pc->namelist);
			error(FATAL, pc->flags & SYSMAP_ARG ?
				DEBUGINFO_ERROR_MESSAGE1 :
				DEBUGINFO_ERROR_MESSAGE2);
		}
		store_sysmap_symbols();
		return;
	} else if (LKCD_KERNTYPES())
		error(FATAL, "%s: use of kerntypes requires a system map\n",
			pc->namelist);

	/*
	 *  Pull a bait-and-switch on st->bfd if we've got a separate
         *  .gnu_debuglink file that matches the CRC. Not done for kerntypes.
	 */
	if (!(LKCD_KERNTYPES()) &&
	    !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {
		if (!check_gnu_debuglink(st->bfd))
			no_debugging_data(FATAL);
	}

	/*
	 *  Gather references to the kernel sections.
	 */
        if ((st->sections = (struct sec *)
             malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)
                error(FATAL, "symbol table section array malloc: %s\n",
                        strerror(errno));
	BZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));
	st->first_section_start = st->last_section_end = 0;

	bfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);
	if ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==
	    (NO_SEC_LOAD|NO_SEC_CONTENTS)) {
		if (!pc->namelist_debug && !pc->debuginfo_file) {
			error(INFO, "%s: no text and data contents\n",
				pc->namelist);
			error(FATAL, DEBUGINFO_ERROR_MESSAGE2);
		}
	}

	symcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);

	if (symcount <= 0)
		no_debugging_data(FATAL);

	sort_x = bfd_make_empty_symbol(st->bfd);
	sort_y = bfd_make_empty_symbol(st->bfd);
	if (sort_x == NULL || sort_y == NULL)
		error(FATAL, "bfd_make_empty_symbol() failed\n");

	kaslr_init();

	gnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);

	store_symbols(st->bfd, FALSE, minisyms, symcount, size);

	free(minisyms);

	symname_hash_init();
	symval_hash_init();
}

/*
```

#### check_gnu_debuglink() [lines 206-232]
```c
	 */
	if (!(LKCD_KERNTYPES()) &&
	    !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {
		if (!check_gnu_debuglink(st->bfd))
			no_debugging_data(FATAL);
	}

	/*
	 *  Gather references to the kernel sections.
	 */
        if ((st->sections = (struct sec *)
             malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)
                error(FATAL, "symbol table section array malloc: %s\n",
                        strerror(errno));
	BZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));
	st->first_section_start = st->last_section_end = 0;

	bfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);
	if ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==
	    (NO_SEC_LOAD|NO_SEC_CONTENTS)) {
		if (!pc->namelist_debug && !pc->debuginfo_file) {
			error(INFO, "%s: no text and data contents\n",
				pc->namelist);
			error(FATAL, DEBUGINFO_ERROR_MESSAGE2);
		}
	}

```

## Upstream Fix
```diff
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Search debuginfo files in the original directory
References: bnc#723639

If debuginfo is in a separate file and the kernel image is compressed,
then it should be found in the same directory as the original (compressed)
image, not in the directory with the uncompressed image (TMPDIR).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 symbols.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

--- a/symbols.c
+++ b/symbols.c
@@ -183,9 +183,9 @@ symtab_init(void)
 	 *  Pull a bait-and-switch on st->bfd if we've got a separate
          *  .gnu_debuglink file that matches the CRC. Not done for kerntypes.
 	 */
-	if (!(LKCD_KERNTYPES()) &&
-	    !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {
-		if (!check_gnu_debuglink(st->bfd))
+	if (!(LKCD_KERNTYPES())) {
+		if (!check_gnu_debuglink(st->bfd) &&
+		    !(bfd_get_file_flags(st->bfd) & HAS_SYMS))
 			no_debugging_data(FATAL);
 	}

@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)
 	char *contents;
 	int crc_offset;
 	unsigned long crc32;
+	char *namelist;
 	char *dirname;
 	char *namelist_debug;
         char **matching;

+	namelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;
+
         sect = bfd_get_section_by_name(bfd, ".gnu_debuglink");
 	if (!sect) {
-		error(INFO, "%s: no .gnu_debuglink section\n", pc->namelist);
+		error(INFO, "%s: no .gnu_debuglink section\n", namelist);
 		return FALSE;
 	}

@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)
 			contents, crc32);

   	if ((pc->debuginfo_file = (char *)
-	    malloc(((strlen(pc->namelist) + strlen("/.debug/") +
+	    malloc(((strlen(namelist) + strlen("/.debug/") +
 	    + strlen(".debug") + strlen(" /usr/lib/debug/boot/ "))*10)
 	    + strlen(pc->namelist_debug ? pc->namelist_debug : " "))) == NULL)
 		error(FATAL, "debuginfo file name malloc: %s\n",
 			strerror(errno));

-	dirname = GETBUF(strlen(pc->namelist)+1);
-	strcpy(dirname, pc->namelist);
+	dirname = GETBUF(strlen(namelist)+1);
+	strcpy(dirname, namelist);

   	for (i = strlen(dirname)-1; i >= 0; i--)
     	{

```

Generate a backported patch for the SUSE target version.

[Assistant]
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Search debuginfo files in the original directory
References: bnc#723639

If debuginfo is in a separate file and the kernel image is compressed,
then it should be found in the same directory as the original (compressed)
image, not in the directory with the uncompressed image (TMPDIR).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 symbols.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

--- a/symbols.c
+++ b/symbols.c
@@ -183,9 +183,9 @@ symtab_init(void)
 	 *  Pull a bait-and-switch on st->bfd if we've got a separate
          *  .gnu_debuglink file that matches the CRC. Not done for kerntypes.
 	 */
-	if (!(LKCD_KERNTYPES()) &&
-	    !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {
-		if (!check_gnu_debuglink(st->bfd))
+	if (!(LKCD_KERNTYPES())) {
+		if (!check_gnu_debuglink(st->bfd) &&
+		    !(bfd_get_file_flags(st->bfd) & HAS_SYMS))
 			no_debugging_data(FATAL);
 	}

@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)
 	char *contents;
 	int crc_offset;
 	unsigned long crc32;
+	char *namelist;
 	char *dirname;
 	char *namelist_debug;
         char **matching;

+	namelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;
+
         sect = bfd_get_section_by_name(bfd, ".gnu_debuglink");
 	if (!sect) {
-		error(INFO, "%s: no .gnu_debuglink section\n", pc->namelist);
+		error(INFO, "%s: no .gnu_debuglink section\n", namelist);
 		return FALSE;
 	}

@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)
 			contents, crc32);

   	if ((pc->debuginfo_file = (char *)
-	    malloc(((strlen(pc->namelist) + strlen("/.debug/") +
+	    malloc(((strlen(namelist) + strlen("/.debug/") +
 	    + strlen(".debug") + strlen(" /usr/lib/debug/boot/ "))*10)
 	    + strlen(pc->namelist_debug ? pc->namelist_debug : " "))) == NULL)
 		error(FATAL, "debuginfo file name malloc: %s\n",
 			strerror(errno));

-	dirname = GETBUF(strlen(pc->namelist)+1);
-	strcpy(dirname, pc->namelist);
+	dirname = GETBUF(strlen(namelist)+1);
+	strcpy(dirname, namelist);

   	for (i = strlen(dirname)-1; i >= 0; i--)
     	{


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

main.c |    8 +-------

## Package
crash

## Files to modify
- main.c

## Target Source Code

### main.c

#### setup_environment() [lines 1080-1245]
```c

static void
setup_environment(int argc, char **argv)
{
	int i;
	char *p1;
	char buf[BUFSIZE];
	char homerc[BUFSIZE];
	char localrc[BUFSIZE];
	FILE *afp;
	char *program;

	program = argv[0];

	/*
	 *  Program output typically goes via "fprintf(fp, ...)", but the
	 *  contents of fp are modified on the fly to handle redirection
	 *  to pipes or output files.
	 */
	fp = stdout;

	if (!set_error("default")) {
		fprintf(stderr, "crash: cannot malloc error() path string\n");
		clean_exit(1);
	}

	/*
	 *  Start populating the program_context structure.  It's used so
	 *  frequently that "pc" has been declared globally to point to the
	 *  "program_context" structure.
	 */
        pc->program_name = (char *)basename(program);
	pc->program_path = program;
        pc->program_version = build_version;
	pc->program_pid = (ulong)getpid();
        pc->curcmd = pc->program_name;
        pc->flags = (HASH|SCROLL);
	pc->flags |= DATADEBUG;          /* default until unnecessary */
	pc->flags2 |= REDZONE;
/* ... 114 lines omitted ... */
	    !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {
		if ((afp = fopen(localrc, "r")) == NULL)
                        error(INFO, "cannot open %s: %s\n",
				localrc, strerror(errno));
		else if (untrusted_file(afp, localrc))
			fclose(afp);
		else {
			while (fgets(buf, BUFSIZE, afp))
				resolve_rc_cmd(buf, ALIAS_RCLOCAL);
			fclose(afp);
		}
	}

	if (STREQ(pc->editing_mode, "no_mode"))
		pc->editing_mode = "vi";

	machdep_init(SETUP_ENV);
}

```

## Upstream Fix
```diff
---
 main.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

--- a/main.c
+++ b/main.c
@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)
 	pc->flags |= READLINE;
 	pc->editing_mode = "no_mode";

-	if ((p1 = getenv("EDITOR"))) {
-		if (strstr(p1, "vi"))
-			pc->editing_mode = "vi";
-		if (strstr(p1, "emacs"))
-			pc->editing_mode = "emacs";
-	}

 	/*
 	 *  Resolve $HOME .rc file first, then the one in the local directory.
@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)
 	}

 	if (STREQ(pc->editing_mode, "no_mode"))
-		pc->editing_mode = "vi";
+		pc->editing_mode = "emacs";

 	machdep_init(SETUP_ENV);
 }

```

Generate a backported patch for the SUSE target version.

[Assistant]
---
 main.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

--- a/main.c
+++ b/main.c
@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)
 	pc->flags |= READLINE;
 	pc->editing_mode = "no_mode";

-	if ((p1 = getenv("EDITOR"))) {
-		if (strstr(p1, "vi"))
-			pc->editing_mode = "vi";
-		if (strstr(p1, "emacs"))
-			pc->editing_mode = "emacs";
-	}

 	/*
 	 *  Resolve $HOME .rc file first, then the one in the local directory.
@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)
 	}

 	if (STREQ(pc->editing_mode, "no_mode"))
-		pc->editing_mode = "vi";
+		pc->editing_mode = "emacs";

 	machdep_init(SETUP_ENV);
 }


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

From: Petr Tesarik <ptesarik@suse.cz>

## Package
crash

## Files to modify
- gdb-7.6.patch

## Upstream Fix
```diff
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Add missing includes

This fixes a compilation failure on ppc64.

---
 gdb-7.6.patch |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/gdb-7.6.patch
+++ b/gdb-7.6.patch
@@ -17,6 +17,16 @@
  	./pex-djgpp.$(objext) ./pex-msdos.$(objext)			\
  	 ./pex-unix.$(objext) ./pex-win32.$(objext)			\
  	 ./putenv.$(objext)						\
+--- gdb-7.6/sim/common/gentmap.c.orig
++++ gdb-7.6/sim/common/gentmap.c
+@@ -2,6 +2,7 @@
+
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+
+ struct tdefs {
+   char *symbol;
 --- gdb-7.6/opcodes/i386-dis.c.orig
 +++ gdb-7.6/opcodes/i386-dis.c
 @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info

```

Generate a backported patch for the SUSE target version.

[Assistant]
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Add missing includes

This fixes a compilation failure on ppc64.

---
 gdb-7.6.patch |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/gdb-7.6.patch
+++ b/gdb-7.6.patch
@@ -17,6 +17,16 @@
  	./pex-djgpp.$(objext) ./pex-msdos.$(objext)			\
  	 ./pex-unix.$(objext) ./pex-win32.$(objext)			\
  	 ./putenv.$(objext)						\
+--- gdb-7.6/sim/common/gentmap.c.orig
++++ gdb-7.6/sim/common/gentmap.c
+@@ -2,6 +2,7 @@
+
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+
+ struct tdefs {
+   char *symbol;
 --- gdb-7.6/opcodes/i386-dis.c.orig
 +++ gdb-7.6/opcodes/i386-dis.c
 @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

printf("%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\n"

## Package
crash

## Upstream Fix
```diff
diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c
--- sial-scripts-2008-02-08.orig//ps.c	2010-03-12 19:59:03.227788951 +0100
+++ sial-scripts-2008-02-08/ps.c	2010-03-12 19:59:16.690665574 +0100
@@ -192,7 +192,11 @@ string cmd;

 	printf("%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\n"
 		, t
+#if LINUX_RELEASE > 0x02061d
+		, t->real_cred->uid
+#else
 		, t->uid
+#endif
 		, t->pid
 #if LINUX_2_6_X
 		, t->parent->pid

```

Generate a backported patch for the SUSE target version.

[Assistant]
diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c
--- sial-scripts-2008-02-08.orig//ps.c	2010-03-12 19:59:03.227788951 +0100
+++ sial-scripts-2008-02-08/ps.c	2010-03-12 19:59:16.690665574 +0100
@@ -192,7 +192,11 @@ string cmd;

 	printf("%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\n"
 		, t
+#if LINUX_RELEASE > 0x02061d
+		, t->real_cred->uid
+#else
 		, t->uid
+#endif
 		, t->pid
 #if LINUX_2_6_X
 		, t->parent->pid


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

Add quirk for SLES9 LKCD header

## Package
crash

## Files to modify
- lkcd_v8.c

## Target Source Code

### lkcd_v8.c

#### lkcd_dump_init_v8_arch() [lines 90-195]
```c

#ifndef HAVE_NO_DUMP_HEADER_ASM
int
lkcd_dump_init_v8_arch(dump_header_t *dh)
{
	off_t 			ret_of;
	ssize_t 		ret_sz;
	uint32_t 		hdr_size, offset, nr_cpus;
	dump_header_asm_t 	arch_hdr;
	char 			*hdr_buf = NULL;

	ret_of = lseek(lkcd->fd, dh->dh_header_size +
			offsetof(dump_header_asm_t, dha_header_size),
			SEEK_SET);
	if (ret_of < 0) {
		perror("lseek failed in " __FILE__ ":" STR(__LINE__));
		goto err;
	}

	ret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));
	if (ret_sz != sizeof(hdr_size)) {
		perror("Reading hdr_size failed in " __FILE__ ":" STR(__LINE__));
		goto err;
	}

	ret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);
	if (ret_of < 0) {
		perror("lseek failed in " __FILE__ ":" STR(__LINE__));
		goto err;
	}

	hdr_buf = (char *)malloc(hdr_size);
	if (!hdr_buf) {
		perror("Could not allocate memory for dump header\n");
		goto err;
	}

	ret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);
	if (ret_sz != hdr_size) {
		perror("Could not read header " __FILE__ ":" STR(__LINE__));
		goto err;
	}

	/*
         * Though we have KL_NR_CPUS is 128, the header size is different
         * CONFIG_NR_CPUS might be different in the kernel. Hence, need
         * to find out how many CPUs are configured.
         */
        offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);
        nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);

	/* check for CPU overflow */
	if (nr_cpus > NR_CPUS) {
		fprintf(stderr, "CPU number too high %d (%s:%d)\n",
				nr_cpus, __FILE__, __LINE__);
		goto err;
	}

	/* parts that don't depend on the number of CPUs */
	memcpy(&arch_hdr, (void *)hdr_buf, offset);

	/* registers */
	memcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],
			nr_cpus * sizeof(struct pt_regs));
	offset += nr_cpus * sizeof(struct pt_regs);

	/* current task */
	memcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],
			nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));
	offset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);

	/* stack */
	memcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],
			nr_cpus * sizeof(&arch_hdr.dha_stack[0]));
	offset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);

	/* stack_ptr */
	memcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],
			nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));
	offset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);

	if (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {
		fprintf(stderr, "Invalid magic number for x86_64\n");
		goto err;
	}

	/*
	 * read the kernel load address on IA64 -- other architectures have
	 * no relocatable kernel at the lifetime of LKCD
	 */
#ifdef IA64
	memcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));
#endif

	memcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));

	free(hdr_buf);
	return 0;

err:
	free(hdr_buf);
	return -1;
}

#else /* architecture that has no lkcd_dump_init_v8 */
```

### Type definitions

```c
/* from lkcd_dump_v8.h */
struct pt_regs {
	long ebx;
	long ecx;
	long edx;
	long esi;
	long edi;
	long ebp;
	long eax;
	int  xds;
	int  xes;
	long orig_eax;
	long eip;
	int  xcs;
	long eflags;
	long esp;
	int  xss;
};
```

## Upstream Fix
```diff
From: Bernhard Walle <bwalle@suse.de>
Subject: [PATCH] Add quirk for SLES9 LKCD header
Patch-mainline: never

On SLES9, we have a different header on IA64:

    SLES 10:

    typedef struct __dump_header_asm {
            uint64_t            dha_magic_number;
            uint32_t            dha_version;
            uint32_t            dha_header_size;
            uint64_t            dha_pt_regs;
            struct pt_regs      dha_regs;
            uint64_t            dha_rnat;
            uint64_t            dha_pfs;
            uint64_t            dha_bspstore;
            uint32_t	        dha_smp_num_cpus;
            uint32_t	        dha_dumping_cpu;
            struct pt_regs	dha_smp_regs[NR_CPUS];
            uint64_t	        dha_smp_current_task[NR_CPUS];
            uint64_t	        dha_stack[NR_CPUS];
            uint64_t	        dha_stack_ptr[NR_CPUS];
            uint64_t            dha_kernel_addr;
    } __attribute__((packed)) dump_header_asm_t;

    SLES 9:
    typedef struct __dump_header_asm {
            uint64_t            dha_magic_number;
            uint32_t            dha_version;
            uint32_t            dha_header_size;
            uint64_t            dha_kernel_addr;
            uint64_t            dha_pt_regs;
            struct pt_regs      dha_regs;
            uint64_t            dha_rnat;
            uint64_t            dha_pfs;
            uint64_t            dha_bspstore;
            uint32_t	        dha_smp_num_cpus;
            uint32_t	        dha_dumping_cpu;
            struct pt_regs	dha_smp_regs[NR_CPUS];
            uint64_t	        dha_smp_current_task[NR_CPUS];
            uint64_t	        dha_stack[NR_CPUS];
            uint64_t	        dha_stack_ptr[NR_CPUS];
    } __attribute__((packed)) dump_header_asm_t;

That patch tries to guess if it's a SLES 9 or a SLES 10 header
at runtime.

Signed-off-by: Bernhard Walle <bwalle@suse.de>

---
 lkcd_v8.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- a/lkcd_v8.c
+++ b/lkcd_v8.c
@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh
 		goto err;
 	}

+#if IA64
+	/* SLES9 on IA64? */
+	if ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {
+		uint64_t kernel_addr;
+		kernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;
+		memmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),
+				hdr_buf + offsetof(dump_header_asm_t, dha_regs),
+				hdr_size - offsetof(dump_header_asm_t, dha_regs));
+		*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;
+	}
+#endif

 	/*
          * Though we have KL_NR_CPUS is 128, the header size is different

```

Generate a backported patch for the SUSE target version.

[Assistant]
From: Bernhard Walle <bwalle@suse.de>
Subject: [PATCH] Add quirk for SLES9 LKCD header
Patch-mainline: never

On SLES9, we have a different header on IA64:

    SLES 10:

    typedef struct __dump_header_asm {
            uint64_t            dha_magic_number;
            uint32_t            dha_version;
            uint32_t            dha_header_size;
            uint64_t            dha_pt_regs;
            struct pt_regs      dha_regs;
            uint64_t            dha_rnat;
            uint64_t            dha_pfs;
            uint64_t            dha_bspstore;
            uint32_t	        dha_smp_num_cpus;
            uint32_t	        dha_dumping_cpu;
            struct pt_regs	dha_smp_regs[NR_CPUS];
            uint64_t	        dha_smp_current_task[NR_CPUS];
            uint64_t	        dha_stack[NR_CPUS];
            uint64_t	        dha_stack_ptr[NR_CPUS];
            uint64_t            dha_kernel_addr;
    } __attribute__((packed)) dump_header_asm_t;

    SLES 9:
    typedef struct __dump_header_asm {
            uint64_t            dha_magic_number;
            uint32_t            dha_version;
            uint32_t            dha_header_size;
            uint64_t            dha_kernel_addr;
            uint64_t            dha_pt_regs;
            struct pt_regs      dha_regs;
            uint64_t            dha_rnat;
            uint64_t            dha_pfs;
            uint64_t            dha_bspstore;
            uint32_t	        dha_smp_num_cpus;
            uint32_t	        dha_dumping_cpu;
            struct pt_regs	dha_smp_regs[NR_CPUS];
            uint64_t	        dha_smp_current_task[NR_CPUS];
            uint64_t	        dha_stack[NR_CPUS];
            uint64_t	        dha_stack_ptr[NR_CPUS];
    } __attribute__((packed)) dump_header_asm_t;

That patch tries to guess if it's a SLES 9 or a SLES 10 header
at runtime.

Signed-off-by: Bernhard Walle <bwalle@suse.de>

---
 lkcd_v8.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- a/lkcd_v8.c
+++ b/lkcd_v8.c
@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh
 		goto err;
 	}

+#if IA64
+	/* SLES9 on IA64? */
+	if ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {
+		uint64_t kernel_addr;
+		kernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;
+		memmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),
+				hdr_buf + offsetof(dump_header_asm_t, dha_regs),
+				hdr_size - offsetof(dump_header_asm_t, dha_regs));
+		*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;
+	}
+#endif

 	/*
          * Though we have KL_NR_CPUS is 128, the header size is different


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

Fix "uptime" and "ps -t" for SLES9

## Package
crash

## Files to modify
- defs.h
- kernel.c
- task.c

## Target Source Code

### defs.h

#### region() [lines 633-739]
```c
#define KMOD_V2       (0x2000)
#define KALLSYMS_V2   (0x2000)
#define TVEC_BASES_V2 (0x4000)
#define GCC_3_3_3     (0x8000)
#define USE_OLD_BT   (0x10000)
#define USE_OPT_BT   (0x10000)
#define ARCH_XEN     (0x20000)
#define NO_IKCONFIG  (0x40000)
#define DWARF_UNWIND (0x80000)
#define NO_DWARF_UNWIND       (0x100000)
#define DWARF_UNWIND_MEMORY   (0x200000)
#define DWARF_UNWIND_EH_FRAME (0x400000)
#define DWARF_UNWIND_CAPABLE  (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)
#define DWARF_UNWIND_MODULES  (0x800000)
#define BUGVERBOSE_OFF       (0x1000000)
#define RELOC_SET            (0x2000000)
#define RELOC_FORCE          (0x4000000)
#define ARCH_OPENVZ          (0x8000000)
#define ARCH_PVOPS          (0x10000000)
#define PRE_KERNEL_INIT     (0x20000000)
#define ARCH_PVOPS_XEN      (0x40000000)

#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)

/* flags2 */
#define RELOC_AUTO                  (0x1ULL)
#define KASLR                       (0x2ULL)
#define KASLR_CHECK                 (0x4ULL)
#define GET_TIMESTAMP               (0x8ULL)
#define TVEC_BASES_V3              (0x10ULL)
#define TIMER_BASES                (0x20ULL)
#define IRQ_DESC_TREE_RADIX        (0x40ULL)
#define IRQ_DESC_TREE_XARRAY       (0x80ULL)
#define KMOD_PAX                  (0x100ULL)

#define XEN()       (kt->flags & ARCH_XEN)
#define OPENVZ()    (kt->flags & ARCH_OPENVZ)
#define PVOPS()     (kt->flags & ARCH_PVOPS)
#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)

#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)

#define XEN_MACHINE_TO_MFN(m)    ((ulonglong)(m) >> PAGESHIFT())
#define XEN_PFN_TO_PSEUDO(p)     ((ulonglong)(p) << PAGESHIFT())

#define XEN_MFN_NOT_FOUND        (~0UL)
#define XEN_PFNS_PER_PAGE        (PAGESIZE()/sizeof(ulong))
#define XEN_FOREIGN_FRAME        (1UL << (BITS()-1))

#define XEN_MACHADDR_NOT_FOUND   (~0ULL)

#define XEN_P2M_PER_PAGE	(PAGESIZE() / sizeof(unsigned long))
#define XEN_P2M_MID_PER_PAGE	(PAGESIZE() / sizeof(unsigned long *))
#define XEN_P2M_TOP_PER_PAGE	(PAGESIZE() / sizeof(unsigned long **))

struct kernel_table {                   /* kernel data */
	ulong flags;
	ulong stext;
	ulong etext;
	ulong stext_init;
	ulong etext_init;
	ulong init_begin;
	ulong init_end;
	ulong end;
	int cpus;
	char *cpus_override;
	void (*display_bh)(void);
        ulong module_list;
        ulong kernel_module;
	int mods_installed;
	struct timespec date;
	char proc_version[BUFSIZE];
	struct new_utsname utsname;
	uint kernel_version[3];
	uint gcc_version[3];
	int runq_siblings;
	int kernel_NR_CPUS;
	long __per_cpu_offset[NR_CPUS];
	long *__rq_idx;
	long *__cpu_idx;
	ulong *cpu_flags;
#define POSSIBLE  (0x1)
#define PRESENT   (0x2)
#define ONLINE    (0x4)
#define NMI       (0x8)
#define POSSIBLE_MAP (POSSIBLE)
#define PRESENT_MAP   (PRESENT)
#define ONLINE_MAP     (ONLINE)
#define ACTIVE_MAP       (0x10)
	int BUG_bytes;
	ulong xen_flags;
#define WRITABLE_PAGE_TABLES    (0x1)
#define SHADOW_PAGE_TABLES      (0x2)
#define CANONICAL_PAGE_TABLES   (0x4)
#define XEN_SUSPEND             (0x8)
	char *m2p_page;
	ulong phys_to_machine_mapping;
	ulong p2m_table_size;
#define P2M_MAPPING_CACHE    (512)
	struct p2m_mapping_cache {
		ulong mapping;
		ulong pfn;
		ulong start;
		ulong end;
	} p2m_mapping_cache[P2M_MAPPING_CACHE];
#define P2M_MAPPING_PAGE_PFN(c) \
   (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \
```

#### region() [lines 5487-5593]
```c
 */
#define HELP_COLUMNS 5
#define START_OF_HELP_DATA(X)  "START_OF_HELP_DATA" X
#define END_OF_HELP_DATA       "END_OF_HELP_DATA"
void help_init(void);
void cmd_usage(char *, int);
void display_version(void);
void display_help_screen(char *);
#ifdef ARM
#define dump_machdep_table(X) arm_dump_machdep_table(X)
#endif
#ifdef ARM64
#define dump_machdep_table(X) arm64_dump_machdep_table(X)
#endif
#ifdef X86
#define dump_machdep_table(X) x86_dump_machdep_table(X)
#endif
#ifdef ALPHA
#define dump_machdep_table(X) alpha_dump_machdep_table(X)
#endif
#ifdef PPC
#define dump_machdep_table(X) ppc_dump_machdep_table(X)
#endif
#ifdef IA64
#define dump_machdep_table(X) ia64_dump_machdep_table(X)
#endif
#ifdef S390
#define dump_machdep_table(X) s390_dump_machdep_table(X)
#endif
#ifdef S390X
#define dump_machdep_table(X) s390x_dump_machdep_table(X)
#endif
#ifdef X86_64
#define dump_machdep_table(X) x86_64_dump_machdep_table(X)
#endif
#ifdef PPC64
#define dump_machdep_table(X) ppc64_dump_machdep_table(X)
#endif
#ifdef MIPS
#define dump_machdep_table(X) mips_dump_machdep_table(X)
#endif
#ifdef MIPS64
#define dump_machdep_table(X) mips64_dump_machdep_table(X)
#endif
#ifdef SPARC64
#define dump_machdep_table(X) sparc64_dump_machdep_table(X)
#endif
extern char *help_pointer[];
extern char *help_alias[];
extern char *help_ascii[];
extern char *help_bpf[];
extern char *help_bt[];
extern char *help_btop[];
extern char *help_dev[];
extern char *help_dis[];
extern char *help_eval[];
extern char *help_exit[];
extern char *help_extend[];
extern char *help_files[];
extern char *help_foreach[];
extern char *help_fuser[];
extern char *help_gdb[];
extern char *help_help[];
extern char *help_irq[];
extern char *help_kmem[];
extern char *help__list[];
extern char *help_tree[];
extern char *help_log[];
extern char *help_mach[];
extern char *help_mod[];
extern char *help_mount[];
extern char *help_net[];
extern char *help_p[];
extern char *help_ps[];
extern char *help_pte[];
extern char *help_ptob[];
extern char *help_ptov[];
extern char *help_quit[];
extern char *help_rd[];
extern char *help_repeat[];
extern char *help_runq[];
extern char *help_ipcs[];
extern char *help_search[];
extern char *help_set[];
extern char *help_sig[];
extern char *help_struct[];
extern char *help_swap[];
extern char *help_sym[];
extern char *help_sys[];
extern char *help_task[];
extern char *help_timer[];
extern char *help_union[];
extern char *help_vm[];
extern char *help_vtop[];
extern char *help_waitq[];
extern char *help_whatis[];
extern char *help_wr[];
#if defined(S390) || defined(S390X)
extern char *help_s390dbf[];
#endif
extern char *help_map[];

/*
 *  task.c
 */
void task_init(void);
int set_context(ulong, ulong);
```

#### kernel_init() [lines 188-294]
```c

#ifdef roundup
#undef roundup
#endif
#define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))

typedef uint64_t physaddr_t;

#define PADDR_NOT_AVAILABLE (0x1ULL)
#define KCORE_USE_VADDR      (-1ULL)

typedef unsigned long long int ulonglong;
struct number_option {
        ulong num;
        ulonglong ll_num;
	ulong retflags;
};

/*
 *  program_context flags
 */
#define LIVE_SYSTEM                 (0x1ULL)
#define TTY                         (0x2ULL)
#define RUNTIME                     (0x4ULL)
#define IN_FOREACH                  (0x8ULL)
#define MCLXCD                     (0x10ULL)
#define CMDLINE_IFILE              (0x20ULL)
#define MFD_RDWR                   (0x40ULL)
#define KVMDUMP                    (0x80ULL)
#define SILENT                    (0x100ULL)
#define SADUMP                    (0x200ULL)
#define HASH                      (0x400ULL)
#define SCROLL                    (0x800ULL)
#define NO_CONSOLE               (0x1000ULL)
#define RUNTIME_IFILE            (0x2000ULL)
#define DROP_CORE                (0x4000ULL)
#define LKCD                     (0x8000ULL)
#define GDB_INIT                (0x10000ULL)
#define IN_GDB                  (0x20000ULL)
#define RCLOCAL_IFILE           (0x40000ULL)
#define RCHOME_IFILE            (0x80000ULL)
#define VMWARE_VMSS            (0x100000ULL)
#define READLINE               (0x200000ULL)
#define _SIGINT_               (0x400000ULL)
#define IN_RESTART             (0x800000ULL)
#define KERNEL_DEBUG_QUERY    (0x1000000ULL)
#define DEVMEM                (0x2000000ULL)
#define REM_LIVE_SYSTEM       (0x4000000ULL)
#define NAMELIST_LOCAL        (0x8000000ULL)
#define LIVE_RAMDUMP         (0x10000000ULL)
#define NAMELIST_SAVED       (0x20000000ULL)
#define DUMPFILE_SAVED       (0x40000000ULL)
#define UNLINK_NAMELIST      (0x80000000ULL)
#define NAMELIST_UNLINKED   (0x100000000ULL)
#define REM_MCLXCD          (0x200000000ULL)
#define REM_LKCD            (0x400000000ULL)
#define NAMELIST_NO_GZIP    (0x800000000ULL)
#define UNLINK_MODULES     (0x1000000000ULL)
#define S390D              (0x2000000000ULL)
#define REM_S390D          (0x4000000000ULL)
#define SYSRQ              (0x8000000000ULL)
#define KDUMP             (0x10000000000ULL)
#define NETDUMP           (0x20000000000ULL)
#define REM_NETDUMP       (0x40000000000ULL)
#define SYSMAP            (0x80000000000ULL)
#define SYSMAP_ARG       (0x100000000000ULL)
#define MEMMOD           (0x200000000000ULL)
#define MODPRELOAD       (0x400000000000ULL)
#define DISKDUMP         (0x800000000000ULL)
#define DATADEBUG       (0x1000000000000ULL)
#define FINDKERNEL      (0x2000000000000ULL)
#define VERSION_QUERY   (0x4000000000000ULL)
#define READNOW         (0x8000000000000ULL)
#define NOCRASHRC      (0x10000000000000ULL)
#define INIT_IFILE     (0x20000000000000ULL)
#define XENDUMP        (0x40000000000000ULL)
#define XEN_HYPER      (0x80000000000000ULL)
#define XEN_CORE      (0x100000000000000ULL)
#define PLEASE_WAIT   (0x200000000000000ULL)
#define IFILE_ERROR   (0x400000000000000ULL)
#define KERNTYPES     (0x800000000000000ULL)
#define MINIMAL_MODE (0x1000000000000000ULL)
#define CRASHBUILTIN (0x2000000000000000ULL)
#define PRELOAD_EXTENSIONS \
		     (0x4000000000000000ULL)
#define PROC_KCORE   (0x8000000000000000ULL)

#define ACTIVE()            (pc->flags & LIVE_SYSTEM)
#define LOCAL_ACTIVE()      ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)
#define DUMPFILE()          (!(pc->flags & LIVE_SYSTEM))
#define LIVE()              (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)
#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)
#define DUMPFILE_TYPES      (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)
#define REMOTE()            (pc->flags2 & REMOTE_DAEMON)
#define REMOTE_ACTIVE()     (pc->flags & REM_LIVE_SYSTEM)
#define REMOTE_DUMPFILE() \
	   (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))
#define REMOTE_MEMSRC()     (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())
#define LKCD_DUMPFILE()     (pc->flags & (LKCD|REM_LKCD))
#define NETDUMP_DUMPFILE()  (pc->flags & (NETDUMP|REM_NETDUMP))
#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)
#define KDUMP_DUMPFILE()    (pc->flags & KDUMP)
#define XENDUMP_DUMPFILE()  (pc->flags & XENDUMP)
#define XEN_HYPER_MODE()    (pc->flags & XEN_HYPER)
#define SYSRQ_TASK(X)       ((pc->flags & SYSRQ) && is_task_active(X))
#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)
#define LKCD_KERNTYPES()    (pc->flags & KERNTYPES)
```

#### get_uptime() [lines 4509-4616]
```c
#define LONG_DEC     (0x8)
#define LONG_HEX     (0x10)
#define INT_DEC      (0x20)
#define INT_HEX      (0x40)
#define LONGLONG_HEX (0x80)
#define ZERO_FILL   (0x100)
#define SLONG_DEC   (0x200)

#define INIT_TIME (1)
#define RUN_TIME  (2)

/*
 * IRQ line status.
 * For kernels up to and including 2.6.17
 */
#define IRQ_INPROGRESS_2_6_17  1       /* IRQ handler active - do not enter! */
#define IRQ_DISABLED_2_6_17    2       /* IRQ disabled - do not enter! */
#define IRQ_PENDING_2_6_17     4       /* IRQ pending - replay on enable */
#define IRQ_REPLAY_2_6_17      8       /* IRQ has been replayed but not acked yet */
#define IRQ_AUTODETECT_2_6_17  16      /* IRQ is being autodetected */
#define IRQ_WAITING_2_6_17     32      /* IRQ not yet seen - for autodetection */
#define IRQ_LEVEL_2_6_17       64      /* IRQ level triggered */
#define IRQ_MASKED_2_6_17      128     /* IRQ masked - shouldn't be seen again */

/*
 * For kernel 2.6.21 and later
 */
#define IRQ_TYPE_NONE_2_6_21		0x00000000	/* Default, unspecified type */
#define IRQ_TYPE_EDGE_RISING_2_6_21	0x00000001	/* Edge rising type */
#define IRQ_TYPE_EDGE_FALLING_2_6_21	0x00000002	/* Edge falling type */
#define IRQ_TYPE_EDGE_BOTH_2_6_21 	(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
#define IRQ_TYPE_LEVEL_HIGH_2_6_21	0x00000004	/* Level high type */
#define IRQ_TYPE_LEVEL_LOW_2_6_21	0x00000008	/* Level low type */
#define IRQ_TYPE_SENSE_MASK_2_6_21	0x0000000f	/* Mask of the above */
#define IRQ_TYPE_PROBE_2_6_21		0x00000010	/* Probing in progress */

#define IRQ_INPROGRESS_2_6_21		0x00000100	/* IRQ handler active - do not enter! */
#define IRQ_DISABLED_2_6_21		0x00000200	/* IRQ disabled - do not enter! */
#define IRQ_PENDING_2_6_21		0x00000400	/* IRQ pending - replay on enable */
#define IRQ_REPLAY_2_6_21		0x00000800	/* IRQ has been replayed but not acked yet */
#define IRQ_AUTODETECT_2_6_21		0x00001000	/* IRQ is being autodetected */
#define I
/* ... truncated ... */
```

## Upstream Fix
```diff
From: Alan Tyson <atyson@hp.com>
Subject: [PATCH] Fix "uptime" and "ps -t" for SLES9
References: 352836

This patch adds a quirk for SLES9 jiffies initialisation and corrects the time
data in "uptime" and "ps -t" command.

Acked-by: Bernhard Walle <bwalle@suse.de>

---
 defs.h   |    8 ++++++++
 kernel.c |    9 ++++++++-
 task.c   |   11 +++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

--- a/defs.h
+++ b/defs.h
@@ -682,6 +682,7 @@ struct kernel_table {
 		ulong p2m_missing;
 	} pvops_xen;
 	int highest_irq;
+    int is_suse_kernel;
 #define IKCONFIG_AVAIL	0x1	/* kernel contains ikconfig data */
 #define IKCONFIG_LOADED	0x2	/* ikconfig data is currently loaded */
 	int ikconfig_flags;
@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;

 #endif  /* LKCD_COMMON */

+
+/*
+ * SUSE specific
+ */
+#define is_SLES9() \
+	((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)
+
 /*
  *  gdb_interface.c
  */
--- a/kernel.c
+++ b/kernel.c
@@ -237,6 +237,12 @@ kernel_init()

 	verify_version();

+	/*
+	 * check if we have a suse kernel (this is the module supported
+	 * patch of agruen@suse.de
+	 */
+	kt->is_suse_kernel = symbol_exists("unsupported");
+
 	if (symbol_exists("__per_cpu_offset")) {
 		if (LKCD_KERNTYPES())
 			i = get_cpus_possible();
@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)

 	if (symbol_exists("jiffies_64")) {
 		get_symbol_data("jiffies_64", sizeof(ulonglong), &jiffies_64);
-		if (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {
+		if (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {
 			wrapped = (jiffies_64 & 0xffffffff00000000ULL);
 			if (wrapped) {
 				wrapped -= 0x100000000ULL;
@@ -5110,6 +5116,7 @@ no_cpu_flags:
 	if (symbol_exists("p2m_mid_missing"))
 		fprintf(fp, "            p2m_mid_missing: %lx\n", kt->pvops_xen.p2m_mid_missing);
 	fprintf(fp, "                p2m_missing: %lx\n", kt->pvops_xen.p2m_missing);
+	fprintf(fp, "         is_suse_kernel: %ld\n", kt->is_suse_kernel);
 }

 /*
--- a/task.c
+++ b/task.c
@@ -3669,6 +3669,12 @@ start_time_timespec(void)
 	default:
 		break;
 	}
+	/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */
+	/* to do the right calculations in convert_start_time               */
+	if (is_SLES9()) {
+		tt->flags |= TIMESPEC;
+		return TRUE;
+	}

 	tt->flags |= NO_TIMESPEC;

@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,
 	ulong tmp1, tmp2;
 	ulonglong wrapped;

+	/* SLES9's start_time is neither jiffies nor a timespec.  It's ns */
+	if (is_SLES9()) {
+		start_time = start_time / 1000000000;
+	}
+
         switch(tt->flags & (TIMESPEC | NO_TIMESPEC))
         {
         case TIMESPEC:

```

Generate a backported patch for the SUSE target version.

[Assistant]
From: Alan Tyson <atyson@hp.com>
Subject: [PATCH] Fix "uptime" and "ps -t" for SLES9
References: 352836

This patch adds a quirk for SLES9 jiffies initialisation and corrects the time
data in "uptime" and "ps -t" command.

Acked-by: Bernhard Walle <bwalle@suse.de>

---
 defs.h   |    8 ++++++++
 kernel.c |    9 ++++++++-
 task.c   |   11 +++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

--- a/defs.h
+++ b/defs.h
@@ -682,6 +682,7 @@ struct kernel_table {
 		ulong p2m_missing;
 	} pvops_xen;
 	int highest_irq;
+    int is_suse_kernel;
 #define IKCONFIG_AVAIL	0x1	/* kernel contains ikconfig data */
 #define IKCONFIG_LOADED	0x2	/* ikconfig data is currently loaded */
 	int ikconfig_flags;
@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;

 #endif  /* LKCD_COMMON */

+
+/*
+ * SUSE specific
+ */
+#define is_SLES9() \
+	((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)
+
 /*
  *  gdb_interface.c
  */
--- a/kernel.c
+++ b/kernel.c
@@ -237,6 +237,12 @@ kernel_init()

 	verify_version();

+	/*
+	 * check if we have a suse kernel (this is the module supported
+	 * patch of agruen@suse.de
+	 */
+	kt->is_suse_kernel = symbol_exists("unsupported");
+
 	if (symbol_exists("__per_cpu_offset")) {
 		if (LKCD_KERNTYPES())
 			i = get_cpus_possible();
@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)

 	if (symbol_exists("jiffies_64")) {
 		get_symbol_data("jiffies_64", sizeof(ulonglong), &jiffies_64);
-		if (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {
+		if (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {
 			wrapped = (jiffies_64 & 0xffffffff00000000ULL);
 			if (wrapped) {
 				wrapped -= 0x100000000ULL;
@@ -5110,6 +5116,7 @@ no_cpu_flags:
 	if (symbol_exists("p2m_mid_missing"))
 		fprintf(fp, "            p2m_mid_missing: %lx\n", kt->pvops_xen.p2m_mid_missing);
 	fprintf(fp, "                p2m_missing: %lx\n", kt->pvops_xen.p2m_missing);
+	fprintf(fp, "         is_suse_kernel: %ld\n", kt->is_suse_kernel);
 }

 /*
--- a/task.c
+++ b/task.c
@@ -3669,6 +3669,12 @@ start_time_timespec(void)
 	default:
 		break;
 	}
+	/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */
+	/* to do the right calculations in convert_start_time               */
+	if (is_SLES9()) {
+		tt->flags |= TIMESPEC;
+		return TRUE;
+	}

 	tt->flags |= NO_TIMESPEC;

@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,
 	ulong tmp1, tmp2;
 	ulonglong wrapped;

+	/* SLES9's start_time is neither jiffies nor a timespec.  It's ns */
+	if (is_SLES9()) {
+		start_time = start_time / 1000000000;
+	}
+
         switch(tt->flags & (TIMESPEC | NO_TIMESPEC))
         {
         case TIMESPEC:


[System]
You are a security patch backporting assistant for SUSE/openSUSE.

Given a CVE description and an upstream fix, adapt the patch to work with
the target SUSE package version. Output the backported patch in unified
diff format. If the upstream fix applies directly, output it unchanged.

[User]
## CVE: CVE-2013-5634, CVE-2015-8956, CVE-2016-2069, CVE-2016-5696, CVE-2016-6130, CVE-2016-6327, CVE-2016-6480, CVE-2016-6828, CVE-2016-7042, CVE-2016-7097, CVE-2016-7425, CVE-2016-8658

CFLAGS.extra  |    1 +

## Package
crash

## Upstream Fix
```diff
---
 CFLAGS.extra  |    1 +
 LDFLAGS.extra |    1 +
 2 files changed, 2 insertions(+)

--- /dev/null
+++ b/CFLAGS.extra
@@ -0,0 +1 @@
+-DLZO
--- /dev/null
+++ b/LDFLAGS.extra
@@ -0,0 +1 @@
+-llzo2

```

Generate a backported patch for the SUSE target version.

[Assistant]
---
 CFLAGS.extra  |    1 +
 LDFLAGS.extra |    1 +
 2 files changed, 2 insertions(+)

--- /dev/null
+++ b/CFLAGS.extra
@@ -0,0 +1 @@
+-DLZO
--- /dev/null
+++ b/LDFLAGS.extra
@@ -0,0 +1 @@
+-llzo2