{"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Hari Bathini \n\n## Package\ncrash\n\n## Files to modify\n- ppc64.c\n\n## Target Source Code\n\n### ppc64.c\n\n#### ppc64_init() [lines 300-720]\n```c\n * times during initialization.\n */\nvoid\nppc64_init(int when)\n{\n#if defined(__x86_64__)\n if (ACTIVE())\n error(FATAL, \"compiled for the PPC64 architecture\\n\");\n#endif\n\tswitch (when)\n\t{\n\tcase SETUP_ENV:\n\t\tmachdep->process_elf_notes = process_elf64_notes;\n\t\tbreak;\n\n\tcase PRE_SYMTAB:\n\t\tmachdep->machspec = &ppc64_machine_specific;\n\t\tmachdep->verify_symbol = ppc64_verify_symbol;\n\t\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\t\treturn;\n\t\tmachdep->stacksize = PPC64_STACK_SIZE;\n\t\tmachdep->last_pgd_read = 0;\n\t\tmachdep->last_pud_read = 0;\n\t\tmachdep->last_pmd_read = 0;\n\t\tmachdep->last_ptbl_read = 0;\n\t\tmachdep->verify_paddr = generic_verify_paddr;\n\t\tmachdep->ptrs_per_pgd = PTRS_PER_PGD;\n\t\tmachdep->flags |= MACHDEP_BT_TEXT;\n if (machdep->cmdline_args[0])\n parse_cmdline_args();\n\t\t machdep->clear_machdep_cache = ppc64_clear_machdep_cache;\n\t\tbreak;\n\n\tcase PRE_GDB:\n\t\t/*\n * Recently there were changes made to kexec tools\n * to support 64K page size. With those changes\n * vmcore file obtained from a kernel which supports\n * 64K page size cannot be analyzed using crash on a\n * machine running with kernel supporting 4K page size\n/* ... 170 lines omitted ... */\n\n\t\t\t\t} else if (!(machdep->flags & BOOK3E) &&\n\t\t\t\t (THIS_KERNEL_VERSION >= LINUX(4,6,0))) {\n\t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K_3_10;\n\n\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,12,0)) {\n\t\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_12;\n\t\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,17,0))\n\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;\n\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_12;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_6;\n\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_6;\n\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n\t\t\t\t\t}\n\t\t\t\t} else if (THIS_KERNEL_VERSION >= LINUX(3,10,0)) {\n\t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K_3_10;\n\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_3_10;\n\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K;\n\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n\n\t\t\t\t} else {\n\t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K;\n\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K;\n\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K;\n\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K;\n/* ... 163 lines omitted ... */\n\t\t}\n\t\t/*\n\t\t * IRQ stacks are introduced in 2.6 and also configurable.\n\t\t */\n\t\tif ((THIS_KERNEL_VERSION >= LINUX(2,6,0)) && \n\t\t\tsymbol_exists(\"hardirq_ctx\"))\n\t\t\tASSIGN_SIZE(irq_ctx) = STACKSIZE();\n\n\t\tbreak;\n\n\tcase POST_INIT:\n\t\tbreak;\n\n\tcase LOG_ONLY:\n\t\tmachdep->identity_map_base = kt->vmcoreinfo._stext_SYMBOL;\n\t\tbreak;\n\t}\n}\n\n#ifndef KSYMS_START\n```\n\n\n## Upstream Fix\n```diff\nFrom 28fa7bd09013455b5ddc020dea4706278cda0d65 Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Wed, 20 Jun 2018 01:34:22 +0530\nSubject: book3s/ppc64: Increase the VA range\nUpstream: no, adapts the below upstream commit for SLE15 SP1\nGit-commit: 28fa7bd09013455b5ddc020dea4706278cda0d65\n\nFix for PPC64 kernel virtual address translation in Linux 4.17 and\nlater kernels with commit c2b4d8b7417a59b7f9a52d0d8402f5257cbbd398,\ntitled \"powerpc/mm/hash64: Increase the VA range\", in which the\nmaximum virtual address value has been increased to 4PB. Without\nthe patch, the translation/access of high vmalloc space addresses\nfails; for example, the \"kmem -[sS]\" option fails the translation\nof per-cpu kmem_cache_cpu addresses located in vmalloc space, with\nthe error messages \"kmem: invalid kernel virtual address:
\ntype: kmem_cache_cpu.freelist\" and \"kmem: invalid kernel virtual\naddress:
type: kmem_cache_cpu.page\", and the \"vtop\"\ncommand shows the addresses as \"(not mapped)\". (hbathini@linux.ibm.com)\n\n[note: apply on 4.12+ for SLE 15 SP1 - incompatible with SLE 15 SP0]\n\n---\n\nIndex: crash-7.2.8/ppc64.c\n===================================================================\n--- crash-7.2.8.orig/ppc64.c\n+++ crash-7.2.8/ppc64.c\n@@ -519,8 +519,9 @@ ppc64_init(int when)\n \n \t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,12,0)) {\n \t\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_12;\n-\t\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,17,0))\n-\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;\n+\t\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,17,0) ||\n+\t\t\t\t\t\t\tis_SLE15SP1())\n+\t\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;\n \t\t\t\t\t\telse\n \t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;\n \t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_12;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 28fa7bd09013455b5ddc020dea4706278cda0d65 Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Wed, 20 Jun 2018 01:34:22 +0530\nSubject: book3s/ppc64: Increase the VA range\nUpstream: no, adapts the below upstream commit for SLE15 SP1\nGit-commit: 28fa7bd09013455b5ddc020dea4706278cda0d65\n\nFix for PPC64 kernel virtual address translation in Linux 4.17 and\nlater kernels with commit c2b4d8b7417a59b7f9a52d0d8402f5257cbbd398,\ntitled \"powerpc/mm/hash64: Increase the VA range\", in which the\nmaximum virtual address value has been increased to 4PB. Without\nthe patch, the translation/access of high vmalloc space addresses\nfails; for example, the \"kmem -[sS]\" option fails the translation\nof per-cpu kmem_cache_cpu addresses located in vmalloc space, with\nthe error messages \"kmem: invalid kernel virtual address:
\ntype: kmem_cache_cpu.freelist\" and \"kmem: invalid kernel virtual\naddress:
type: kmem_cache_cpu.page\", and the \"vtop\"\ncommand shows the addresses as \"(not mapped)\". (hbathini@linux.ibm.com)\n\n[note: apply on 4.12+ for SLE 15 SP1 - incompatible with SLE 15 SP0]\n\n---\n\nIndex: crash-7.2.8/ppc64.c\n===================================================================\n--- crash-7.2.8.orig/ppc64.c\n+++ crash-7.2.8/ppc64.c\n@@ -519,8 +519,9 @@ ppc64_init(int when)\n \n \t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,12,0)) {\n \t\t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_12;\n-\t\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,17,0))\n-\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;\n+\t\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,17,0) ||\n+\t\t\t\t\t\t\tis_SLE15SP1())\n+\t\t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;\n \t\t\t\t\t\telse\n \t\t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;\n \t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_12;\n"}], "metadata": {"id": "crash-16042-crash-SLE15-SP1-Fix-for-PPC64-kernel-virtual-address-translation-in.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-SLE15-SP1-Fix-for-PPC64-kernel-virtual-address-translation-in.patch", "tier": "identical", "language": "c", "patch_lines_changed": 5, "patch_files_count": 1, "total_tokens_est": 1086, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFix for reading compressed kdump dumpfiles from systems with\n\n## Package\ncrash\n\n## Files to modify\n- diskdump.c\n\n## Target Source Code\n\n### diskdump.c\n\n#### clean_diskdump_data() [lines 216-235]\n```c\n}\n\nstatic void \nclean_diskdump_data(void)\n{\n\tint i;\n\n\tif (dd_list == NULL)\n\t\treturn;\n\n\tfor (i=1; idfd, sub_header, block_size) < block_size) {\n\t\t\t\terror(INFO, \"diskdump: cannot read dump sub header\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\t\tdd->sub_header = sub_header;\n\n\t\t/* the 64bit max_mapnr only exists in sub-header of compressed\n\t\t * kdump file, if it's not a compressed kdump file, we have to\n\t\t * use the old 32bit max_mapnr in dumpfile header.\n\t\t * max_mapnr may be truncated here.\n\t\t */\n\t\tdd->max_mapnr = header->max_mapnr;\n\t} else if (KDUMP_CMPRS_VALID()) {\n\t\tif ((sub_header_kdump = malloc(block_size)) == NULL)\n\t\t\terror(FATAL, \"compressed kdump: cannot malloc sub_header_kdump buffer\\n\");\n\n\t\tif (FLAT_FORMAT()) {\n\t\t\tif (!read_flattened_format(dd->dfd, offset, sub_header_kdump, block_size)) {\n\t\t\t\terror(INFO, \"compressed kdump: cannot read dump sub header\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t} else {\n\t\t\tif (lseek(dd->dfd, offset, SEEK_SET) == failed) {\n\t\t\t\terror(INFO, \"compressed kdump: cannot lseek dump sub header\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tif (read(dd->dfd, sub_header_kdump, block_size) < block_size) {\n\t\t\t\terror(INFO, \"compressed kdump: cannot read dump sub header\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\t\tdd->sub_header_kdump = sub_header_kdump;\n\n#if defined(__i386__) && (defined(ARM) || defined(MIPS))\n\t\tarm_kdump_header_adjust(header->header_version);\n#endif\n\t\t/* use 64bit max_mapnr in compressed kdump file sub-header */\n\t\tif (header->header_version >= 6)\n\t\t\tdd->max_mapnr = dd->sub_header_kdump->max_mapnr_64;\n\t\telse {\n\t\t\tdd->sub_header_kdump->start_pfn_64\n\t\t\t\t= dd->sub_header_kdump->start_pfn;\n\t\t\tdd->sub_header_kdump->end_pfn_64\n\t\t\t\t= dd->sub_header_kdump->end_pfn;\n\t\t}\n\t}\n\n\tif (header->header_version < 6)\n\t\tdd->max_mapnr = header->max_mapnr;\n\n\t/* read memory bitmap */\n\tbitmap_len = (off_t)block_size * header->bitmap_blocks;\n\tdd->bitmap_len = bitmap_len;\n\n\toffset = (off_t)block_size * (1 + header->sub_hdr_size);\n\n\tif ((dd->bitmap = malloc(bitmap_len)) == NULL)\n\t\terror(FATAL, \"%s: cannot malloc bitmap buffer\\n\",\n\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\n\tdd->dumpable_bitmap = calloc(bitmap_len, 1);\n\n\tif (CRASHDEBUG(8))\n\t\tfprintf(fp, \"%s: memory bitmap offset: %llx\\n\",\n\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\",\n\t\t\t(ulonglong)offset);\n\n\tif (FLAT_FORMAT()) {\n\t\tif (!read_flattened_format(dd->dfd, offset, dd->bitmap, bitmap_len)) {\n\t\t\terror(INFO, \"%s: cannot read memory bitmap\\n\",\n\t\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\t\t\tgoto err;\n\t\t}\n\t} else {\n\t\tif (lseek(dd->dfd, offset, SEEK_SET) == failed) {\n\t\t\terror(INFO, \"%s: cannot lseek memory bitmap\\n\",\n\t\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\t\t\tgoto err;\n\t\t}\n\t\tbufptr = dd->bitmap;\n\t\tlen = bitmap_len;\n\t\twhile (len) {\n\t\t\tbytes_read = read(dd->dfd, bufptr, len);\n\t\t\tif (bytes_read <= 0) {\n\t\t\t\terror(INFO, \"%s: cannot read memory bitmap\\n\",\n\t\t\t\t\tDISKDUMP_VALID() ? \"diskdump\"\n\t\t\t\t\t: \"compressed kdump\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tlen -= bytes_read;\n\t\t\tbufptr += bytes_read;\n\t\t}\n\t}\n\n\tif (dump_is_partial(header))\n\t\tmemcpy(dd->dumpable_bitmap, dd->bitmap + bitmap_len/2,\n\t\t bitmap_len/2);\n\telse\n\t\tmemcpy(dd->dumpable_bitmap, dd->bitmap, bitmap_len);\n\n\tdd->data_offset\n\t\t= (1UL + header->sub_hdr_size + header->bitmap_blocks)\n\t\t* header->block_size;\n\n```\n\n#### region() [lines 695-802]\n```c\n\n\tif (header->header_version < 6)\n\t\tdd->max_mapnr = header->max_mapnr;\n\n\t/* read memory bitmap */\n\tbitmap_len = (off_t)block_size * header->bitmap_blocks;\n\tdd->bitmap_len = bitmap_len;\n\n\toffset = (off_t)block_size * (1 + header->sub_hdr_size);\n\n\tif ((dd->bitmap = malloc(bitmap_len)) == NULL)\n\t\terror(FATAL, \"%s: cannot malloc bitmap buffer\\n\",\n\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\n\tdd->dumpable_bitmap = calloc(bitmap_len, 1);\n\n\tif (CRASHDEBUG(8))\n\t\tfprintf(fp, \"%s: memory bitmap offset: %llx\\n\",\n\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\",\n\t\t\t(ulonglong)offset);\n\n\tif (FLAT_FORMAT()) {\n\t\tif (!read_flattened_format(dd->dfd, offset, dd->bitmap, bitmap_len)) {\n\t\t\terror(INFO, \"%s: cannot read memory bitmap\\n\",\n\t\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\t\t\tgoto err;\n\t\t}\n\t} else {\n\t\tif (lseek(dd->dfd, offset, SEEK_SET) == failed) {\n\t\t\terror(INFO, \"%s: cannot lseek memory bitmap\\n\",\n\t\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\");\n\t\t\tgoto err;\n\t\t}\n\t\tbufptr = dd->bitmap;\n\t\tlen = bitmap_len;\n\t\twhile (len) {\n\t\t\tbytes_read = read(dd->dfd, bufptr, len);\n\t\t\tif (bytes_read <= 0) {\n\t\t\t\terror(INFO, \"%s: cannot read memory bitmap\\n\",\n\t\t\t\t\tDISKDUMP_VALID() ? \"diskdump\"\n\t\t\t\t\t: \"compressed kdump\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tlen -= bytes_read;\n\t\t\tbufptr += bytes_read;\n\t\t}\n\t}\n\n\tif (dump_is_partial(header))\n\t\tmemcpy(dd->dumpable_bitmap, dd->bitmap + bitmap_len/2,\n\t\t bitmap_len/2);\n\telse\n\t\tmemcpy(dd->dumpable_bitmap, dd->bitmap, bitmap_len);\n\n\tdd->data_offset\n\t\t= (1UL + header->sub_hdr_size + header->bitmap_blocks)\n\t\t* header->block_size;\n\n\tdd->header = header;\n\n\tif (machine_type(\"ARM\"))\n\t\tdd->machine_type = EM_ARM;\n\telse if (machine_type(\"MIPS\") || machine_type(\"MIPS64\"))\n\t\tdd->machine_type = EM_MIPS;\n\telse if (machine_type(\"X86\"))\n\t\tdd->machine_type = EM_386;\n\telse if (machine_type(\"X86_64\"))\n\t\tdd->machine_type = EM_X86_64;\n\telse if (machine_type(\"IA64\"))\n\t\tdd->machine_type = EM_IA_64;\n\telse if (machine_type(\"PPC\"))\n\t\tdd->machine_type = EM_PPC;\n\telse if (machine_type(\"PPC64\"))\n\t\tdd->machine_type = EM_PPC64;\n\telse if (machine_type(\"S390X\"))\n\t\tdd->machine_type = EM_S390;\n\telse if (machine_type(\"ARM64\"))\n\t\tdd->machine_type = EM_AARCH64;\n\telse if (machine_type(\"SPARC64\"))\n\t\tdd->machine_type = EM_SPARCV9;\n\telse {\n\t\terror(INFO, \"%s: unsupported machine type: %s\\n\", \n\t\t\tDISKDUMP_VALID() ? \"diskdump\" : \"compressed kdump\",\n\t\t\tMACHINE_TYPE);\n\t\tgoto err;\n\t}\n\n\t/* process elf notes data */\n\tif (KDUMP_CMPRS_VALID() && !(dd->flags & NO_ELF_NOTES) &&\n\t\t(dd->header->header_version >= 4) &&\n\t\t(sub_header_kdump->offset_note) &&\n\t\t(sub_header_kdump->size_note) && (machdep->process_elf_notes)) {\n\t\tsize = sub_header_kdump->size_note;\n\t\toffset = sub_header_kdump->offset_note;\n\n\t\tif ((dd->notes_buf = malloc(size)) == NULL)\n\t\t\terror(FATAL, \"compressed kdump: cannot malloc notes\"\n\t\t\t\t\" buffer\\n\");\n\n\t\tif ((dd->nt_prstatus_percpu = malloc(NR_CPUS * sizeof(void *))) == NULL)\n\t\t\terror(FATAL, \"compressed kdump: cannot malloc pointer\"\n\t\t\t\t\" to NT_PRSTATUS notes\\n\");\n\n\t\tif ((dd->nt_qemu_percpu = malloc(NR_CPUS * sizeof(void *))) == NULL)\n\t\t\terror(FATAL, \"qemu mem dump compressed: cannot malloc pointer\"\n\t\t\t\t\" to QEMU notes\\n\");\n\n\t\tif ((dd->nt_qemucs_percpu = malloc(NR_CPUS * sizeof(void *))) == NULL)\n```\n\n\n## Upstream Fix\n```diff\nFrom b80b16549e24769c7d5fe3a10c4b1a1c4b5161f3 Mon Sep 17 00:00:00 2001\nFrom: Dave Anderson \nDate: Mon, 23 Mar 2020 15:52:11 -0400\nSubject: [PATCH] Fix for reading compressed kdump dumpfiles from systems with\n physical memory located at extraordinarily high addresses. In a system with\n a physical address range from 0x602770ecf000 to 0x6027ffffffff, the crash\n utility fails during session initialization due to an integer overflow,\n ending with the error message \"crash: vmlinux and vmcore do not match!\".\n (chenjialong@huawei.com)\n\nReferences: bsc#1168233 ltc#184660\nUpstream: merged\nGit-commit: b80b16549e24769c7d5fe3a10c4b1a1c4b5161f3\n\n---\n diskdump.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diskdump.c b/diskdump.c\nindex e88243e616cc..328c932dad5a 100644\n--- a/diskdump.c\n+++ b/diskdump.c\n@@ -233,7 +233,7 @@ clean_diskdump_data(void)\n }\n \n static inline int \n-get_bit(char *map, int byte, int bit)\n+get_bit(char *map, unsigned long byte, int bit)\n {\n \treturn map[byte] & (1<max_mapnr = header->max_mapnr;\n \n \t/* read memory bitmap */\n-\tbitmap_len = block_size * header->bitmap_blocks;\n+\tbitmap_len = (off_t)block_size * header->bitmap_blocks;\n \tdd->bitmap_len = bitmap_len;\n \n \toffset = (off_t)block_size * (1 + header->sub_hdr_size);\n@@ -744,7 +744,7 @@ restart:\n \t\tmemcpy(dd->dumpable_bitmap, dd->bitmap, bitmap_len);\n \n \tdd->data_offset\n-\t\t= (1 + header->sub_hdr_size + header->bitmap_blocks)\n+\t\t= (1UL + header->sub_hdr_size + header->bitmap_blocks)\n \t\t* header->block_size;\n \n \tdd->header = header;\n-- \n2.23.0\n\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From b80b16549e24769c7d5fe3a10c4b1a1c4b5161f3 Mon Sep 17 00:00:00 2001\nFrom: Dave Anderson \nDate: Mon, 23 Mar 2020 15:52:11 -0400\nSubject: [PATCH] Fix for reading compressed kdump dumpfiles from systems with\n physical memory located at extraordinarily high addresses. In a system with\n a physical address range from 0x602770ecf000 to 0x6027ffffffff, the crash\n utility fails during session initialization due to an integer overflow,\n ending with the error message \"crash: vmlinux and vmcore do not match!\".\n (chenjialong@huawei.com)\n\nReferences: bsc#1168233 ltc#184660\nUpstream: merged\nGit-commit: b80b16549e24769c7d5fe3a10c4b1a1c4b5161f3\n\n---\n diskdump.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diskdump.c b/diskdump.c\nindex e88243e616cc..328c932dad5a 100644\n--- a/diskdump.c\n+++ b/diskdump.c\n@@ -233,7 +233,7 @@ clean_diskdump_data(void)\n }\n \n static inline int \n-get_bit(char *map, int byte, int bit)\n+get_bit(char *map, unsigned long byte, int bit)\n {\n \treturn map[byte] & (1<max_mapnr = header->max_mapnr;\n \n \t/* read memory bitmap */\n-\tbitmap_len = block_size * header->bitmap_blocks;\n+\tbitmap_len = (off_t)block_size * header->bitmap_blocks;\n \tdd->bitmap_len = bitmap_len;\n \n \toffset = (off_t)block_size * (1 + header->sub_hdr_size);\n@@ -744,7 +744,7 @@ restart:\n \t\tmemcpy(dd->dumpable_bitmap, dd->bitmap, bitmap_len);\n \n \tdd->data_offset\n-\t\t= (1 + header->sub_hdr_size + header->bitmap_blocks)\n+\t\t= (1UL + header->sub_hdr_size + header->bitmap_blocks)\n \t\t* header->block_size;\n \n \tdd->header = header;\n-- \n2.23.0\n\n"}], "metadata": {"id": "crash-16042-crash-Fix-for-reading-compressed-kdump-dumpfiles-from-syst.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-Fix-for-reading-compressed-kdump-dumpfiles-from-syst.patch", "tier": "identical", "language": "c", "patch_lines_changed": 7, "patch_files_count": 1, "total_tokens_est": 1018, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Luc Chouinard \n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic/applications/crash/eppic.c\n\n## Target Source Code\n\n### eppic/applications/crash/eppic.c\n\n#### _init() [lines 984-5]\n```c\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Luc Chouinard \nDate: Thu Jun 19 12:28:40 2014 -0700\nSubject: Support for ARM64\nReferences: FATE#320844\nPatch-mainline: yes\nGit-commit: 5391d3dd0e6710c22ec5801f99a6788a2e4b132a\n\nAcked-by: Petr Tesarik \n\n---\n extensions/eppic/applications/crash/eppic.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\n--- a/extensions/eppic/applications/crash/eppic.c\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -1033,10 +1033,14 @@ _init() /* Register the command set. */\n #ifdef PPC64\n #define EPPIC_ABI ABI_PPC64\n #else\n+#ifdef ARM64\n+#define EPPIC_ABI ABI_ARM64\n+#else\n #error eppic: Unkown ABI \n #endif\n #endif\n #endif\n+#endif\n #endif\n #endif\n #endif\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Luc Chouinard \nDate: Thu Jun 19 12:28:40 2014 -0700\nSubject: Support for ARM64\nReferences: FATE#320844\nPatch-mainline: yes\nGit-commit: 5391d3dd0e6710c22ec5801f99a6788a2e4b132a\n\nAcked-by: Petr Tesarik \n\n---\n extensions/eppic/applications/crash/eppic.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\n--- a/extensions/eppic/applications/crash/eppic.c\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -1033,10 +1033,14 @@ _init() /* Register the command set. */\n #ifdef PPC64\n #define EPPIC_ABI ABI_PPC64\n #else\n+#ifdef ARM64\n+#define EPPIC_ABI ABI_ARM64\n+#else\n #error eppic: Unkown ABI \n #endif\n #endif\n #endif\n+#endif\n #endif\n #endif\n #endif\n"}], "metadata": {"id": "crash-16042-eppic-support-arm64.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "eppic-support-arm64.patch", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 577, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nfix \"kmem -[sS]\" for caches created during SLUB bootstrap\n\n## Package\ncrash\n\n## Files to modify\n- memory.c\n\n## Upstream Fix\n```diff\nFrom 50f39247d80519c71d1f03984bc34aa476a9c2bd Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Wed, 8 Apr 2020 11:38:23 +0200\nSubject: [PATCH] fix \"kmem -[sS]\" for caches created during SLUB bootstrap\n\nReferences: bsc#1164815 ltc#182973 https://www.redhat.com/archives/crash-utility/2020-April/msg00029.html\nUpstream: submitted\n\nFix for \"kmem -[sS]\" options on Linux 4.14 and later kernels built\nwith CONFIG_SLAB_FREELIST_HARDENED enabled. Without the patch, there\nwill error messages of the type \"kmem: slab:
\ninvalid freepointer: \" for caches created during\nSLUB bootstrap, as they are likely to have s->random == 0.\n\nSigned-off-by: Hari Bathini \n---\n memory.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/memory.c b/memory.c\nindex ccc29442c3f6..c2433ebe5e75 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -19244,7 +19244,7 @@ count_free_objects(struct meminfo *si, ulong freelist)\n static ulong\n freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr)\n {\n-\tif (si->random)\n+\tif (VALID_MEMBER(kmem_cache_random))\n \t\t/* CONFIG_SLAB_FREELIST_HARDENED */\n \t\treturn (ptr ^ si->random ^ ptr_addr);\n \telse\n-- \n2.23.0\n\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 50f39247d80519c71d1f03984bc34aa476a9c2bd Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Wed, 8 Apr 2020 11:38:23 +0200\nSubject: [PATCH] fix \"kmem -[sS]\" for caches created during SLUB bootstrap\n\nReferences: bsc#1164815 ltc#182973 https://www.redhat.com/archives/crash-utility/2020-April/msg00029.html\nUpstream: submitted\n\nFix for \"kmem -[sS]\" options on Linux 4.14 and later kernels built\nwith CONFIG_SLAB_FREELIST_HARDENED enabled. Without the patch, there\nwill error messages of the type \"kmem: slab:
\ninvalid freepointer: \" for caches created during\nSLUB bootstrap, as they are likely to have s->random == 0.\n\nSigned-off-by: Hari Bathini \n---\n memory.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/memory.c b/memory.c\nindex ccc29442c3f6..c2433ebe5e75 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -19244,7 +19244,7 @@ count_free_objects(struct meminfo *si, ulong freelist)\n static ulong\n freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr)\n {\n-\tif (si->random)\n+\tif (VALID_MEMBER(kmem_cache_random))\n \t\t/* CONFIG_SLAB_FREELIST_HARDENED */\n \t\treturn (ptr ^ si->random ^ ptr_addr);\n \telse\n-- \n2.23.0\n\n"}], "metadata": {"id": "crash-16042-crash-fix-kmem-sS-for-caches-created-during-SLUB-bootstrap.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-fix-kmem-sS-for-caches-created-during-SLUB-bootstrap.patch", "tier": "identical", "language": "c", "patch_lines_changed": 3, "patch_files_count": 1, "total_tokens_est": 816, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 40 lines omitted ... */\n\t\t\tpc->scroll_command = SCROLL_CRASHPAGER;\n\t\t} else if (file_exists(\"/usr/bin/less\", NULL)) {\n\t\t\tpc->flags |= SCROLL;\n\t\t\tpc->scroll_command = SCROLL_LESS;\n\t\t} else if (file_exists(\"/bin/more\", NULL)) {\n\t\t\tpc->flags |= SCROLL;\n\t\t\tpc->scroll_command = SCROLL_MORE;\n\t\t} else {\n \tpc->scroll_command = SCROLL_NONE;\n \tpc->flags &= ~SCROLL;\n \t}\n\t} \n\n\t/*\n\t * Setup the readline command line editing mode based upon the \n\t * following order:\n\t *\n\t * (1) EDITOR environment variable\n * (2) overridden by any .crashrc entry: \"set vi\" or \"set emacs\"\n * (3) RL_VI_MODE if not set anywhere else\n\t */\n\n\tpc->flags |= READLINE;\n\tpc->editing_mode = \"no_mode\";\n\n\tif ((p1 = getenv(\"EDITOR\"))) {\n\t\tif (strstr(p1, \"vi\"))\n\t\t\tpc->editing_mode = \"vi\";\n\t\tif (strstr(p1, \"emacs\"))\n\t\t\tpc->editing_mode = \"emacs\";\n\t}\n\n/* ... 34 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: crash-7.2.7/main.c\n===================================================================\n--- crash-7.2.7.orig/main.c\n+++ crash-7.2.7/main.c\n@@ -1169,12 +1169,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1224,7 +1218,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: crash-7.2.7/main.c\n===================================================================\n--- crash-7.2.7.orig/main.c\n+++ crash-7.2.7/main.c\n@@ -1169,12 +1169,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1224,7 +1218,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-16042-crash-make-emacs-default.diff", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 1, "total_tokens_est": 584, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: crash-7.2.7/symbols.c\n===================================================================\n--- crash-7.2.7.orig/symbols.c\n+++ crash-7.2.7/symbols.c\n@@ -203,9 +203,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -267,13 +267,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -294,14 +297,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: crash-7.2.7/symbols.c\n===================================================================\n--- crash-7.2.7.orig/symbols.c\n+++ crash-7.2.7/symbols.c\n@@ -203,9 +203,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -267,13 +267,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -294,14 +297,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-16042-crash-debuginfo-compressed.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 1, "total_tokens_est": 1314, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-16042-crash-sles9-quirk.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1515, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: David Mair \n\n## Package\ncrash\n\n## Files to modify\n- memory.c\n\n## Upstream Fix\n```diff\nFrom: David Mair \nDate: 2017-05-25 10:27:21 -0600\nSubject: Avoid printing a read error for a failed read that can be retried\nReferences: bnc#1038839\nUpstream: tbd\n\nWhen reading a memory image fails it may not be an error if it is still\npossible to switch image and retry the read. Fix the error message output\nto only occur if no retries are intended.\n\n---\n\nIndex: crash-7.2.8/memory.c\n===================================================================\n--- crash-7.2.8.orig/memory.c\n+++ crash-7.2.8/memory.c\n@@ -2320,8 +2320,6 @@ readmem(ulonglong addr, int memtype, voi\n goto readmem_error;\n \n \t\tcase READ_ERROR:\n-\t\t\tif (PRINT_ERROR_MESSAGE)\n-\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tif ((pc->flags & DEVMEM) && (kt->flags & PRE_KERNEL_INIT) &&\n \t\t\t !(error_handle & NO_DEVMEM_SWITCH) && devmem_is_restricted() && \n \t\t\t switch_to_proc_kcore()) {\n@@ -2329,6 +2327,8 @@ readmem(ulonglong addr, int memtype, voi\n \t\t\t\treturn(readmem(addr, memtype, bufptr, size,\n \t\t\t\t\ttype, error_handle));\n \t\t\t}\n+\t\t\tif (PRINT_ERROR_MESSAGE)\n+\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tgoto readmem_error;\n \n \t\tcase PAGE_EXCLUDED:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: David Mair \nDate: 2017-05-25 10:27:21 -0600\nSubject: Avoid printing a read error for a failed read that can be retried\nReferences: bnc#1038839\nUpstream: tbd\n\nWhen reading a memory image fails it may not be an error if it is still\npossible to switch image and retry the read. Fix the error message output\nto only occur if no retries are intended.\n\n---\n\nIndex: crash-7.2.8/memory.c\n===================================================================\n--- crash-7.2.8.orig/memory.c\n+++ crash-7.2.8/memory.c\n@@ -2320,8 +2320,6 @@ readmem(ulonglong addr, int memtype, voi\n goto readmem_error;\n \n \t\tcase READ_ERROR:\n-\t\t\tif (PRINT_ERROR_MESSAGE)\n-\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tif ((pc->flags & DEVMEM) && (kt->flags & PRE_KERNEL_INIT) &&\n \t\t\t !(error_handle & NO_DEVMEM_SWITCH) && devmem_is_restricted() && \n \t\t\t switch_to_proc_kcore()) {\n@@ -2329,6 +2327,8 @@ readmem(ulonglong addr, int memtype, voi\n \t\t\t\treturn(readmem(addr, memtype, bufptr, size,\n \t\t\t\t\ttype, error_handle));\n \t\t\t}\n+\t\t\tif (PRINT_ERROR_MESSAGE)\n+\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tgoto readmem_error;\n \n \t\tcase PAGE_EXCLUDED:\n"}], "metadata": {"id": "crash-16042-crash-stop_read_error_when_intent_is_retry.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-stop_read_error_when_intent_is_retry.patch", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 1, "total_tokens_est": 810, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Hari Bathini \n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- ppc64.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 6847-6953]\n```c\nint vmware_vmss_valid_regs(struct bt_info *);\nint vmware_vmss_get_nr_cpus(void);\nint vmware_vmss_get_cr3_cr4_idtr(int, ulong *, ulong *, ulong *);\nint vmware_vmss_phys_base(ulong *phys_base);\nint vmware_vmss_set_phys_base(ulong);\n\n/*\n * vmware_guestdump.c\n */\nint is_vmware_guestdump(char *filename);\nint vmware_guestdump_init(char *filename, FILE *ofp);\nint vmware_guestdump_memory_dump(FILE *);\n\n/*\n * kaslr_helper.c\n */\nint calc_kaslr_offset(ulong *, ulong *);\n\n/*\n * printk.c\n */\nvoid dump_lockless_record_log(int);\n\n/*\n * gnu_binutils.c\n */\n\n/* NO LONGER IN USE */\n\n/*\n * test.c\n */\nvoid cmd_template(void);\nvoid foreach_test(ulong, ulong);\n\n/*\n * va_server.c\n */\nint mclx_page_size(void);\nint vas_memory_used(void);\nint vas_memory_dump(FILE *);\nint vas_free_memory(char *);\nvoid set_vas_debug(ulong);\nsize_t vas_write(void *, size_t);\nint va_server_init(char *, ulong *, ulong *, ulong *);\nsize_t vas_read(void *, size_t);\nint vas_lseek(ulong, int);\n\n/*\n * lkcd_x86_trace.c\n */\nint lkcd_x86_back_trace(struct bt_info *, int, FILE *);\n\n/*\n * lkcd_common.c\n */\nint lkcd_dump_init(FILE *, int, char *);\nulong get_lkcd_panic_task(void);\nvoid get_lkcd_panicmsg(char *);\nint is_lkcd_compressed_dump(char *);\nvoid dump_lkcd_environment(ulong);\nint lkcd_lseek(physaddr_t);\nlong lkcd_read(void *, long);\nvoid set_lkcd_debug(ulong);\nFILE *set_lkcd_fp(FILE *);\nuint lkcd_page_size(void);\nint lkcd_memory_used(void);\nint lkcd_memory_dump(FILE *);\nint lkcd_free_memory(void);\nvoid lkcd_print(char *, ...);\nvoid set_remote_lkcd_panic_data(ulong, char *);\nvoid set_lkcd_nohash(void);\nint lkcd_load_dump_page_header(void *, ulong);\nvoid lkcd_dumpfile_complaint(uint32_t, uint32_t, int);\nint set_mb_benchmark(ulong);\nulonglong fix_lkcd_address(ulonglong);\nint lkcd_get_kernel_start(ulong *addr);\nint get_lkcd_regs_for_cpu(struct bt_info *bt, ulong *eip, ulong *esp);\n\n/*\n * lkcd_v1.c\n */\nint lkcd_dump_init_v1(FILE *, int);\nvoid dump_dump_page_v1(char *, void *);\nvoid dump_lkcd_environment_v1(ulong);\nuint32_t get_dp_size_v1(void);\nuint32_t get_dp_flags_v1(void);\nuint64_t get_dp_address_v1(void);\n\n/*\n * lkcd_v2_v3.c\n */\nint lkcd_dump_init_v2_v3(FILE *, int);\nvoid dump_dump_page_v2_v3(char *, void *);\nvoid dump_lkcd_environment_v2_v3(ulong);\nuint32_t get_dp_size_v2_v3(void);\nuint32_t get_dp_flags_v2_v3(void);\nuint64_t get_dp_address_v2_v3(void);\n\n/*\n * lkcd_v5.c\n */\nint lkcd_dump_init_v5(FILE *, int);\nvoid dump_dump_page_v5(char *, void *);\nvoid dump_lkcd_environment_v5(ulong);\nuint32_t get_dp_size_v5(void); \nuint32_t get_dp_flags_v5(void);\n```\n\n### ppc64.c\n\n#### set_ppc64_max_physmem_bits() [lines 222-258]\n```c\n\n#define is_RHEL8() (strstr(kt->proc_version, \".el8.\"))\n\nstatic int set_ppc64_max_physmem_bits(void)\n{\n\tint dimension;\n\tchar *string;\n\n\tif ((string = pc->read_vmcoreinfo(\"NUMBER(MAX_PHYSMEM_BITS)\"))) {\n\t\tmachdep->max_physmem_bits = atol(string);\n\t\tfree(string);\n\t\treturn 0;\n\t}\n\n\tget_array_length(\"mem_section\", &dimension, 0);\n\n\tif ((machdep->flags & VMEMMAP) &&\n\t (THIS_KERNEL_VERSION >= LINUX(4,20,0)) &&\n\t !dimension && (machdep->pagesize == 65536)) {\n\t\t/*\n\t\t * SPARSEMEM_VMEMMAP & SPARSEMEM_EXTREME configurations with\n\t\t * 64K pagesize and v4.20 kernel or later.\n\t\t */\n\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_20;\n\t} else if ((machdep->flags & VMEMMAP) &&\n\t ((THIS_KERNEL_VERSION >= LINUX(4,19,0)) || is_RHEL8())) {\n\t\t/* SPARSEMEM_VMEMMAP & v4.19 kernel or later, or RHEL8 */\n\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;\n\t} else if (THIS_KERNEL_VERSION >= LINUX(3,7,0))\n\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_3_7;\n\telse\n\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS;\n\n\treturn 0;\n}\n\nstruct machine_specific ppc64_machine_specific = { \n```\n\n\n## Upstream Fix\n```diff\nFrom 599a6579aa916df7800f8e889d68e4287e4520dd Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Thu, 27 Sep 2018 02:06:49 +0530\nSubject: ppc64: increase MAX_PHYSMEM_BITS to 128TB\nUpstream: no, adapts the below upstream commit for SLE15 SP1\nGit-commit: 599a6579aa916df7800f8e889d68e4287e4520dd\n\nWith Linux 4.19-rc1 commit 7d4340bb92a9df78e6e28152f3dd89d9bd82146b,\ntitled \"powerpc/mm: Increase MAX_PHYSMEM_BITS to 128TB with\nSPARSEMEM_VMEMMAP config\", the PPC64 MAX_PHYSMEM_BITS value has been\nbumped up to 47. The appropriate update has been made in this patch.\n(hbathini@linux.ibm.com)\n\n[note: apply on 4.12+ for SLE 15 SP1 - incompatible with SLE 15 SP0]\n---\n\nIndex: crash-7.2.8/defs.h\n===================================================================\n--- crash-7.2.8.orig/defs.h\n+++ crash-7.2.8/defs.h\n@@ -6896,6 +6896,9 @@ extern struct lkcd_environment *lkcd;\n #define is_SLES9() \\\n \t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n \n+#define is_SLE15SP1() \\\n+\t((THIS_KERNEL_VERSION >= LINUX(4,12,0)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\nIndex: crash-7.2.8/ppc64.c\n===================================================================\n--- crash-7.2.8.orig/ppc64.c\n+++ crash-7.2.8/ppc64.c\n@@ -244,9 +244,14 @@ static int set_ppc64_max_physmem_bits(vo\n \t\t */\n \t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_20;\n \t} else if ((machdep->flags & VMEMMAP) &&\n-\t ((THIS_KERNEL_VERSION >= LINUX(4,19,0)) || is_RHEL8())) {\n-\t\t/* SPARSEMEM_VMEMMAP & v4.19 kernel or later, or RHEL8 */\n-\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;\n+\t ((THIS_KERNEL_VERSION >= LINUX(4,19,0)) ||\n+\t\tis_RHEL8() ||\n+\t\tis_SLE15SP1())) {\n+\t\t\t/*\n+\t\t\t * SPARSEMEM_VMEMMAP & v4.19 kernel or later,\n+\t\t\t * or RHEL8 or SLE-15-SP1\n+\t\t\t */\n+\t\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;\n \t} else if (THIS_KERNEL_VERSION >= LINUX(3,7,0))\n \t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_3_7;\n \telse\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 599a6579aa916df7800f8e889d68e4287e4520dd Mon Sep 17 00:00:00 2001\nFrom: Hari Bathini \nDate: Thu, 27 Sep 2018 02:06:49 +0530\nSubject: ppc64: increase MAX_PHYSMEM_BITS to 128TB\nUpstream: no, adapts the below upstream commit for SLE15 SP1\nGit-commit: 599a6579aa916df7800f8e889d68e4287e4520dd\n\nWith Linux 4.19-rc1 commit 7d4340bb92a9df78e6e28152f3dd89d9bd82146b,\ntitled \"powerpc/mm: Increase MAX_PHYSMEM_BITS to 128TB with\nSPARSEMEM_VMEMMAP config\", the PPC64 MAX_PHYSMEM_BITS value has been\nbumped up to 47. The appropriate update has been made in this patch.\n(hbathini@linux.ibm.com)\n\n[note: apply on 4.12+ for SLE 15 SP1 - incompatible with SLE 15 SP0]\n---\n\nIndex: crash-7.2.8/defs.h\n===================================================================\n--- crash-7.2.8.orig/defs.h\n+++ crash-7.2.8/defs.h\n@@ -6896,6 +6896,9 @@ extern struct lkcd_environment *lkcd;\n #define is_SLES9() \\\n \t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n \n+#define is_SLE15SP1() \\\n+\t((THIS_KERNEL_VERSION >= LINUX(4,12,0)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\nIndex: crash-7.2.8/ppc64.c\n===================================================================\n--- crash-7.2.8.orig/ppc64.c\n+++ crash-7.2.8/ppc64.c\n@@ -244,9 +244,14 @@ static int set_ppc64_max_physmem_bits(vo\n \t\t */\n \t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_20;\n \t} else if ((machdep->flags & VMEMMAP) &&\n-\t ((THIS_KERNEL_VERSION >= LINUX(4,19,0)) || is_RHEL8())) {\n-\t\t/* SPARSEMEM_VMEMMAP & v4.19 kernel or later, or RHEL8 */\n-\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;\n+\t ((THIS_KERNEL_VERSION >= LINUX(4,19,0)) ||\n+\t\tis_RHEL8() ||\n+\t\tis_SLE15SP1())) {\n+\t\t\t/*\n+\t\t\t * SPARSEMEM_VMEMMAP & v4.19 kernel or later,\n+\t\t\t * or RHEL8 or SLE-15-SP1\n+\t\t\t */\n+\t\t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;\n \t} else if (THIS_KERNEL_VERSION >= LINUX(3,7,0))\n \t\tmachdep->max_physmem_bits = _MAX_PHYSMEM_BITS_3_7;\n \telse\n"}], "metadata": {"id": "crash-16042-crash-SLE15-SP1-With-Linux-4.19-rc1-up-MAX_PHYSMEM_BITS-to-128TB.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-SLE15-SP1-With-Linux-4.19-rc1-up-MAX_PHYSMEM_BITS-to-128TB.patch", "tier": "identical", "language": "c", "patch_lines_changed": 14, "patch_files_count": 2, "total_tokens_est": 1176, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-16042-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 417, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- b/defs.h\n- b/kernel.c\n- b/task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 692-798]\n```c\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n (((kt->p2m_mapping_cache[c].mapping - kt->phys_to_machine_mapping)/PAGESIZE()) \\\n * XEN_PFNS_PER_PAGE))\n\tulong last_mapping_read;\n\tulong p2m_cache_index;\n\tulong p2m_pages_searched;\n\tulong p2m_mfn_cache_hits;\n\tulong p2m_page_cache_hits;\n\tulong relocate;\n\tchar *module_tree;\n\tstruct pvops_xen_info {\n\t\tint p2m_top_entries;\n\t\tulong p2m_top;\n\t\tulong p2m_mid_missing;\n\t\tulong p2m_missing;\n\t} pvops_xen;\n\tint highest_irq;\n#define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n#define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n\tint ikconfig_flags;\n\tint ikconfig_ents;\n\tchar *hypervisor;\n\tstruct vmcoreinfo_data {\n\t\tulong log_buf_SYMBOL;\n\t\tulong log_end_SYMBOL;\n\t\tulong log_buf_len_SYMBOL;\n\t\tulong logged_chars_SYMBOL;\n\t\tulong log_first_idx_SYMBOL;\n\t\tulong log_next_idx_SYMBOL;\n\t\tlong log_SIZE;\n\t\tlong log_ts_nsec_OFFSET;\n\t\tlong log_len_OFFSET;\n\t\tlong log_text_len_OFFSET;\n\t\tlong log_dict_len_OFFSET;\n\t\tulong phys_base_SYMBOL;\n\t\tulong _stext_SYMBOL;\n\t} vmcoreinfo;\n\tulonglong flags2;\n\tchar *source_tree;\n\tstruct timespec boot_date;\n};\n\n/*\n * Aid for the two versions of the kernel's module list linkage.\n */\n#define NEXT_MODULE(next_module, modbuf) \\\n{ \\\n switch (kt->flags & (KMOD_V1|KMOD_V2)) \\\n { \\\n case KMOD_V1: \\\n next_module = ULONG(modbuf + OFFSET(module_next)); \\\n break; \\\n case KMOD_V2: \\\n next_module = ULONG(modbuf + OFFSET(module_list)); \\\n if (next_module != kt->kernel_module) \\\n next_module -= OFFSET(module_list); \\\n break; \\\n } \\\n}\n\n```\n\n#### region() [lines 6839-6945]\n```c\nint vmware_vmss_init(char *filename, FILE *ofp);\nuint vmware_vmss_page_size(void);\nint read_vmware_vmss(int, void *, int, ulong, physaddr_t);\nint write_vmware_vmss(int, void *, int, ulong, physaddr_t);\nvoid vmware_vmss_display_regs(int, FILE *);\nvoid get_vmware_vmss_regs(struct bt_info *, ulong *, ulong *);\nint vmware_vmss_memory_dump(FILE *);\nvoid dump_registers_for_vmss_dump(void);\nint vmware_vmss_valid_regs(struct bt_info *);\nint vmware_vmss_get_nr_cpus(void);\nint vmware_vmss_get_cr3_cr4_idtr(int, ulong *, ulong *, ulong *);\nint vmware_vmss_phys_base(ulong *phys_base);\nint vmware_vmss_set_phys_base(ulong);\n\n/*\n * vmware_guestdump.c\n */\nint is_vmware_guestdump(char *filename);\nint vmware_guestdump_init(char *filename, FILE *ofp);\nint vmware_guestdump_memory_dump(FILE *);\n\n/*\n * kaslr_helper.c\n */\nint calc_kaslr_offset(ulong *, ulong *);\n\n/*\n * printk.c\n */\nvoid dump_lockless_record_log(int);\n\n\n/* ... truncated ... */\n```\n\n### kernel.c\n\n#### kernel_init() [lines 101-823]\n```c\n * Gather a few kernel basics.\n */\nvoid\nkernel_init()\n{\n\tint i, c;\n\tchar *p1, *p2, buf[BUFSIZE];\n\tstruct syment *sp1, *sp2;\n\tchar *rqstruct;\n\tchar *rq_timestamp_name = NULL;\n\tchar *irq_desc_type_name;\t\n\tulong pv_init_ops;\n\tstruct gnu_request req;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (!(kt->cpu_flags = (ulong *)calloc(NR_CPUS, sizeof(ulong))))\n error(FATAL, \"cannot malloc cpu_flags array\");\n\n\tcpu_maps_init();\n\n\tkt->stext = symbol_value(\"_stext\");\n\tkt->etext = symbol_value(\"_etext\");\n\tget_text_init_space(); \n\tif (symbol_exists(\"__init_begin\")) {\n\t\tkt->init_begin = symbol_value(\"__init_begin\");\n\t\tkt->init_end = symbol_value(\"__init_end\");\n\t}\n\tkt->end = highest_bss_symbol();\n\tif ((sp1 = kernel_symbol_search(\"_end\")) && (sp1->value > kt->end)) \n\t\tkt->end = sp1->value;\n\n\tcheck_vmcoreinfo();\n\t\n\t/*\n\t * For the traditional (non-pv_ops) Xen architecture, default to writable \n * page tables unless:\n\t * \n\t * (1) it's an \"xm save\" CANONICAL_PAGE_TABLES dumpfile, or\n/* ... 147 lines omitted ... */\n\t\t\t*p2 = NULLCHAR;\n\t\t\tkt->kernel_version[2] = atoi(p1);\n\t\t} else\n\t\t\tkt->kernel_version[2] = 0;\n\n\t\tif (CRASHDEBUG(1))\n\t\t\tfprintf(fp, \"base kernel version: %d.%d.%d\\n\",\n\t\t\t\tkt->kernel_version[0],\n\t\t\t\tkt->kernel_version[1],\n\t\t\t\tkt->kernel_version[2]);\n\t} else\n\t\terror(INFO, \"cannot determine base kernel version\\n\");\n\n\n\tverify_version();\n\n\tif (symbol_exists(\"__per_cpu_offset\")) {\n\t\tif (LKCD_KERNTYPES())\n\t\t\ti = get_cpus_possible();\n\t\telse\n\t\t\ti = get_array_length(\"__per_cpu_offset\", NULL, 0);\n\t\tget_symbol_data(\"__per_cpu_offset\",\n\t\t\tsizeof(long)*((i && (i <= NR_CPUS)) ? i : NR_CPUS),\n\t\t\t&kt->__per_cpu_offset[0]);\n kt->flags |= PER_CPU_OFF;\n\t}\n/* ... 490 lines omitted ... */\n\tMEMBER_OFFSET_INIT(hrtimer_softexpires, \"hrtimer\", \"_softexpires\");\n\tMEMBER_OFFSET_INIT(hrtimer_function, \"hrtimer\", \"function\");\n\n\tMEMBER_OFFSET_INIT(ktime_t_tv64, \"ktime\", \"tv64\");\n\tif (INVALID_MEMBER(ktime_t_tv64))\n\t\tMEMBER_OFFSET_INIT(ktime_t_tv64, \"ktime_t\", \"tv64\");\n\tMEMBER_OFFSET_INIT(ktime_t_sec, \"ktime\", \"sec\");\n\tif (INVALID_MEMBER(ktime_t_sec))\n\t\tMEMBER_OFFSET_INIT(ktime_t_sec, \"ktime_t\", \"sec\");\n\tMEMBER_OFFSET_INIT(ktime_t_nsec, \"ktime\", \"nsec\");\n\tif (INVALID_MEMBER(ktime_t_nsec))\n\t\tMEMBER_OFFSET_INIT(ktime_t_nsec, \"ktime_t\", \"nsec\");\n\n\tif (kt->source_tree)\n\t\tsource_tree_init();\n\n\tkt->flags &= ~PRE_KERNEL_INIT;\n}\n\n/*\n```\n\n#### get_uptime() [lines 5718-5756]\n```c\n * Calculate and return the uptime.\n */\nchar *\nget_uptime(char *buf, ulonglong *j64p)\n{\n\tulong jiffies, tmp1, tmp2;\n\tulonglong jiffies_64, wrapped;\n\n\tif (symbol_exists(\"jiffies_64\")) {\n\t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n\t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n\t\t\tif (wrapped) {\n\t\t\t\twrapped -= 0x100000000ULL;\n\t\t\t\tjiffies_64 &= 0x00000000ffffffffULL;\n\t\t\t\tjiffies_64 |= wrapped;\n \t\tjiffies_64 += (ulonglong)(300*machdep->hz);\n\t\t\t} else {\n\t\t\t\ttmp1 = (ulong)(uint)(-300*machdep->hz);\n\t\t\t\ttmp2 = (ulong)jiffies_64;\n\t\t\t\tjiffies_64 = (ulonglong)(tmp2 - tmp1);\n\t\t\t}\n\t\t}\n\t\tif (buf)\n\t\t\tconvert_time(jiffies_64, buf);\n\t\tif (j64p)\n\t\t\t*j64p = jiffies_64;\n\t} else {\n\t\tget_symbol_data(\"jiffies\", sizeof(long), &jiffies);\n\t\tif (buf)\n\t\t\tconvert_time((ulonglong)jiffies, buf);\n\t\tif (j64p)\n\t\t\t*j64p = (ulonglong)jiffies;\n\t}\n\n\treturn buf;\n}\n\n#define FSHIFT 11 /* nr of bits of precision */\n```\n\n#### region() [lines 6201-6221]\n```c\n\t\t}\n\t\tfprintf(fp, \"%lx \", kt->cpu_flags[i]);\n\t\tfor (j = i, more = FALSE; j < nr_cpus; j++) {\n\t\t\tif (kt->cpu_flags[j])\n\t\t\t\tmore = TRUE;\n\t\t}\n\t\tif (!more) {\n\t\t\tfprintf(fp, \"...\");\n\t\t\tbreak;\n\t\t}\n\t}\n\tfprintf(fp, \"\\n\");\n\tfprintf(fp, \" possible cpus: \");\n\tif (cpu_map_addr(\"possible\")) {\n\t\tfor (i = c = 0; i < nr_cpus; i++) {\n\t\t\tif (kt->cpu_flags[i] & POSSIBLE_MAP) {\n\t\t\t\tfprintf(fp, \"%d \", i);\n\t\t\t\tc++;\n\t\t\t}\n\t\t}\n\t\tfprintf(fp, \"%s\\n\", c ? \"\" : \"(none)\");\n```\n\n### task.c\n\n#### start_time_timespec() [lines 4532-4545]\n```c\n \t\ttsp->tc = tc;\n\n\t\tif (BITS32() && (SIZE(task_struct_start_time) == 8)) {\n\t\t\tif (start_time_timespec())\n\t\t\t\ttsp->start_time = \n\t\t\t\t\tULONG(tt->task_struct +\n\t\t\t\t\tOFFSET(task_struct_start_time));\n\t\t\telse\n\t\t\t\ttsp->start_time = \n\t\t\t\t\tULONGLONG(tt->task_struct +\n\t\t\t\t\tOFFSET(task_struct_start_time));\n\t\t} else {\n\t\t\tstart_time_timespec();\n\t\t\ttsp->start_time = ULONG(tt->task_struct +\n```\n\n#### convert_start_time() [lines 4613-4641]\n```c\n for (i = 0, tsp = task_start_times; i < tasks; i++, tsp++) {\n\t\tprint_task_header(fp, tsp->tc, 0);\n\t\tfprintf(fp, \" RUN TIME: %s\\n\", symbol_exists(\"jiffies_64\") ? \n\t\t\tconvert_time(convert_start_time(tsp->start_time, jiffies_64), buf1) :\n\t\t\tconvert_time(jiffies - tsp->start_time, buf1));\n\t\tfprintf(fp, \" START TIME: %llu\\n\", tsp->start_time); \n\t\tif (VALID_MEMBER(task_struct_times)) {\n\t\t\tfprintf(fp, \" USER TIME: %ld\\n\", tsp->tms_utime);\n\t\t\tfprintf(fp, \" SYSTEM TIME: %ld\\n\\n\", tsp->tms_stime);\n\t\t} else if (VALID_MEMBER(task_struct_utime)) {\n\t\t\tif (use_utime_stime) {\n\t\t\t\tfprintf(fp, \" UTIME: %lld\\n\", \n\t\t\t\t\t(ulonglong)tsp->utime);\n\t\t\t\tfprintf(fp, \" STIME: %lld\\n\\n\", \n\t\t\t\t\t(ulonglong)tsp->stime);\n\t\t\t} else if (use_kernel_timeval) {\n\t\t\t\tfprintf(fp, \" USER TIME: %d\\n\", \n\t\t\t\t\ttsp->kutime.tv_sec);\n\t\t\t\tfprintf(fp, \" SYSTEM TIME: %d\\n\\n\", \n\t\t\t\t\ttsp->kstime.tv_sec);\n\t\t\t} else {\n\t\t\t\tfprintf(fp, \" USER TIME: %ld\\n\", \n\t\t\t\t\ttsp->old_utime.tv_sec);\n\t\t\t\tfprintf(fp, \" SYSTEM TIME: %ld\\n\\n\", \n\t\t\t\t\ttsp->old_stime.tv_sec);\n\t\t\t}\n\t\t}\n\t}\n\tFREEBUF(task_start_times);\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\nIndex: b/defs.h\n===================================================================\n--- a/defs.h\n+++ b/defs.h\n@@ -741,6 +741,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -6888,6 +6889,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\nIndex: b/kernel.c\n===================================================================\n--- a/kernel.c\n+++ b/kernel.c\n@@ -297,6 +297,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -5617,7 +5623,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -6213,6 +6219,7 @@ no_cpu_flags:\n \t\t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \t\tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n \t}\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\nIndex: b/task.c\n===================================================================\n--- a/task.c\n+++ b/task.c\n@@ -4631,6 +4631,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -4667,6 +4673,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC | START_TIME_NSECS))\n {\n \tcase START_TIME_NSECS:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\nIndex: b/defs.h\n===================================================================\n--- a/defs.h\n+++ b/defs.h\n@@ -741,6 +741,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -6888,6 +6889,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\nIndex: b/kernel.c\n===================================================================\n--- a/kernel.c\n+++ b/kernel.c\n@@ -297,6 +297,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -5617,7 +5623,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -6213,6 +6219,7 @@ no_cpu_flags:\n \t\t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \t\tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n \t}\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\nIndex: b/task.c\n===================================================================\n--- a/task.c\n+++ b/task.c\n@@ -4631,6 +4631,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -4667,6 +4673,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC | START_TIME_NSECS))\n {\n \tcase START_TIME_NSECS:\n"}], "metadata": {"id": "crash-16042-crash-sles9-time.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 3, "total_tokens_est": 1658, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 532-638]\n```c\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n{\n\tchar kernel[BUFSIZE];\n\tchar buffer[BUFSIZE];\n\tchar **searchdirs;\n\tint i, preferred, wrapped;\n DIR *dirp;\n struct dirent *dp;\n\tint found;\n\n\tpc->flags |= FINDKERNEL;\n\n\tfflush(fp);\n\n\tif (!file_exists(\"/proc/version\", NULL)) {\n\t\terror(INFO, \n\t\t \"/proc/version: %s: cannot determine booted kernel\\n\",\n\t\t\tstrerror(ENOENT));\n\t\treturn FALSE;\n\t}\n\n\tif (!get_proc_version()) {\n error(INFO, \"/proc/version: %s\\n\", strerror(errno));\n return FALSE;\n\t}\n\n if (CRASHDEBUG(1))\n fprintf(fp, \"\\nfind_booted_kernel: search for [%s]\\n\", \n\t\t\tkt->proc_version);\n\n searchdirs = build_searchdirs(CREATE, &preferred);\n\n\tfor (i = preferred, wrapped = found = FALSE; !found; i++) { \n\t\tif (!searchdirs[i]) {\n\t\t\tif (preferred && !wrapped) {\n\t\t\t\twrapped = TRUE;\n\t\t\t\ti = 0;\n\t\t\t} else\n\t\t\t\tbreak;\n\t\t} else if (wrapped && (preferred == i))\n\t\t\tbreak;\n\t\n\t dirp = opendir(searchdirs[i]);\n\t\tif (!dirp)\n\t\t\tcontinue;\n\t for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {\n\t\t\tif (dp->d_name[0] == '.')\n\t\t\t\tcontinue;\n\n\t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n\n\t\t\tif (mount_point(kernel) ||\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: crash-7.2.7/filesys.c\n===================================================================\n--- crash-7.2.7.orig/filesys.c\n+++ crash-7.2.7/filesys.c\n@@ -581,6 +581,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -630,16 +631,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_kernel(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_kernel(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -659,10 +668,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: crash-7.2.7/filesys.c\n===================================================================\n--- crash-7.2.7.orig/filesys.c\n+++ crash-7.2.7/filesys.c\n@@ -581,6 +581,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -630,16 +631,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_kernel(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_kernel(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -659,10 +668,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n"}], "metadata": {"id": "crash-16042-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 26, "patch_files_count": 1, "total_tokens_est": 1143, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nThis patch fix a problem that crash cannot open a dumpfile which is\n\n## Package\ncrash\n\n## Files to modify\n- b/symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symname_hash_install() [lines 1131-1160]\n```c\n * Install a single static kernel symbol into the symname_hash.\n */\nstatic void\nsymname_hash_install(struct syment *spn)\n{\n\tstruct syment *sp;\n int index;\n\n index = SYMNAME_HASH_INDEX(spn->name);\n\tspn->cnt = 1;\n\n if ((sp = st->symname_hash[index]) == NULL) \n \tst->symname_hash[index] = spn;\n\telse {\n\t\twhile (sp) {\n\t \tif (STREQ(sp->name, spn->name)) {\n\t \tsp->cnt++;\n\t \tspn->cnt++;\n\t \t}\n\t\t\tif (sp->name_hash_next)\n\t\t\t\tsp = sp->name_hash_next;\n\t\t\telse {\n\t\t\t\tsp->name_hash_next = spn;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n```\n\n\n### Type definitions\n\n```c\n/* from defs.h */\nstruct syment {\n ulong value;\n char *name;\n\tstruct syment *val_hash_next;\n\tstruct syment *name_hash_next;\n\tchar type;\n\tunsigned char cnt;\n\tunsigned char flags;\n\tunsigned char pad2;\n};\n```\n\n\n## Upstream Fix\n```diff\nThis patch fix a problem that crash cannot open a dumpfile which is\ncaptured by sadump in KASLR enabled kernel.\n\nWhen KASLR feature is enabled, a kernel is placed on the memory randomly\nand therefore crash cannot open a dumpfile captured by sadump because\naddresses of kernel symbols in System.map or vmlinux are different from\nactual addresses.\n\nTo solve this problem, we need to calculate kaslr offset(the difference\nbetween original symbol address and actual address) and phys_base, and\nadjust symbol table of crash. In the case of dumpfile of kdump, these\ninformation is included in the header, but dumpfile of sadump does not\nhave such a information.\n\nThis patch calculate kaslr offset and phys_base to solve this problem.\nPlease see the comment in the calc_kaslr_offset() for the detail idea.\nThe basic idea is getting register (IDTR and CR3) from dump header, and\ncalculate kaslr_offset/phys_base using them.\n\nSigned-off-by: Takao Indoh \n---\n symbols.c | 3 +++\n 1 file changed, 3 insertions(+)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -1156,6 +1156,9 @@ symname_hash_install(struct syment *spn)\n \t\t\t}\n \t\t}\n \t}\n+\n+\tif (SADUMP_DUMPFILE())\n+\t\tkt->flags2 |= KASLR_CHECK;\n }\n \n /*\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "This patch fix a problem that crash cannot open a dumpfile which is\ncaptured by sadump in KASLR enabled kernel.\n\nWhen KASLR feature is enabled, a kernel is placed on the memory randomly\nand therefore crash cannot open a dumpfile captured by sadump because\naddresses of kernel symbols in System.map or vmlinux are different from\nactual addresses.\n\nTo solve this problem, we need to calculate kaslr offset(the difference\nbetween original symbol address and actual address) and phys_base, and\nadjust symbol table of crash. In the case of dumpfile of kdump, these\ninformation is included in the header, but dumpfile of sadump does not\nhave such a information.\n\nThis patch calculate kaslr offset and phys_base to solve this problem.\nPlease see the comment in the calc_kaslr_offset() for the detail idea.\nThe basic idea is getting register (IDTR and CR3) from dump header, and\ncalculate kaslr_offset/phys_base using them.\n\nSigned-off-by: Takao Indoh \n---\n symbols.c | 3 +++\n 1 file changed, 3 insertions(+)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -1156,6 +1156,9 @@ symname_hash_install(struct syment *spn)\n \t\t\t}\n \t\t}\n \t}\n+\n+\tif (SADUMP_DUMPFILE())\n+\t\tkt->flags2 |= KASLR_CHECK;\n }\n \n /*\n"}], "metadata": {"id": "crash-16042-crash-allow-use-of-sadump-captured-KASLR-kernel.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-allow-use-of-sadump-captured-KASLR-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 3, "patch_files_count": 1, "total_tokens_est": 856, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- Makefile\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \tif [ \"${ARCH}\" = \"x86_64\" ] && [ \"${TARGET}\" = \"PPC64\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n \t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \tif [ \"${ARCH}\" = \"x86_64\" ] && [ \"${TARGET}\" = \"PPC64\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n \t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n"}], "metadata": {"id": "crash-16042-crash-patch-gdb.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-patch-gdb.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 7, "patch_files_count": 1, "total_tokens_est": 769, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2020-14356, CVE-2020-14331, CVE-2020-16166, CVE-2020-10135, CVE-2020-0305, CVE-2020-15780, CVE-2020-10781\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: crash-7.2.7/gdb-7.6.patch\n===================================================================\n--- crash-7.2.7.orig/gdb-7.6.patch\n+++ crash-7.2.7/gdb-7.6.patch\n@@ -41,6 +41,16 @@ exit 0\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: crash-7.2.7/gdb-7.6.patch\n===================================================================\n--- crash-7.2.7.orig/gdb-7.6.patch\n+++ crash-7.2.7/gdb-7.6.patch\n@@ -41,6 +41,16 @@ exit 0\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-13737-crash-missing-declarations.patch", "cve_id": "CVE-2020-14356", "cves": ["CVE-2020-0305", "CVE-2020-10135", "CVE-2020-10781", "CVE-2020-14331", "CVE-2020-14356", "CVE-2020-15780", "CVE-2020-16166"], "package": "crash", "incident_id": 13737, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 1, "total_tokens_est": 566, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2020-14356, CVE-2020-14331, CVE-2020-16166, CVE-2020-10135, CVE-2020-0305, CVE-2020-15780, CVE-2020-10781\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- Makefile\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \tif [ \"${ARCH}\" = \"x86_64\" ] && [ \"${TARGET}\" = \"PPC64\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n \t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \tif [ \"${ARCH}\" = \"x86_64\" ] && [ \"${TARGET}\" = \"PPC64\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n \t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n"}], "metadata": {"id": "crash-13737-crash-patch-gdb.patch", "cve_id": "CVE-2020-14356", "cves": ["CVE-2020-0305", "CVE-2020-10135", "CVE-2020-10781", "CVE-2020-14331", "CVE-2020-14356", "CVE-2020-15780", "CVE-2020-16166"], "package": "crash", "incident_id": 13737, "patch_name": "crash-patch-gdb.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 7, "patch_files_count": 1, "total_tokens_est": 713, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2020-14356, CVE-2020-14331, CVE-2020-16166, CVE-2020-10135, CVE-2020-0305, CVE-2020-15780, CVE-2020-10781\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- CFLAGS.extra\n- LDFLAGS.extra\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n"}], "metadata": {"id": "crash-13737-crash_enable_snappy_support.patch", "cve_id": "CVE-2020-14356", "cves": ["CVE-2020-0305", "CVE-2020-10135", "CVE-2020-10781", "CVE-2020-14331", "CVE-2020-14356", "CVE-2020-15780", "CVE-2020-16166"], "package": "crash", "incident_id": 13737, "patch_name": "crash_enable_snappy_support.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 4, "patch_files_count": 2, "total_tokens_est": 357, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- CFLAGS.extra\n- LDFLAGS.extra\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n"}], "metadata": {"id": "crash-16042-crash_enable_snappy_support.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash_enable_snappy_support.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 4, "patch_files_count": 2, "total_tokens_est": 413, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: crash-7.2.7/gdb-7.6.patch\n===================================================================\n--- crash-7.2.7.orig/gdb-7.6.patch\n+++ crash-7.2.7/gdb-7.6.patch\n@@ -41,6 +41,16 @@ exit 0\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: crash-7.2.7/gdb-7.6.patch\n===================================================================\n--- crash-7.2.7.orig/gdb-7.6.patch\n+++ crash-7.2.7/gdb-7.6.patch\n@@ -41,6 +41,16 @@ exit 0\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-16042-crash-missing-declarations.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 1, "total_tokens_est": 621, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nextensions/eppic.mk | 26\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-16042-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2020-14356, CVE-2020-14331, CVE-2020-16166, CVE-2020-10135, CVE-2020-0305, CVE-2020-15780, CVE-2020-10781\n\nextensions/eppic.mk | 26\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-13737-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2020-14356", "cves": ["CVE-2020-0305", "CVE-2020-10135", "CVE-2020-10781", "CVE-2020-14331", "CVE-2020-14356", "CVE-2020-15780", "CVE-2020-16166"], "package": "crash", "incident_id": 13737, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2021-3444, CVE-2021-3428, CVE-2021-29647, CVE-2021-29265, CVE-2021-29264, CVE-2021-28972, CVE-2021-28971, CVE-2021-28964, CVE-2021-28688, CVE-2021-28660, CVE-2021-28375, CVE-2021-28038, CVE-2021-27365, CVE-2021-27364, CVE-2021-27363, CVE-2020-35519, CVE-2020-27815, CVE-2020-27171, CVE-2020-27170, CVE-2019-19769, CVE-2019-18814\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-16042-crash_enable_lzo_support.patch", "cve_id": "CVE-2021-3444", "cves": ["CVE-2019-18814", "CVE-2019-19769", "CVE-2020-27170", "CVE-2020-27171", "CVE-2020-27815", "CVE-2020-35519", "CVE-2021-27363", "CVE-2021-27364", "CVE-2021-27365", "CVE-2021-28038", "CVE-2021-28375", "CVE-2021-28660", "CVE-2021-28688", "CVE-2021-28964", "CVE-2021-28971", "CVE-2021-28972", "CVE-2021-29264", "CVE-2021-29265", "CVE-2021-29647", "CVE-2021-3428", "CVE-2021-3444"], "package": "crash", "incident_id": 16042, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2020-14356, CVE-2020-14331, CVE-2020-16166, CVE-2020-10135, CVE-2020-0305, CVE-2020-15780, CVE-2020-10781\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-13737-crash_enable_lzo_support.patch", "cve_id": "CVE-2020-14356", "cves": ["CVE-2020-0305", "CVE-2020-10135", "CVE-2020-10781", "CVE-2020-14331", "CVE-2020-14356", "CVE-2020-15780", "CVE-2020-16166"], "package": "crash", "incident_id": 13737, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 522-628]\n```c\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n{\n\tchar kernel[BUFSIZE];\n\tchar buffer[BUFSIZE];\n\tchar **searchdirs;\n\tint i, preferred, wrapped;\n DIR *dirp;\n struct dirent *dp;\n\tint found;\n\n\tpc->flags |= FINDKERNEL;\n\n\tfflush(fp);\n\n\tif (!file_exists(\"/proc/version\", NULL)) {\n\t\terror(INFO, \n\t\t \"/proc/version: %s: cannot determine booted kernel\\n\",\n\t\t\tstrerror(ENOENT));\n\t\treturn FALSE;\n\t}\n\n\tif (!get_proc_version()) {\n error(INFO, \"/proc/version: %s\\n\", strerror(errno));\n return FALSE;\n\t}\n\n if (CRASHDEBUG(1))\n fprintf(fp, \"\\nfind_booted_kernel: search for [%s]\\n\", \n\t\t\tkt->proc_version);\n\n searchdirs = build_searchdirs(CREATE, &preferred);\n\n\tfor (i = preferred, wrapped = found = FALSE; !found; i++) { \n\t\tif (!searchdirs[i]) {\n\t\t\tif (preferred && !wrapped) {\n\t\t\t\twrapped = TRUE;\n\t\t\t\ti = 0;\n\t\t\t} else\n\t\t\t\tbreak;\n\t\t} else if (wrapped && (preferred == i))\n\t\t\tbreak;\n\t\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -571,6 +571,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -620,16 +621,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -649,10 +658,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -571,6 +571,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -620,16 +621,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -649,10 +658,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n"}], "metadata": {"id": "crash-8217-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 26, "patch_files_count": 0, "total_tokens_est": 1005, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -204,9 +204,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -268,13 +268,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -295,14 +298,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -204,9 +204,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -268,13 +268,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -295,14 +298,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-8217-crash-debuginfo-compressed.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 0, "total_tokens_est": 1173, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: David Mair \n\n## Package\ncrash\n\n## Files to modify\n- Makefile\n\n## Upstream Fix\n```diff\nFrom: David Mair \nDate: 2017-03-28 17:17:25.532260682 -0600\nSubject: Add application of GLIBC proc_service prototype cleanup from upstream\nReferences: bnc#1029318 bnc#1022962\nUpstream: tbd (crash); merged (gdb)\n\ncrash source nests gdb source but crash/gdb has a newly seen build error on\nsome cases due to a \"cause\" and a new build environment. The cause is that the\nfunction prototype for extern ps_get_thread_area() in GLIBC/proc_service has a\nnon-const first argument but implementations in crash's gdb have a const first\nargument. Then gcc considers the definition as for a different function from\nthe declaration (conflicting types for 'ps_get_thread_area').\n\nThe fix is in upstream gdb (current):\n\nhttps://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=754653a7c0a43a668a38aa30c4063b9e292a19f9\n\n...but not upstream crash's gdb (older).\n\nCreated crash patch:\n\ncrash-gdb-add-proc_service-sync-with-GLIBC.patch\n\n...to create a context fixed version of the gdb patch in expanded crash and\nadded it's application to the gdb Makefile patch. Note that \"fixed\" means\nmaking it applicable to the older version of gdb in crash rather than the gdb\nversion the upstream gdb patch was intended for. Resolves the build error\ncauses I'm aware of.\n\nI will make a public submission to crash upstream right away but there it will\nprobably be of the nested content rather than this patch of a patch. Upstream\ngenerates the source tarball and the method used here was to avoid creating a\nunique case of the source tarball containing the patch.\n\n---\n Makefile | 1 +\n gdb-7.6-sync-proc_service-definition-with-GLIBC.patch | 277 +++++++++++++++++++\n 2 file changed, 278 insertions(+)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,9 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n \tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-sync-proc_service-definition-with-GLIBC.patch ; \\\n \tif [ -f ${GDB}.series ]; then \\\n \t\twhile read p; do \\\n \t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n \t\tdone < ${GDB}.series ; \\\n--- /dev/null\n+++ b/gdb-7.6-sync-proc_service-definition-with-GLIBC.patch\n@@ -0,0 +1,277 @@\n+From 754653a7c0a43a668a38aa30c4063b9e292a19f9 Mon Sep 17 00:00:00 2001\n+From: Adhemerval Zanella \n+Date: Thu, 25 Aug 2016 08:42:03 +0100\n+Subject: [PATCH] Sync proc_service definition with GLIBC\n+\n+GLIBC BZ#20311 [1] proc_service.h install patch also remove 'const'\n+attributes from ps_get_thread_area and comment #15 discuss why to remove\n+the const attribute (basically since it a callback with the struct\n+ps_prochandle owned by the client it should be able to modify it if\n+it the case).\n+\n+On default build this is not the issue and current g++ does not trigger\n+any issue with this mismatch declaration. However, on some bootstrap\n+build configuration where gdbserver is build with gcc instead this\n+triggers:\n+\n+error: conflicting types for 'ps_get_thread_area'\n+\n+This patch fixes it by syncing the declaration with GLIBC.\n+\n+[1] https://sourceware.org/bugzilla/show_bug.cgi?id=20311\n+\n+gdb/ChangeLog:\n+\n+2016-08-25 Adhemerval Zanella \n+\n+\t* aarch64-linux-nat.c (ps_get_thread_area): Remove const from\n+\tstruct ps_prochandle.\n+\t* amd64-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* arm-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* gdb_proc_service.h (ps_get_thread_area): Likewise.\n+\t* i386-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* m68klinux-nat.c (ps_get_thread_area): Likewise.\n+\t* mips-linux-nat.c (ps_get_thread_area): Likewise.\n+\n+gdb/gdbserver/ChangeLog:\n+\n+2016-08-25 Adhemerval Zanella \n+\n+\tPR server/20491\n+\t* gdb_proc_service.h (ps_get_thread_area): Remove const from struct\n+\tps_prochandle.\n+\t* linux-aarch64-low.c (ps_get_thread_area): Likewise.\n+\t* linux-arm-low.c (ps_get_thread_area): Likewise.\n+\t* linux-m68k-low.c (ps_get_thread_area): Likewise.\n+\t* linux-mips-low.c (ps_get_thread_area): Likewise.\n+\t* linux-tic6x-low.c (ps_get_thread_area): Likewise.\n+\t* linux-x86-low.c (ps_get_thread_area): Likewise.\n+---\n+ gdb/ChangeLog | 14 ++++++++++++++\n+ gdb/aarch64-linux-nat.c | 2 +-\n+ gdb/amd64-linux-nat.c | 2 +-\n+ gdb/arm-linux-nat.c | 2 +-\n+ gdb/gdb_proc_service.h | 2 +-\n+ gdb/gdbserver/ChangeLog | 15 +++++++++++++++\n+ gdb/gdbserver/linux-aarch64-low.c | 2 +-\n+ gdb/gdbserver/linux-arm-low.c | 2 +-\n+ gdb/gdbserver/linux-m68k-low.c | 2 +-\n+ gdb/gdbserver/linux-mips-low.c | 2 +-\n+ gdb/gdbserver/linux-tic6x-low.c | 2 +-\n+ gdb/gdbserver/linux-x86-low.c | 2 +-\n+ gdb/i386-linux-nat.c | 2 +-\n+ gdb/m68klinux-nat.c | 2 +-\n+ gdb/mips-linux-nat.c | 2 +-\n+ 17 files changed, 44 insertions(+), 15 deletions(-)\n+\n+diff --git a/gdb/ChangeLog b/gdb/ChangeLog\n+index 0d875c8..677ed7d 100644\n+--- a/gdb/ChangeLog\n++++ b/gdb/ChangeLog\n+@@ -1,3 +1,14 @@\n++2016-08-25 Adhemerval Zanella \n++\n++\t* aarch64-linux-nat.c (ps_get_thread_area): Remove const from\n++\tstruct ps_prochandle.\n++\t* amd64-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* arm-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* gdb_proc_service.h (ps_get_thread_area): Likewise.\n++\t* i386-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* m68klinux-nat.c (ps_get_thread_area): Likewise.\n++\t* mips-linux-nat.c (ps_get_thread_area): Likewise.\n++\n+ 2013-11-15 Alan Modra \n+ \n+ \t* ppc64-tdep.c (ppc64_plt_entry_point): Renamed from..\n+diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c\n+index e431637..65ca8ff 100644\n+--- a/gdb/aarch64-linux-nat.c\n++++ b/gdb/aarch64-linux-nat.c\n+@@ -750,7 +750,7 @@ aarch64_linux_new_fork (struct lwp_info *parent, pid_t child_pid)\n+ storage (or its descriptor). */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ struct iovec iovec;\n+diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c\n+index fea6ee2..5122b04 100644\n+--- a/gdb/amd64-linux-nat.c\n++++ b/gdb/amd64-linux-nat.c\n+@@ -493,7 +493,7 @@ amd64_linux_store_inferior_registers (struct target_ops *ops,\n+ a request for a thread's local storage address. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (gdbarch_bfd_arch_info (target_gdbarch ())->bits_per_word == 32)\n+diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c\n+index d77ca93..d11bdc6 100644\n+--- a/gdb/arm-linux-nat.c\n++++ b/gdb/arm-linux-nat.c\n+@@ -613,7 +613,7 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h\n+index 38b98fc..0a9f26d 100644\n+--- a/gdb/gdb_proc_service.h\n++++ b/gdb/gdb_proc_service.h\n+@@ -115,7 +115,7 @@ extern pid_t ps_getpid (struct ps_prochandle *);\n+ /* Fetch the special per-thread address associated with the given LWP.\n+ This call is only used on a few platforms (most use a normal register).\n+ The meaning of the `int' parameter is machine-dependent. */\n+-extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,\n++extern ps_err_e ps_get_thread_area (struct ps_prochandle *,\n+ \t\t\t\t lwpid_t, int, psaddr_t *);\n+ \n+ \n+diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog\n+index c28c2cb..af0140f 100644\n+--- a/gdb/gdbserver/ChangeLog\n++++ b/gdb/gdbserver/ChangeLog\n+@@ -1,3 +1,15 @@\n++2016-08-25 Adhemerval Zanella \n++\n++\tPR server/20491\n++\t* gdb_proc_service.h (ps_get_thread_area): Remove const from struct\n++\tps_prochandle.\n++\t* linux-aarch64-low.c (ps_get_thread_area): Likewise.\n++\t* linux-arm-low.c (ps_get_thread_area): Likewise.\n++\t* linux-m68k-low.c (ps_get_thread_area): Likewise.\n++\t* linux-mips-low.c (ps_get_thread_area): Likewise.\n++\t* linux-tic6x-low.c (ps_get_thread_area): Likewise.\n++\t* linux-x86-low.c (ps_get_thread_area): Likewise.\n++\n+ 2013-04-25 Hui Zhu \n+ \n+ \tPR gdb/15186\n+diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c\n+index 6efa035..e54a8ba 100644\n+--- a/gdb/gdbserver/linux-aarch64-low.c\n++++ b/gdb/gdbserver/linux-aarch64-low.c\n+@@ -1089,7 +1089,7 @@ aarch64_stopped_by_watchpoint (void)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ struct iovec iovec;\n+diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c\n+index e1261e5..ed9b356 100644\n+--- a/gdb/gdbserver/linux-arm-low.c\n++++ b/gdb/gdbserver/linux-arm-low.c\n+@@ -325,7 +325,7 @@ get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c\n+index df3d7c6..78a340f 100644\n+--- a/gdb/gdbserver/linux-m68k-low.c\n++++ b/gdb/gdbserver/linux-m68k-low.c\n+@@ -159,7 +159,7 @@ m68k_breakpoint_at (CORE_ADDR pc)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c\n+index 30a03d5..9356bb3 100644\n+--- a/gdb/gdbserver/linux-mips-low.c\n++++ b/gdb/gdbserver/linux-mips-low.c\n+@@ -238,7 +238,7 @@ mips_stopped_data_address (void)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-tic6x-low.c b/gdb/gdbserver/linux-tic6x-low.c\n+index e40a3af..6b90560 100644\n+--- a/gdb/gdbserver/linux-tic6x-low.c\n++++ b/gdb/gdbserver/linux-tic6x-low.c\n+@@ -256,7 +256,7 @@ tic6x_breakpoint_at (CORE_ADDR where)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c\n+index d847b93..acded1a 100644\n+--- a/gdb/gdbserver/linux-x86-low.c\n++++ b/gdb/gdbserver/linux-x86-low.c\n+@@ -164,7 +164,7 @@ is_64bit_tdesc (void)\n+ /* Called by libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ #ifdef __x86_64__\n+diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c\n+index a41ee21..70d954f 100644\n+--- a/gdb/i386-linux-nat.c\n++++ b/gdb/i386-linux-nat.c\n+@@ -849,7 +849,7 @@ i386_linux_new_fork (struct lwp_info *parent, pid_t child_pid)\n+ storage (or its descriptor). */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph, \n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ /* NOTE: cagney/2003-08-26: The definition of this buffer is found\n+diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c\n+index 24b6242..5b8684b 100644\n+--- a/gdb/m68klinux-nat.c\n++++ b/gdb/m68klinux-nat.c\n+@@ -568,7 +568,7 @@ m68k_linux_store_inferior_registers (struct target_ops *ops,\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph, \n++ps_get_thread_area (struct ps_prochandle *ph, \n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) < 0)\n+diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c\n+index bfe9fcb..0f20f16 100644\n+--- a/gdb/mips-linux-nat.c\n++++ b/gdb/mips-linux-nat.c\n+@@ -154,7 +154,7 @@ mips64_linux_register_addr (struct gdbarch *gdbarch, int regno, int store)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+-- \n+2.9.3\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: David Mair \nDate: 2017-03-28 17:17:25.532260682 -0600\nSubject: Add application of GLIBC proc_service prototype cleanup from upstream\nReferences: bnc#1029318 bnc#1022962\nUpstream: tbd (crash); merged (gdb)\n\ncrash source nests gdb source but crash/gdb has a newly seen build error on\nsome cases due to a \"cause\" and a new build environment. The cause is that the\nfunction prototype for extern ps_get_thread_area() in GLIBC/proc_service has a\nnon-const first argument but implementations in crash's gdb have a const first\nargument. Then gcc considers the definition as for a different function from\nthe declaration (conflicting types for 'ps_get_thread_area').\n\nThe fix is in upstream gdb (current):\n\nhttps://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=754653a7c0a43a668a38aa30c4063b9e292a19f9\n\n...but not upstream crash's gdb (older).\n\nCreated crash patch:\n\ncrash-gdb-add-proc_service-sync-with-GLIBC.patch\n\n...to create a context fixed version of the gdb patch in expanded crash and\nadded it's application to the gdb Makefile patch. Note that \"fixed\" means\nmaking it applicable to the older version of gdb in crash rather than the gdb\nversion the upstream gdb patch was intended for. Resolves the build error\ncauses I'm aware of.\n\nI will make a public submission to crash upstream right away but there it will\nprobably be of the nested content rather than this patch of a patch. Upstream\ngenerates the source tarball and the method used here was to avoid creating a\nunique case of the source tarball containing the patch.\n\n---\n Makefile | 1 +\n gdb-7.6-sync-proc_service-definition-with-GLIBC.patch | 277 +++++++++++++++++++\n 2 file changed, 278 insertions(+)\n\n--- a/Makefile\n+++ b/Makefile\n@@ -263,8 +263,9 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n \tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-sync-proc_service-definition-with-GLIBC.patch ; \\\n \tif [ -f ${GDB}.series ]; then \\\n \t\twhile read p; do \\\n \t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n \t\tdone < ${GDB}.series ; \\\n--- /dev/null\n+++ b/gdb-7.6-sync-proc_service-definition-with-GLIBC.patch\n@@ -0,0 +1,277 @@\n+From 754653a7c0a43a668a38aa30c4063b9e292a19f9 Mon Sep 17 00:00:00 2001\n+From: Adhemerval Zanella \n+Date: Thu, 25 Aug 2016 08:42:03 +0100\n+Subject: [PATCH] Sync proc_service definition with GLIBC\n+\n+GLIBC BZ#20311 [1] proc_service.h install patch also remove 'const'\n+attributes from ps_get_thread_area and comment #15 discuss why to remove\n+the const attribute (basically since it a callback with the struct\n+ps_prochandle owned by the client it should be able to modify it if\n+it the case).\n+\n+On default build this is not the issue and current g++ does not trigger\n+any issue with this mismatch declaration. However, on some bootstrap\n+build configuration where gdbserver is build with gcc instead this\n+triggers:\n+\n+error: conflicting types for 'ps_get_thread_area'\n+\n+This patch fixes it by syncing the declaration with GLIBC.\n+\n+[1] https://sourceware.org/bugzilla/show_bug.cgi?id=20311\n+\n+gdb/ChangeLog:\n+\n+2016-08-25 Adhemerval Zanella \n+\n+\t* aarch64-linux-nat.c (ps_get_thread_area): Remove const from\n+\tstruct ps_prochandle.\n+\t* amd64-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* arm-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* gdb_proc_service.h (ps_get_thread_area): Likewise.\n+\t* i386-linux-nat.c (ps_get_thread_area): Likewise.\n+\t* m68klinux-nat.c (ps_get_thread_area): Likewise.\n+\t* mips-linux-nat.c (ps_get_thread_area): Likewise.\n+\n+gdb/gdbserver/ChangeLog:\n+\n+2016-08-25 Adhemerval Zanella \n+\n+\tPR server/20491\n+\t* gdb_proc_service.h (ps_get_thread_area): Remove const from struct\n+\tps_prochandle.\n+\t* linux-aarch64-low.c (ps_get_thread_area): Likewise.\n+\t* linux-arm-low.c (ps_get_thread_area): Likewise.\n+\t* linux-m68k-low.c (ps_get_thread_area): Likewise.\n+\t* linux-mips-low.c (ps_get_thread_area): Likewise.\n+\t* linux-tic6x-low.c (ps_get_thread_area): Likewise.\n+\t* linux-x86-low.c (ps_get_thread_area): Likewise.\n+---\n+ gdb/ChangeLog | 14 ++++++++++++++\n+ gdb/aarch64-linux-nat.c | 2 +-\n+ gdb/amd64-linux-nat.c | 2 +-\n+ gdb/arm-linux-nat.c | 2 +-\n+ gdb/gdb_proc_service.h | 2 +-\n+ gdb/gdbserver/ChangeLog | 15 +++++++++++++++\n+ gdb/gdbserver/linux-aarch64-low.c | 2 +-\n+ gdb/gdbserver/linux-arm-low.c | 2 +-\n+ gdb/gdbserver/linux-m68k-low.c | 2 +-\n+ gdb/gdbserver/linux-mips-low.c | 2 +-\n+ gdb/gdbserver/linux-tic6x-low.c | 2 +-\n+ gdb/gdbserver/linux-x86-low.c | 2 +-\n+ gdb/i386-linux-nat.c | 2 +-\n+ gdb/m68klinux-nat.c | 2 +-\n+ gdb/mips-linux-nat.c | 2 +-\n+ 17 files changed, 44 insertions(+), 15 deletions(-)\n+\n+diff --git a/gdb/ChangeLog b/gdb/ChangeLog\n+index 0d875c8..677ed7d 100644\n+--- a/gdb/ChangeLog\n++++ b/gdb/ChangeLog\n+@@ -1,3 +1,14 @@\n++2016-08-25 Adhemerval Zanella \n++\n++\t* aarch64-linux-nat.c (ps_get_thread_area): Remove const from\n++\tstruct ps_prochandle.\n++\t* amd64-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* arm-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* gdb_proc_service.h (ps_get_thread_area): Likewise.\n++\t* i386-linux-nat.c (ps_get_thread_area): Likewise.\n++\t* m68klinux-nat.c (ps_get_thread_area): Likewise.\n++\t* mips-linux-nat.c (ps_get_thread_area): Likewise.\n++\n+ 2013-11-15 Alan Modra \n+ \n+ \t* ppc64-tdep.c (ppc64_plt_entry_point): Renamed from..\n+diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c\n+index e431637..65ca8ff 100644\n+--- a/gdb/aarch64-linux-nat.c\n++++ b/gdb/aarch64-linux-nat.c\n+@@ -750,7 +750,7 @@ aarch64_linux_new_fork (struct lwp_info *parent, pid_t child_pid)\n+ storage (or its descriptor). */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ struct iovec iovec;\n+diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c\n+index fea6ee2..5122b04 100644\n+--- a/gdb/amd64-linux-nat.c\n++++ b/gdb/amd64-linux-nat.c\n+@@ -493,7 +493,7 @@ amd64_linux_store_inferior_registers (struct target_ops *ops,\n+ a request for a thread's local storage address. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (gdbarch_bfd_arch_info (target_gdbarch ())->bits_per_word == 32)\n+diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c\n+index d77ca93..d11bdc6 100644\n+--- a/gdb/arm-linux-nat.c\n++++ b/gdb/arm-linux-nat.c\n+@@ -613,7 +613,7 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h\n+index 38b98fc..0a9f26d 100644\n+--- a/gdb/gdb_proc_service.h\n++++ b/gdb/gdb_proc_service.h\n+@@ -115,7 +115,7 @@ extern pid_t ps_getpid (struct ps_prochandle *);\n+ /* Fetch the special per-thread address associated with the given LWP.\n+ This call is only used on a few platforms (most use a normal register).\n+ The meaning of the `int' parameter is machine-dependent. */\n+-extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,\n++extern ps_err_e ps_get_thread_area (struct ps_prochandle *,\n+ \t\t\t\t lwpid_t, int, psaddr_t *);\n+ \n+ \n+diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog\n+index c28c2cb..af0140f 100644\n+--- a/gdb/gdbserver/ChangeLog\n++++ b/gdb/gdbserver/ChangeLog\n+@@ -1,3 +1,15 @@\n++2016-08-25 Adhemerval Zanella \n++\n++\tPR server/20491\n++\t* gdb_proc_service.h (ps_get_thread_area): Remove const from struct\n++\tps_prochandle.\n++\t* linux-aarch64-low.c (ps_get_thread_area): Likewise.\n++\t* linux-arm-low.c (ps_get_thread_area): Likewise.\n++\t* linux-m68k-low.c (ps_get_thread_area): Likewise.\n++\t* linux-mips-low.c (ps_get_thread_area): Likewise.\n++\t* linux-tic6x-low.c (ps_get_thread_area): Likewise.\n++\t* linux-x86-low.c (ps_get_thread_area): Likewise.\n++\n+ 2013-04-25 Hui Zhu \n+ \n+ \tPR gdb/15186\n+diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c\n+index 6efa035..e54a8ba 100644\n+--- a/gdb/gdbserver/linux-aarch64-low.c\n++++ b/gdb/gdbserver/linux-aarch64-low.c\n+@@ -1089,7 +1089,7 @@ aarch64_stopped_by_watchpoint (void)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ struct iovec iovec;\n+diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c\n+index e1261e5..ed9b356 100644\n+--- a/gdb/gdbserver/linux-arm-low.c\n++++ b/gdb/gdbserver/linux-arm-low.c\n+@@ -325,7 +325,7 @@ get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c\n+index df3d7c6..78a340f 100644\n+--- a/gdb/gdbserver/linux-m68k-low.c\n++++ b/gdb/gdbserver/linux-m68k-low.c\n+@@ -159,7 +159,7 @@ m68k_breakpoint_at (CORE_ADDR pc)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c\n+index 30a03d5..9356bb3 100644\n+--- a/gdb/gdbserver/linux-mips-low.c\n++++ b/gdb/gdbserver/linux-mips-low.c\n+@@ -238,7 +238,7 @@ mips_stopped_data_address (void)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-tic6x-low.c b/gdb/gdbserver/linux-tic6x-low.c\n+index e40a3af..6b90560 100644\n+--- a/gdb/gdbserver/linux-tic6x-low.c\n++++ b/gdb/gdbserver/linux-tic6x-low.c\n+@@ -256,7 +256,7 @@ tic6x_breakpoint_at (CORE_ADDR where)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c\n+index d847b93..acded1a 100644\n+--- a/gdb/gdbserver/linux-x86-low.c\n++++ b/gdb/gdbserver/linux-x86-low.c\n+@@ -164,7 +164,7 @@ is_64bit_tdesc (void)\n+ /* Called by libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ #ifdef __x86_64__\n+diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c\n+index a41ee21..70d954f 100644\n+--- a/gdb/i386-linux-nat.c\n++++ b/gdb/i386-linux-nat.c\n+@@ -849,7 +849,7 @@ i386_linux_new_fork (struct lwp_info *parent, pid_t child_pid)\n+ storage (or its descriptor). */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph, \n++ps_get_thread_area (struct ps_prochandle *ph,\n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ /* NOTE: cagney/2003-08-26: The definition of this buffer is found\n+diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c\n+index 24b6242..5b8684b 100644\n+--- a/gdb/m68klinux-nat.c\n++++ b/gdb/m68klinux-nat.c\n+@@ -568,7 +568,7 @@ m68k_linux_store_inferior_registers (struct target_ops *ops,\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph, \n++ps_get_thread_area (struct ps_prochandle *ph, \n+ \t\t lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) < 0)\n+diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c\n+index bfe9fcb..0f20f16 100644\n+--- a/gdb/mips-linux-nat.c\n++++ b/gdb/mips-linux-nat.c\n+@@ -154,7 +154,7 @@ mips64_linux_register_addr (struct gdbarch *gdbarch, int regno, int store)\n+ /* Fetch the thread-local storage pointer for libthread_db. */\n+ \n+ ps_err_e\n+-ps_get_thread_area (const struct ps_prochandle *ph,\n++ps_get_thread_area (struct ps_prochandle *ph,\n+ lwpid_t lwpid, int idx, void **base)\n+ {\n+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)\n+-- \n+2.9.3\n+\n"}], "metadata": {"id": "crash-8217-crash-gdb-add-proc_service-sync-with-GLIBC.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-gdb-add-proc_service-sync-with-GLIBC.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 263, "patch_files_count": 0, "total_tokens_est": 6770, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 29 lines omitted ... */\n\t * Get gdb version before initializing it since this might be one \n * of the short-hand commands that need it without running gdb.\n\t */\n\tget_gdb_version();\n\n\t/* \n\t * Set up the default scrolling behavior for terminal output.\n\t */\n\tif (isatty(fileno(stdout))) {\n\t\tif (CRASHPAGER_valid()) {\n\t\t\tpc->flags |= SCROLL;\n\t\t\tpc->scroll_command = SCROLL_CRASHPAGER;\n\t\t} else if (file_exists(\"/usr/bin/less\", NULL)) {\n\t\t\tpc->flags |= SCROLL;\n\t\t\tpc->scroll_command = SCROLL_LESS;\n\t\t} else if (file_exists(\"/bin/more\", NULL)) {\n\t\t\tpc->flags |= SCROLL;\n\t\t\tpc->scroll_command = SCROLL_MORE;\n\t\t} else {\n \tpc->scroll_command = SCROLL_NONE;\n \tpc->flags &= ~SCROLL;\n \t}\n\t} \n\n\t/*\n\t * Setup the readline command line editing mode based upon the \n\t * following order:\n\t *\n\t * (1) EDITOR environment variable\n * (2) overridden by any .crashrc entry: \"set vi\" or \"set emacs\"\n * (3) RL_VI_MODE if not set anywhere else\n\t */\n/* ... 45 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1158,12 +1158,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1213,7 +1207,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1158,12 +1158,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1213,7 +1207,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-8217-crash-make-emacs-default.diff", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 0, "total_tokens_est": 445, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-8217-crash-missing-declarations.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 0, "total_tokens_est": 475, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Hari Krishna Bathini \n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- ppc64.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 3788-3894]\n```c\n\tvoid *mmu_special;\n};\n\n/* machdep flags for ppc32 specific */\n#define IS_PAE()\t\t(machdep->flags & PAE)\n#define IS_BOOKE()\t\t(machdep->flags & CPU_BOOKE)\n/* Page translation bits */\n#define PPC_PLATFORM\t\t(machdep->machspec->platform)\n#define PTE_SIZE\t\t(machdep->machspec->pte_size)\n#define PTE_RPN_SHIFT\t\t(machdep->machspec->pte_rpn_shift)\n#define PAGE_SHIFT\t\t(12)\n#define PTE_T_LOG2\t\t(ffs(PTE_SIZE) - 1)\n#define PTE_SHIFT\t\t(PAGE_SHIFT - PTE_T_LOG2)\n#define PGDIR_SHIFT\t\t(PAGE_SHIFT + PTE_SHIFT)\n#define PTRS_PER_PGD\t\t(1 << (32 - PGDIR_SHIFT))\n#define PTRS_PER_PTE\t\t(1 << PTE_SHIFT)\n/* special vtop */\n#define VTOP_SPECIAL\t\t(machdep->machspec->vtop_special)\n#define MMU_SPECIAL\t\t(machdep->machspec->mmu_special)\n\n/* PFN shifts */\n#define BOOKE3E_PTE_RPN_SHIFT\t(24)\n\n/* PAGE flags */\n#define _PAGE_PRESENT (machdep->machspec->_page_present)\t/* software: pte contains a translation */\n#define _PAGE_USER (machdep->machspec->_page_user)\t\t/* matches one of the PP bits */\n#define _PAGE_RW (machdep->machspec->_page_rw)\t\t/* software: user write access allowed */\n#define _PAGE_GUARDED (machdep->machspec->_page_guarded)\n#define _PAGE_COHERENT (machdep->machspec->_page_coherent\t/* M: enforce memory coherence (SMP systems) */)\n#define _PAGE_NO_CACHE (machdep->machspec->_page_no_cache)\t/* I: cache inhibit */\n#define _PAGE_WRITETHRU (machdep->machspec->_page_writethru)\t/* W: cache write-through */\n#define _PAGE_DIRTY (machdep->machspec->_page_dirty)\t/* C: page changed */\n#define _PAGE_ACCESSED (machdep->machspec->_page_accessed)\t/* R: page referenced */\n#define _PAGE_HWWRITE (machdep->machspec->_page_hwwrite)\t/* software: _PAGE_RW & _PAGE_DIRTY */\n#define _PAGE_SHARED (machdep->machspec->_page_shared)\n#define _PAGE_K_RW\t(machdep->machspec->_page_k_rw)\t\t/* privilege only write access allowed */\n\n/* Default values for PAGE flags */\n#define DEFAULT_PAGE_PRESENT 0x001\n#define DEFAULT_PAGE_USER 0x002\n#define DEFAULT_PAGE_RW 0x004\n#define DEFAULT_PAGE_GUARDED 0x008\n#define DEFAULT_PAGE_COHERENT 0x010\n#define DEFAULT_PAGE_NO_CACHE 0x020\n#define DEFAULT_PAGE_WRITETHRU 0x040\n#define DEFAULT_PAGE_DIRTY 0x080\n#define DEFAULT_PAGE_ACCESSED 0x100\n#define DEFAULT_PAGE_HWWRITE 0x200\n#define DEFAULT_PAGE_SHARED 0\n\n/* PPC44x PAGE flags: Values from kernel asm/pte-44x.h */\n#define PPC44x_PAGE_PRESENT\t0x001\n#define PPC44x_PAGE_RW\t\t0x002\n#define PPC44x_PAGE_ACCESSED\t0x008\n#define PPC44x_PAGE_DIRTY\t0x010\n#define PPC44x_PAGE_USER\t0x040\n#define PPC44x_PAGE_GUARDED\t0x100\n#define PPC44x_PAGE_COHERENT\t0x200\n#define PPC44x_PAGE_NO_CACHE\t0x400\n#define PPC44x_PAGE_WRITETHRU\t0x800\n#define PPC44x_PAGE_HWWRITE\t0\n#define PPC44x_PAGE_SHARED\t0\n\n/* BOOK3E */\n#define BOOK3E_PAGE_PRESENT\t0x000001\n#define BOOK3E_PAGE_BAP_SR\t0x000004\n#define BOOK3E_PAGE_BAP_UR\t0x000008 /* User Readable */\n#define BOOK3E_PAGE_BAP_SW\t0x000010\n#define BOOK3E_PAGE_BAP_UW\t0x000020 /* User Writable */\n#define BOOK3E_PAGE_DIRTY\t0x001000\n#define BOOK3E_PAGE_ACCESSED\t0x040000\n#define BOOK3E_PAGE_GUARDED\t0x100000\n#define BOOK3E_PAGE_COHERENT\t0x200000\n#define BOOK3E_PAGE_NO_CACHE\t0x400000\n#define BOOK3E_PAGE_WRITETHRU\t0x800000\n#define BOOK3E_PAGE_HWWRITE\t0\n#define BOOK3E_PAGE_SHARED\t0\n#define BOOK3E_PAGE_USER\t(BOOK3E_PAGE_BAP_SR | BOOK3E_PAGE_BAP_UR)\n#define BOOK3E_PAGE_RW\t\t(BOOK3E_PAGE_BAP_SW | BOOK3E_PAGE_BAP_UW)\n#define BOOK3E_PAGE_KERNEL_RW\t(BOOK3E_PAGE_BAP_SW | BOOK3E_PAGE_BAP_SR | BOOK3E_PAGE_DIRTY)\n\n/* FSL BOOKE */\n#define FSL_BOOKE_PAGE_PRESENT\t0x00001\n#define FSL_BOOKE_PAGE_USER\t0x00002\n#define FSL_BOOKE_PAGE_RW\t0x00004\n#define FSL_BOOKE_PAGE_DIRTY\t0x00008\n#define FSL_BOOKE_PAGE_ACCESSED\t0x00020\n#define FSL_BOOKE_PAGE_GUARDED\t0x00080\n#define FSL_BOOKE_PAGE_COHERENT\t0x00100\n#define FSL_BOOKE_PAGE_NO_CACHE\t0x00200\n#define FSL_BOOKE_PAGE_WRITETHRU\t0x00400\n#define FSL_BOOKE_PAGE_HWWRITE\t0\n#define FSL_BOOKE_PAGE_SHARED\t0\n\n#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)\n#define SWP_OFFSET(entry) ((entry) >> 8)\n#define __swp_type(entry) SWP_TYPE(entry)\n#define __swp_offset(entry) SWP_OFFSET(entry)\n\n#define TIF_SIGPENDING (2)\n\n#define _SECTION_SIZE_BITS\t24\n#define _MAX_PHYSMEM_BITS\t44\n\n#define STACK_FRAME_OVERHEAD\t16\n#define STACK_FRAME_LR_SAVE\t(sizeof(ulong))\n#define STACK_FRAME_MARKER\t(2 * sizeof(ulong))\n```\n\n#### region() [lines 3806-3912]\n```c\n#define MMU_SPECIAL\t\t(machdep->machspec->mmu_special)\n\n/* PFN shifts */\n#define BOOKE3E_PTE_RPN_SHIFT\t(24)\n\n/* PAGE flags */\n#define _PAGE_PRESENT (machdep->machspec->_page_present)\t/* software: pte contains a translation */\n#define _PAGE_USER (machdep->machspec->_page_user)\t\t/* matches one of the PP bits */\n#define _PAGE_RW (machdep->machspec->_page_rw)\t\t/* software: user write access allowed */\n#define _PAGE_GUARDED (machdep->machspec->_page_guarded)\n#define _PAGE_COHERENT (machdep->machspec->_page_coherent\t/* M: enforce memory coherence (SMP systems) */)\n#define _PAGE_NO_CACHE (machdep->machspec->_page_no_cache)\t/* I: cache inhibit */\n#define _PAGE_WRITETHRU (machdep->machspec->_page_writethru)\t/* W: cache write-through */\n#define _PAGE_DIRTY (machdep->machspec->_page_dirty)\t/* C: page changed */\n#define _PAGE_ACCESSED (machdep->machspec->_page_accessed)\t/* R: page referenced */\n#define _PAGE_HWWRITE (machdep->machspec->_page_hwwrite)\t/* software: _PAGE_RW & _PAGE_DIRTY */\n#define _PAGE_SHARED (machdep->machspec->_page_shared)\n#define _PAGE_K_RW\t(machdep->machspec->_page_k_rw)\t\t/* privilege only write access allowed */\n\n/* Default values for PAGE flags */\n#define DEFAULT_PAGE_PRESENT 0x001\n#define DEFAULT_PAGE_USER 0x002\n#define DEFAULT_PAGE_RW 0x004\n#define DEFAULT_PAGE_GUARDED 0x008\n#define DEFAULT_PAGE_COHERENT 0x010\n#define DEFAULT_PAGE_NO_CACHE 0x020\n#define DEFAULT_PAGE_WRITETHRU 0x040\n#define DEFAULT_PAGE_DIRTY 0x080\n#define DEFAULT_PAGE_ACCESSED 0x100\n#define DEFAULT_PAGE_HWWRITE 0x200\n#define DEFAULT_PAGE_SHARED 0\n\n/* PPC44x PAGE flags: Values from kernel asm/pte-44x.h */\n#define PPC44x_PAGE_PRESENT\t0x001\n#define PPC44x_PAGE_RW\t\t0x002\n#define PPC44x_PAGE_ACCESSED\t0x008\n#define PPC44x_PAGE_DIRTY\t0x010\n#define PPC44x_PAGE_USER\t0x040\n#define PPC44x_PAGE_GUARDED\t0x100\n#define PPC44x_PAGE_COHERENT\t0x200\n#define PPC44x_PAGE_NO_CACHE\t0x400\n#define PPC44x_PAGE_WRITETHRU\t0x800\n#define PPC44x_PAGE_HWWRITE\t0\n#define PPC44x_PAGE_SHARED\t0\n\n/* BOOK3E */\n#define BOOK3E_PA\n/* ... truncated ... */\n```\n\n### ppc64.c\n\n#### ppc64_init() [lines 300-720]\n```c\n * times during initialization.\n */\nvoid\nppc64_init(int when)\n{\n#if defined(__x86_64__)\n if (ACTIVE())\n error(FATAL, \"compiled for the PPC64 architecture\\n\");\n#endif\n\tswitch (when)\n\t{\n\tcase SETUP_ENV:\n\t\tmachdep->process_elf_notes = process_elf64_notes;\n\t\tbreak;\n\n\tcase PRE_SYMTAB:\n\t\tmachdep->machspec = &ppc64_machine_specific;\n\t\tmachdep->verify_symbol = ppc64_verify_symbol;\n\t\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\t\treturn;\n\t\tmachdep->stacksize = PPC64_STACK_SIZE;\n\t\tmachdep->last_pgd_read = 0;\n\t\tmachdep->last_pud_read = 0;\n\t\tmachdep->last_pmd_read = 0;\n\t\tmachdep->last_ptbl_read = 0;\n\t\tmachdep->verify_paddr = generic_verify_paddr;\n\t\tmachdep->ptrs_per_pgd = PTRS_PER_PGD;\n\t\tmachdep->flags |= MACHDEP_BT_TEXT;\n if (machdep->cmdline_args[0])\n parse_cmdline_args();\n\t\t machdep->clear_machdep_cache = ppc64_clear_machdep_cache;\n\t\tbreak;\n\n\tcase PRE_GDB:\n\t\t/*\n * Recently there were changes made to kexec tools\n * to support 64K page size. With those changes\n * vmcore file obtained from a kernel which supports\n * 64K page size cannot be analyzed using crash on a\n * machine running with kernel supporting 4K page size\n/* ... 106 lines omitted ... */\n\t\t\t * bit as it is always set on hash64 and on platforms\n\t\t\t * that cannot always set it, _PAGE_NO_CACHE and\n\t\t\t * _PAGE_WRITETHRU can be used to infer it.\n\t\t\t */\n\t\t\tif (THIS_KERNEL_VERSION >= LINUX(3,14,0))\n\t\t\t\tm->_page_coherent = 0x0UL;\n\n\t\t\t/*\n\t\t\t * In kernel v4.5, _PAGE_PTE bit is introduced to\n\t\t\t * distinguish PTEs from pointers.\n\t\t\t */\n\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,5,0)) {\n\t\t\t\tm->_page_pte = 0x1UL;\n\t\t\t\tm->_page_present = 0x2UL;\n\t\t\t\tm->_page_user = 0x4UL;\n\t\t\t\tm->_page_rw = 0x8UL;\n\t\t\t\tm->_page_guarded = 0x10UL;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Starting with kernel v4.6, to accommodate both\n\t\t\t * radix and hash MMU modes in a single kernel,\n\t\t\t * _PAGE_PTE & _PAGE_PRESENT page flags are changed.\n\t\t\t * Also, page table entries store physical addresses.\n\t\t\t */\n\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,6,0)) {\n\t\t\t\tm->_page_pte = 0x1UL << 62;\n/* ... 228 lines omitted ... */\n\t\t}\n\t\t/*\n\t\t * IRQ stacks are introduced in 2.6 and also configurable.\n\t\t */\n\t\tif ((THIS_KERNEL_VERSION >= LINUX(2,6,0)) && \n\t\t\tsymbol_exists(\"hardirq_ctx\"))\n\t\t\tASSIGN_SIZE(irq_ctx) = STACKSIZE();\n\n\t\tbreak;\n\n\tcase POST_INIT:\n\t\tbreak;\n\n\tcase LOG_ONLY:\n\t\tmachdep->identity_map_base = kt->vmcoreinfo._stext_SYMBOL;\n\t\tbreak;\n\t}\n}\n\n#ifndef KSYMS_START\n```\n\n\n### Type definitions\n\n```c\n/* from defs.h */\nstruct efi_memory_desc_t {\n uint32_t type;\n uint32_t pad;\n uint64_t phys_addr;\n uint64_t virt_addr;\n uint64_t num_pages;\n uint64_t attribute;\n} desc;\n```\n\n\n## Upstream Fix\n```diff\nFrom: Hari Krishna Bathini \nSubject: book3s/ppc64: update hash page table geometry\n\nPatch-mainline: never, SLE12-SP3 specific\n\nKernel commit f6eedbba7a26 (\"powerpc/mm/hash: Increase VA range to 128TB\")\nupdated hash page table geometry. A modified version of this commit is\nincluded in SLES12 SP3. Make the corresponding changes in crash utility\nfor analyzing dump appropriately.\n---\n defs.h | 2 ++\n ppc64.c | 10 ++++++++--\n 2 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/defs.h b/defs.h\nindex 0fe8d36..f26f642 100755\n--- a/defs.h\n+++ b/defs.h\n@@ -3837,6 +3837,7 @@ struct efi_memory_desc_t {\n #define PUD_INDEX_SIZE_L4_4K 7\n #define PGD_INDEX_SIZE_L4_4K 9\n #define PUD_INDEX_SIZE_L4_4K_3_7 9\n+#define PGD_INDEX_SIZE_L4_4K_4_4_63 12\n #define PTE_INDEX_SIZE_RADIX_4K 9\n #define PMD_INDEX_SIZE_RADIX_4K 9\n #define PUD_INDEX_SIZE_RADIX_4K 9\n@@ -3855,6 +3856,7 @@ struct efi_memory_desc_t {\n #define PTE_INDEX_SIZE_L4_64K_3_10 8\n #define PMD_INDEX_SIZE_L4_64K_3_10 10\n #define PGD_INDEX_SIZE_L4_64K_3_10 12\n+#define PGD_INDEX_SIZE_L4_64K_4_4_63 15\n #define PMD_INDEX_SIZE_L4_64K_4_6 5\n #define PUD_INDEX_SIZE_L4_64K_4_6 5\n #define PTE_INDEX_SIZE_RADIX_64K 5\ndiff --git a/ppc64.c b/ppc64.c\nindex edf46dc..bed4dea 100755\n--- a/ppc64.c\n+++ b/ppc64.c\n@@ -455,7 +455,10 @@ ppc64_init(int when)\n \t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K_3_10;\n \t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_3_10;\n \t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K;\n-\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n+\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,4,63))\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_4_63;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n \n \t\t\t\t} else {\n \t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K;\n@@ -499,7 +502,10 @@ ppc64_init(int when)\n \t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_4K_3_7;\n \t\t\t\t\telse\n \t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_4K;\n-\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K;\n+\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,4,63))\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K_4_4_63;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K;\n \n \t\t\t\t\tif (machdep->flags & BOOK3E)\n \t\t\t\t\t\tm->pte_rpn_shift = PTE_RPN_SHIFT_L4_BOOK3E_4K;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Hari Krishna Bathini \nSubject: book3s/ppc64: update hash page table geometry\n\nPatch-mainline: never, SLE12-SP3 specific\n\nKernel commit f6eedbba7a26 (\"powerpc/mm/hash: Increase VA range to 128TB\")\nupdated hash page table geometry. A modified version of this commit is\nincluded in SLES12 SP3. Make the corresponding changes in crash utility\nfor analyzing dump appropriately.\n---\n defs.h | 2 ++\n ppc64.c | 10 ++++++++--\n 2 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/defs.h b/defs.h\nindex 0fe8d36..f26f642 100755\n--- a/defs.h\n+++ b/defs.h\n@@ -3837,6 +3837,7 @@ struct efi_memory_desc_t {\n #define PUD_INDEX_SIZE_L4_4K 7\n #define PGD_INDEX_SIZE_L4_4K 9\n #define PUD_INDEX_SIZE_L4_4K_3_7 9\n+#define PGD_INDEX_SIZE_L4_4K_4_4_63 12\n #define PTE_INDEX_SIZE_RADIX_4K 9\n #define PMD_INDEX_SIZE_RADIX_4K 9\n #define PUD_INDEX_SIZE_RADIX_4K 9\n@@ -3855,6 +3856,7 @@ struct efi_memory_desc_t {\n #define PTE_INDEX_SIZE_L4_64K_3_10 8\n #define PMD_INDEX_SIZE_L4_64K_3_10 10\n #define PGD_INDEX_SIZE_L4_64K_3_10 12\n+#define PGD_INDEX_SIZE_L4_64K_4_4_63 15\n #define PMD_INDEX_SIZE_L4_64K_4_6 5\n #define PUD_INDEX_SIZE_L4_64K_4_6 5\n #define PTE_INDEX_SIZE_RADIX_64K 5\ndiff --git a/ppc64.c b/ppc64.c\nindex edf46dc..bed4dea 100755\n--- a/ppc64.c\n+++ b/ppc64.c\n@@ -455,7 +455,10 @@ ppc64_init(int when)\n \t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K_3_10;\n \t\t\t\t\tm->l2_index_size = PMD_INDEX_SIZE_L4_64K_3_10;\n \t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_64K;\n-\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n+\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,4,63))\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_4_63;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_64K_3_10;\n \n \t\t\t\t} else {\n \t\t\t\t\tm->l1_index_size = PTE_INDEX_SIZE_L4_64K;\n@@ -499,7 +502,10 @@ ppc64_init(int when)\n \t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_4K_3_7;\n \t\t\t\t\telse\n \t\t\t\t\t\tm->l3_index_size = PUD_INDEX_SIZE_L4_4K;\n-\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K;\n+\t\t\t\t\tif (THIS_KERNEL_VERSION >= LINUX(4,4,63))\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K_4_4_63;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tm->l4_index_size = PGD_INDEX_SIZE_L4_4K;\n \n \t\t\t\t\tif (machdep->flags & BOOK3E)\n \t\t\t\t\t\tm->pte_rpn_shift = PTE_RPN_SHIFT_L4_BOOK3E_4K;\n"}], "metadata": {"id": "crash-8217-crash-ppc64-book3s-update-hash-page-table-geometry.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-ppc64-book3s-update-hash-page-table-geometry.patch", "tier": "identical", "language": "c", "patch_lines_changed": 12, "patch_files_count": 2, "total_tokens_est": 1242, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-8217-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 338, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-8217-crash-sles9-quirk.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1435, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 682-788]\n```c\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n (((kt->p2m_mapping_cache[c].mapping - kt->phys_to_machine_mapping)/PAGESIZE()) \\\n * XEN_PFNS_PER_PAGE))\n\tulong last_mapping_read;\n\tulong p2m_cache_index;\n\tulong p2m_pages_searched;\n\tulong p2m_mfn_cache_hits;\n\tulong p2m_page_cache_hits;\n\tulong relocate;\n\tchar *module_tree;\n\tstruct pvops_xen_info {\n\t\tint p2m_top_entries;\n\t\tulong p2m_top;\n\t\tulong p2m_mid_missing;\n\t\tulong p2m_missing;\n\t} pvops_xen;\n\tint highest_irq;\n#define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n#define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n\tint ikconfig_flags;\n\tint ikconfig_ents;\n\tchar *hypervisor;\n\tstruct vmcoreinfo_data {\n\t\tulong log_buf_SYMBOL;\n\t\tulong log_end_SYMBOL;\n\t\tulong log_buf_len_SYMBOL;\n\t\tulong logged_chars_SYMBOL;\n\t\tulong log_first_idx_SYMBOL;\n\t\tulong log_next_idx_SYMBOL;\n\t\tlong log_SIZE;\n\t\tlong log_ts_nsec_OFFSET;\n\t\tlong log_len_OFFSET;\n\t\tlong log_text_len_OFFSET;\n\t\tlong log_dict_len_OFFSET;\n\t\tulong phys_base_SYMBOL;\n\t\tulong _stext_SYMBOL;\n\t} vmcoreinfo;\n\tulonglong flags2;\n\tchar *source_tree;\n\tstruct timespec boot_date;\n};\n\n/*\n * Aid for the two versions of the kernel's module list linkage.\n */\n#define NEXT_MODULE(next_module, modbuf) \\\n{ \\\n switch (kt->flags & (KMOD_V1|KMOD_V2)) \\\n { \\\n case KMOD_V1: \\\n```\n\n#### region() [lines 6490-6596]\n```c\n\n/* from arch/mips/include/uapi/asm/ptrace.h */\nstruct mips64_register {\n\tulong regs[45];\n};\n\nstruct mips64_pt_regs_main {\n\tulong regs[32];\n\tulong cp0_status;\n\tulong hi;\n\tulong lo;\n};\n\nstruct mips64_pt_regs_cp0 {\n\tulong cp0_badvaddr;\n\tulong cp0_cause;\n\tulong cp0_epc;\n};\n\nstruct mips64_unwind_frame {\n\tunsigned long sp;\n\tunsigned long pc;\n\tunsigned long ra;\n};\n\n#define KSYMS_START\t(0x1)\n\nstruct machine_specific {\n\tulong phys_base;\n\tulong vmalloc_start_addr;\n\tulong modules_vaddr;\n\tulong modules_end;\n\n\tulong _page_present;\n\tulong _page_read;\n\tulong _page_write;\n\tulong _page_accessed;\n\tulong _page_modified;\n\tulong _page_huge;\n\tulong _page_special;\n\tulong _page_protnone;\n\tulong _page_global;\n\tulong _page_valid;\n\tulong _page_no_read;\n\tulong _page_no_exec;\n\tulong _page_dirty;\n\n\tulong _pfn_shift;\n\n\tstruct mips64_register *crash_task_regs;\n};\n/* from arch/mips/include/asm/pgtable-bits.h */\n#define _PAGE_PRESENT\t(machdep->machspec->_page_present)\n#define _PAGE_READ\t(machdep->machspec->_page_read)\n#define _PAGE_WRITE\t(machdep->machspec->_page_write)\n#define _PAGE_ACCESSED\t(machdep->machspec->_page_accessed)\n#define _PAGE_MODIFIED\t(machdep->machspec->_page_modified)\n#define _PAGE_HUGE\t(machdep->machspec->_page_huge)\n#define _PAGE_SPECIAL\t(machdep->machspec->_page_special)\n#define _PAGE_PROTNONE\t(machdep->machspec->_page_protnone)\n#define _PAGE_GLOBAL\t(machdep->machspec->_page_global)\n#define _PAGE_VALID\t(machdep->machspec->_page_valid)\n#define _PAGE_NO_READ\t(machdep->machspec->_page_no_read)\n#define _PAGE_NO_EXEC\t(machdep->machspec->_page_no_exec)\n#define _PAGE_DIRTY\t(machdep->machspec->_page_dirty)\n#define _PFN_SHIFT\t(machdep->machspec->_pfn_shift)\n\n#endif /* MIPS64 */\n\n/*\n * sparc64.c\n */\n#ifdef SPARC64\nvoid sparc64_init(int);\nvoid sparc64_dump_machdep_table(ulong);\nint sparc64_vmalloc_addr(ulong);\n#define display_idt_table() \\\n\terror(FATAL, \"The -d option is not applicable to sparc64.\\n\")\n#endif\n\n/*\n * netdump.c \n */\nint is_netdump(char *, ulong);\nuint netdump_page_size(void);\nint read_netdump(int, void *, int, ulong, physaddr_t);\nint write_netdump(int, void *, int, ulong, physaddr_t);\nint netdump_free_memory(void);\nint netdump_memory_used(void);\nint netdump_init(char *, FILE *);\nulong get_netdump_panic_task(void);\nulong get_netdump_switch_stack(ulong);\nFILE *set_netdump_fp(FILE *);\nint netdump_memory_dump(FILE *);\nvoid get_netdump_regs(struct bt_info *, ulong *, ulong *);\nint is_partial_netdump(void);\nvoid get_netdump_regs_x86(struct bt_info *, ulong *, ulong *);\nvoid get_netdump_regs_x86_64(struct bt_info *, ulong *, ulong *);\nvoid dump_registers_for_elf_dumpfiles(void);\nstruct vmcore_data;\nstruct vmcore_data *get_kdump_vmcore_data(void);\nint read_kdump(int, void *, int, ulong, physaddr_t);\nint write_kdump(int, void *, int, ulong, physaddr_t);\nint is_kdump(char *, ulong);\nint kdump_init(char *, FILE *);\nulong get_kdump_panic_task(void);\nuint kdump_page_size(void);\n```\n\n#### kernel_init() [lines 237-343]\n```c\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n#define KVMDUMP_DUMPFILE() (pc->flags & KVMDUMP)\n#define SADUMP_DUMPFILE() (pc->flags & SADUMP)\n#define VMSS_DUMPFILE() (pc->flags & VMWARE_VMSS)\n#define QEMU_MEM_DUMP_NO_VMCOREINFO() \\\n\t ((pc->flags2 & (QEMU_MEM_DUMP_ELF|QEMU_MEM_DUMP_COMPRESSED)) && !(pc->flags2 & VMCOREINFO))\n\n\n#define NETDUMP_LOCAL (0x1) /* netdump_data flags */\n#define NETDUMP_REMOTE (0x2) \n#define VMCORE_VALID() (nd->flags & (NETDUMP_LOCAL|NETDUMP_REMOTE|KDUMP_LOCAL))\n#define NETDUMP_ELF32 (0x4)\n#define NETDUMP_ELF64 (0x8)\n#define PARTIAL_DUMP (0x10) /* netdump or diskdump */\n#define KDUMP_ELF32 (0x20)\n#define KDUMP_ELF64 (0x40)\n#define KDUMP_LOCAL (0x80) \n#define KCORE_LOCAL (0x100) \n#define KCORE_ELF32 (0x200)\n#define KCORE_ELF64 (0x400)\n#define QEMU_MEM_DUMP_KDUMP_BACKUP \\\n (0x800)\n#define KVMDUMP_LOCAL (0x1)\n#define KVMDUMP_VALID() (kvm->flags & (KVMDUMP_LOCAL))\n\n#define DUMPFILE_FORMAT(flags) ((flags) & \\\n\t\t (NETDUMP_ELF32|NETDUMP_ELF64|KDUMP_ELF32|KDUMP_ELF64))\n\n#define DISKDUMP_LOCAL (0x1)\n#define KDUMP_CMPRS_LOCAL (0x2)\n#define ERROR_EXCLUDED (0x4)\n#define ZERO_EXCLUDED (0x8)\n#define DUMPFILE_SPLIT (0x10)\n#define NO_ELF_NOTES (0x20)\n#define LZO_SUPPORTED (0x40)\n#define SNAPPY_SUPPORTED (0x80)\n#define DISKDUMP_VALID() (dd->flags & DISKDUMP_LOCAL)\n#define KDUMP_CMPRS_VALID() (dd->flags & KDUMP_CMPRS_LOCAL)\n#define KDUMP_SPLIT() (dd->flags & DUMPFILE_SPLIT)\n\n#define XENDUMP_LOCAL (0x1)\n#define XENDUMP_VALID() (xd->flags & XENDUMP_LOCAL)\n\n#define SADUMP_LOCAL (0x1)\n#define SADUMP_DISKSET (0x2)\n#define SADUMP_MEDIA (0x4)\n#define SADUMP_ZERO_EXCLUDED (0x8)\n#define SADUMP_KDUMP_BACKUP (0x10)\n#define SADUMP_VALID() (sd->flags & SADUMP_LOCAL)\n\n```\n\n#### get_uptime() [lines 5407-5514]\n```c\nint vaddr_type(ulong, struct task_context *);\nchar *format_stack_entry(struct bt_info *bt, char *, ulong, ulong);\nint in_user_stack(ulong, ulong);\nint dump_inode_page(ulong);\nulong valid_section_nr(ulong);\nvoid display_memory_from_file_offset(ulonglong, long, void *);\nvoid swap_info_init(void);\n\n/*\n * filesys.c \n */\nvoid fd_init(void);\nvoid vfs_init(void);\nint is_a_tty(char *);\nint file_exists(char *, struct stat *);\nint file_readable(char *);\nint is_directory(char *);\nchar *search_directory_tree(char *, char *, int);\nvoid open_tmpfile(void);\nvoid close_tmpfile(void);\nvoid open_tmpfile2(void);\nvoid set_tmpfile2(FILE *);\nvoid close_tmpfile2(void);\nvoid open_files_dump(ulong, int, struct reference *);\nvoid get_pathname(ulong, char *, int, int, ulong);\nulong *get_mount_list(int *, struct task_context *);\nchar *vfsmount_devname(ulong, char *, int);\nulong file_to_dentry(ulong);\nulong file_to_vfsmnt(ulong);\nint get_proc_version(void);\nint file_checksum(char *, long *);\nvoid dump_filesys_table(int);\nchar *fill_file_cache(ulong);\nvoid clear_file_cache(void);\nchar *fill_dentry_cache(ulong);\nvoid clear_dentry_cache(void);\nchar *fill_inode_cache(ulong);\nvoid clear_inode_cache(void);\nint monitor_memory(long *, long *, long *, long *);\nint is_readable(char *);\nstruct list_pair {\n\tulong index;\n\tvoid *value;\n};\n#define radix_tree_pair list_pair\nulong do_radix_tree(ulong, int, struct list_pair *);\n#define RADIX_TREE_COUNT (1)\n#define RADIX_TREE_SEARCH (2)\n#define RADIX_TREE_DUMP (3)\n#define RADIX_TREE_GATHER (4)\n#define RADIX_TREE_DUMP_CB (5)\n/*\n * from: \"include/linux/radix-tree.h\"\n */\n#define RADIX_TREE_ENTRY_MASK 3UL\n#define RADIX_TREE_EXCEPTIONAL_ENTRY 2\n\nulong do_xarray(ulong, int, struct list_pair *);\n#define XARRAY_COUNT (1)\n#define XARRAY_SEARCH (2)\n#define XARRAY_DUMP (3)\n#define XARRAY_GATHER (4)\n#define XARRAY_DUMP_CB (5)\n#define XARRAY_TAG_MASK (3UL\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -731,6 +731,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -6539,6 +6540,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -286,6 +286,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -5456,7 +5462,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -6050,6 +6056,7 @@ no_cpu_flags:\n \t\t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \t\tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n \t}\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -4100,6 +4100,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -4136,6 +4142,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC | START_TIME_NSECS))\n {\n \tcase START_TIME_NSECS:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -731,6 +731,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -6539,6 +6540,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -286,6 +286,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -5456,7 +5462,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -6050,6 +6056,7 @@ no_cpu_flags:\n \t\t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \t\tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n \t}\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -4100,6 +4100,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -4136,6 +4142,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC | START_TIME_NSECS))\n {\n \tcase START_TIME_NSECS:\n"}], "metadata": {"id": "crash-8217-crash-sles9-time.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1450, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: David Mair \n\n## Package\ncrash\n\n## Files to modify\n- memory.c\n\n## Upstream Fix\n```diff\nFrom: David Mair \nDate: 2017-05-25 10:27:21 -0600\nSubject: Avoid printing a read error for a failed read that can be retried\nReferences: bnc#1038839\nUpstream: tbd\n\nWhen reading a memory image fails it may not be an error if it is still\npossible to switch image and retry the read. Fix the error message output\nto only occur if no retries are intended.\n\n---\n memory.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\n--- a/memory.c\n+++ b/memory.c\n@@ -2237,13 +2237,15 @@ readmem(ulonglong addr, int memtype, voi\n goto readmem_error;\n \n \t\tcase READ_ERROR:\n-\t\t\tif (PRINT_ERROR_MESSAGE)\n-\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tif ((pc->flags & DEVMEM) && (kt->flags & PRE_KERNEL_INIT) &&\n \t\t\t !(error_handle & NO_DEVMEM_SWITCH) && devmem_is_restricted() && \n \t\t\t switch_to_proc_kcore())\n \t\t\t\treturn(readmem(addr, memtype, bufptr, size,\n \t\t\t\t\ttype, error_handle));\n+\n+\t\t\tif (PRINT_ERROR_MESSAGE)\n+\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n+\n \t\t\tgoto readmem_error;\n \n \t\tcase PAGE_EXCLUDED:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: David Mair \nDate: 2017-05-25 10:27:21 -0600\nSubject: Avoid printing a read error for a failed read that can be retried\nReferences: bnc#1038839\nUpstream: tbd\n\nWhen reading a memory image fails it may not be an error if it is still\npossible to switch image and retry the read. Fix the error message output\nto only occur if no retries are intended.\n\n---\n memory.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\n--- a/memory.c\n+++ b/memory.c\n@@ -2237,13 +2237,15 @@ readmem(ulonglong addr, int memtype, voi\n goto readmem_error;\n \n \t\tcase READ_ERROR:\n-\t\t\tif (PRINT_ERROR_MESSAGE)\n-\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n \t\t\tif ((pc->flags & DEVMEM) && (kt->flags & PRE_KERNEL_INIT) &&\n \t\t\t !(error_handle & NO_DEVMEM_SWITCH) && devmem_is_restricted() && \n \t\t\t switch_to_proc_kcore())\n \t\t\t\treturn(readmem(addr, memtype, bufptr, size,\n \t\t\t\t\ttype, error_handle));\n+\n+\t\t\tif (PRINT_ERROR_MESSAGE)\n+\t\t\t\terror(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);\n+\n \t\t\tgoto readmem_error;\n \n \t\tcase PAGE_EXCLUDED:\n"}], "metadata": {"id": "crash-8217-crash-stop_read_error_when_intent_is_retry.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-stop_read_error_when_intent_is_retry.patch", "tier": "identical", "language": "c", "patch_lines_changed": 6, "patch_files_count": 0, "total_tokens_est": 673, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\ncrash patch c3413456599161cabc4e910a0ae91dfe5eec3c21 (xen: Add support for\n\n## Package\ncrash\n\n## Files to modify\n- kernel.c\n- xendump.c\n- xendump.h\n\n## Target Source Code\n\n### kernel.c\n\n#### region() [lines 1-79]\n```c\n/* kernel.c - core analysis suite\n *\n * Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.\n * Copyright (C) 2002-2019 David Anderson\n * Copyright (C) 2002-2019 Red Hat, Inc. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n */\n\n#include \"defs.h\"\n#include \"xen_hyper_defs.h\"\n#include \"xen_dom0.h\"\n#include \n#include \n#include \n#include \n#include \"xendump.h\"\n\nstatic void do_module_cmd(ulong, char *, ulong, char *, char *);\nstatic void show_module_taint(void);\nstatic char *find_module_objfile(char *, char *, char *);\nstatic char *module_objfile_search(char *, char *, char *);\nstatic char *get_loadavg(char *);\nstatic void get_lkcd_regs(struct bt_info *, ulong *, ulong *);\nstatic void dump_sys_call_table(char *, int);\nstatic int get_NR_syscalls(int *);\nstatic ulong get_irq_desc_addr(int);\nstatic void display_cpu_affinity(ulong *);\nstatic void display_bh_1(void);\nstatic void display_bh_2(void);\nstatic void display_bh_3(void);\nstatic void display_bh_4(void);\nstatic void dump_hrtimer_data(const ulong *cpus);\nstatic void dump_hrtimer_clock_base(const void *, const int);\nstatic void dump_hrtimer_base(const void *, const int);\nstatic void dump_active_timers(const void *, ulonglong);\nstatic int get_expires_len(const int, const ulong *, ulonglong, const int);\nstatic void print_timer(const void *, ulonglong);\nstatic ulonglong ktime_to_ns(const void *);\nstatic void dump_timer_data(const ulong *cpus);\nstatic void dump_timer_data_tvec_bases_v1(const ulong *cpus);\nstatic void dump_timer_data_tvec_bases_v2(const ulong *cpus);\nstatic void dump_timer_data_tvec_bases_v3(const ulong *cpus);\nstatic void dump_timer_data_timer_bases(const ulong *cpus);\nstruct tv_range;\nstatic void init_tv_ranges(struct tv_range *, int, int, int);\nstatic int do_timer_list(ulong,int, ulong *, void *,ulong *, ulong *, struct tv_range *, ulong);\nstatic int do_timer_list_v3(ulong, int, ulong *, void *,ulong *, ulong *, ulong, long);\nstruct timer_bases_data;\nstatic int do_timer_list_v4(struct timer_bases_data *, ulong);\nstatic int compare_timer_data(const void *, const void *);\nstatic void panic_this_kernel(void);\nstatic void dump_waitq(ulong, char *);\nstatic void reinit_modules(void);\nstatic int verify_modules(void);\nstatic void verify_namelist(void);\nstatic char *debug_kernel_version(char *);\nstatic int restore_stack(struct bt_info *);\nstatic ulong __xen_m2p(ulonglong, ulong);\nstatic ulong __xen_pvops_m2p_l2(ulonglong, ulong);\nstatic ulong __xen_pvops_m2p_l3(ulonglong, ulong);\nstatic ulong __xen_pvops_m2p_hyper(ulonglong, ulong);\nstatic ulong __xen_pvops_m2p_domU(ulonglong, ulong);\nstatic int read_xc_p2m(ulonglong, void *, long);\nstatic void read_p2m(ulong, int, void *);\nstatic int search_mapping_page(ulong, ulong *, ulong *, ulong *);\nstatic void read_in_kernel_config_err(int, char *);\nstatic void BUG_bytes_init(void);\nstatic int BUG_x86(void);\nstatic int BUG_x86_64(void);\nstatic void cpu_maps_init(void);\n```\n\n#### __xen_m2p() [lines 9733-9858]\n```c\n}\n\nstatic ulong\n__xen_m2p(ulonglong machine, ulong mfn)\n{\n\tulong c, i, kmfn, mapping, p, pfn;\n\tulong start, end;\n\tulong *mp = (ulong *)kt->m2p_page;\n\tint memtype;\n\n\tif (XEN_CORE_DUMPFILE() && symbol_exists(\"xen_p2m_addr\"))\n\t\tmemtype = PHYSADDR;\n\telse\n\t\tmemtype = KVADDR;\n\n\t/*\n\t * Check the FIFO cache first.\n\t */\n\tfor (c = 0; c < P2M_MAPPING_CACHE; c++) {\n\t\tif (kt->p2m_mapping_cache[c].mapping &&\n\t\t ((mfn >= kt->p2m_mapping_cache[c].start) && \n\t\t (mfn <= kt->p2m_mapping_cache[c].end))) { \n\n\t\t\tif (kt->p2m_mapping_cache[c].mapping != kt->last_mapping_read) {\n\t\t\t\tif (memtype == PHYSADDR)\n\t\t\t\t\tpc->curcmd_flags |= XEN_MACHINE_ADDR;\n\n\t\t\t\tread_p2m(c, memtype, mp);\n\n\t\t\t\tif (memtype == PHYSADDR)\n\t\t\t\t\tpc->curcmd_flags &= ~XEN_MACHINE_ADDR;\n\t\t\t} else\n\t\t\t\tkt->p2m_page_cache_hits++;\n\n \tfor (i = 0; i < XEN_PFNS_PER_PAGE; i++) {\n\t\t\t\tkmfn = (*(mp+i)) & ~XEN_FOREIGN_FRAME;\n \tif (kmfn == mfn) {\n\t\t\t\t\tp = P2M_MAPPING_PAGE_PFN(c);\n\t\t\t\t\tpfn = p + i;\n\n/* ... 80 lines omitted ... */\n\t\t\t\tc = kt->p2m_cache_index;\n\t\t\t\tkt->p2m_mapping_cache[c].start = start;\n\t\t\t\tkt->p2m_mapping_cache[c].end = end;\n\t\t\t\tkt->p2m_mapping_cache[c].mapping = mapping;\n\t\t\t\tkt->p2m_cache_index = (c+1) % P2M_MAPPING_CACHE;\n\t\n\t\t\t\treturn pfn;\n\t\t\t}\n\t\n\t\t\tmapping += PAGESIZE();\n\t\t}\n\t}\t\n\n\tif (CRASHDEBUG(1))\n\t\tconsole(\"machine address %llx not found\\n\", machine);\n\t\n\treturn (XEN_MFN_NOT_FOUND);\n}\n\nstatic ulong\n```\n\n#### kernel_init() [lines 101-823]\n```c\n * Gather a few kernel basics.\n */\nvoid\nkernel_init()\n{\n\tint i, c;\n\tchar *p1, *p2, buf[BUFSIZE];\n\tstruct syment *sp1, *sp2;\n\tchar *rqstruct;\n\tchar *rq_timestamp_name = NULL;\n\tchar *irq_desc_type_name;\t\n\tulong pv_init_ops;\n\tstruct gnu_request req;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (!(kt->cpu_flags = (ulong *)calloc(NR_CPUS, sizeof(ulong))))\n error(FATAL, \"cannot malloc cpu_flags array\");\n\n\tcpu_maps_init();\n\n\tkt->stext = symbol_value(\"_stext\");\n\tkt->etext = symbol_value(\"_etext\");\n\tget_text_init_space(); \n\tif (symbol_exists(\"__init_begin\")) {\n\t\tkt->init_begin = symbol_value(\"__init_begin\");\n\t\tkt->init_end = symbol_value(\"__init_end\");\n\t}\n\tkt->end = highest_bss_symbol();\n\tif ((sp1 = kernel_symbol_search(\"_end\")) && (sp1->value > kt->end)) \n\t\tkt->end = sp1->value;\n\n\tcheck_vmcoreinfo();\n\t\n\t/*\n\t * For the traditional (non-pv_ops) Xen architecture, default to writable \n * page tables unless:\n\t * \n\t * (1) it's an \"xm save\" CANONICAL_PAGE_TABLES dumpfile, or\n/* ... 31 lines omitted ... */\n\tif (PVOPS() && symbol_exists(\"pv_init_ops\") &&\n\t readmem(symbol_value(\"pv_init_ops\"), KVADDR, &pv_init_ops,\n\t sizeof(void *), \"pv_init_ops\", RETURN_ON_ERROR) &&\n\t ((p1 = value_symbol(pv_init_ops)) &&\n\t (STREQ(p1, \"xen_patch\") || STREQ(p1, \"paravirt_patch_default\")))) {\n\t\tkt->flags |= ARCH_XEN | ARCH_PVOPS_XEN;\n\t\tkt->xen_flags |= WRITABLE_PAGE_TABLES;\n\t\tif (machine_type(\"X86\"))\n \tget_symbol_data(\"max_pfn\", sizeof(ulong), &kt->p2m_table_size);\n\t\tif (machine_type(\"X86_64\")) {\n\t\t\tif (!try_get_symbol_data(\"end_pfn\", sizeof(ulong), &kt->p2m_table_size))\n\t\t\t\tget_symbol_data(\"max_pfn\", sizeof(ulong), &kt->p2m_table_size);\n\t\t}\n if ((kt->m2p_page = (char *)malloc(PAGESIZE())) == NULL)\n \terror(FATAL, \"cannot malloc m2p page.\");\n\n\t\tif (symbol_exists(\"p2m_mid_missing\")) {\n\t\t\tkt->pvops_xen.p2m_top_entries = XEN_P2M_TOP_PER_PAGE;\n\t\t\tget_symbol_data(\"p2m_top\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_top);\n\t\t\tget_symbol_data(\"p2m_mid_missing\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_mid_missing);\n\t\t\tget_symbol_data(\"p2m_missing\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_missing);\n\t\t} else if (!symbol_exists(\"xen_p2m_addr\")) {\n\t\t\tkt->pvops_xen.p2m_top_entries = get_array_length(\"p2m_top\", NULL, 0);\n\t\t\tkt->pvops_xen.p2m_top = symbol_value(\"p2m_top\");\n\t\t\tkt->pvops_xen.p2m_missing = symbol_value(\"p2m_missing\");\n\t\t}\n\t}\n/* ... 602 lines omitted ... */\n\tMEMBER_OFFSET_INIT(hrtimer_softexpires, \"hrtimer\", \"_softexpires\");\n\tMEMBER_OFFSET_INIT(hrtimer_function, \"hrtimer\", \"function\");\n\n\tMEMBER_OFFSET_INIT(ktime_t_tv64, \"ktime\", \"tv64\");\n\tif (INVALID_MEMBER(ktime_t_tv64))\n\t\tMEMBER_OFFSET_INIT(ktime_t_tv64, \"ktime_t\", \"tv64\");\n\tMEMBER_OFFSET_INIT(ktime_t_sec, \"ktime\", \"sec\");\n\tif (INVALID_MEMBER(ktime_t_sec))\n\t\tMEMBER_OFFSET_INIT(ktime_t_sec, \"ktime_t\", \"sec\");\n\tMEMBER_OFFSET_INIT(ktime_t_nsec, \"ktime\", \"nsec\");\n\tif (INVALID_MEMBER(ktime_t_nsec))\n\t\tMEMBER_OFFSET_INIT(ktime_t_nsec, \"ktime_t\", \"nsec\");\n\n\tif (kt->source_tree)\n\t\tsource_tree_init();\n\n\tkt->flags &= ~PRE_KERNEL_INIT;\n}\n\n/*\n```\n\n#### __xen_pvops_m2p_hyper() [lines 9965-10011]\n```c\n}\n\nstatic ulong\n__xen_pvops_m2p_hyper(ulonglong machine, ulong mfn)\n{\n\tulong c, end, i, mapping, p, pfn, start;\n\n\tfor (p = 0;\n\t p < xkd->p2m_frames;\n\t ++p) {\n\n\t\tmapping = PTOB(xkd->p2m_mfn_frame_list[p]);\n\n\t\tif (mapping != kt->last_mapping_read) {\n\t\t\tpc->curcmd_flags |= XEN_MACHINE_ADDR;\n\t\t\tif (!readmem(mapping, PHYSADDR, (void *)kt->m2p_page,\n\t\t\t\t\tPAGESIZE(), \"p2m_mfn_frame_list page\", RETURN_ON_ERROR))\n\t\t\t\terror(FATAL, \"cannot access p2m_mfn_frame_list[] page\\n\");\n\n\t\t\tpc->curcmd_flags &= ~XEN_MACHINE_ADDR;\n\t\t\tkt->last_mapping_read = mapping;\n\t\t}\n\n\t\tkt->p2m_pages_searched++;\n\n\t\tif (search_mapping_page(mfn, &i, &start, &end)) {\n\t\t\tpfn = p * XEN_PFNS_PER_PAGE + i;\n\t\t\tif (CRASHDEBUG(1))\n\t\t\t console(\"pages: %d mfn: %lx (%llx) p: %ld\"\n\t\t\t\t\" i: %ld pfn: %lx (%llx)\\n\", p + 1, mfn, machine,\n\t\t\t\tp, i, pfn, XEN_PFN_TO_PSEUDO(pfn));\n\n\t\t\tc = kt->p2m_cache_index;\n\t\t\tkt->p2m_mapping_cache[c].start = start;\n\t\t\tkt->p2m_mapping_cache[c].end = end;\n\t\t\tkt->p2m_mapping_cache[c].mapping = mapping;\n\t\t\tkt->p2m_mapping_cache[c].pfn = p * XEN_PFNS_PER_PAGE;\n\t\t\tkt->p2m_cache_index = (c+1) % P2M_MAPPING_CACHE;\n\n\t\t\treturn pfn;\n\t\t}\n\t}\n\n\treturn XEN_MFN_NOT_FOUND;\n}\n\nstatic void read_p2m(ulong cache_index, int memtype, void *buffer)\n```\n\n#### region() [lines 189-198]\n```c\n\t\t\tkt->pvops_xen.p2m_top_entries = XEN_P2M_TOP_PER_PAGE;\n\t\t\tget_symbol_data(\"p2m_top\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_top);\n\t\t\tget_symbol_data(\"p2m_mid_missing\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_mid_missing);\n\t\t\tget_symbol_data(\"p2m_missing\", sizeof(ulong),\n\t\t\t\t\t\t&kt->pvops_xen.p2m_missing);\n\t\t} else if (!symbol_exists(\"xen_p2m_addr\")) {\n\t\t\tkt->pvops_xen.p2m_top_entries = get_array_length(\"p2m_top\", NULL, 0);\n\t\t\tkt->pvops_xen.p2m_top = symbol_value(\"p2m_top\");\n```\n\n\n### Type definitions\n\n```c\n/* from xendump.h */\nstruct xendump_data {\n ulong flags; /* XENDUMP_LOCAL, plus anything else... */\n\tint xfd;\n\tint pc_next;\n\tuint page_size;\n\tFILE *ofp;\n\tchar *page;\n\tulong accesses;\n\tulong cache_hits;\n\tulong redundant;\n\tulong last_pfn;\n\tstruct pfn_offset_cache *poc;\n\n\tstruct xc_core_data {\n\t\tint p2m_frames;\n\t\tulong *p2m_frame_index_list;\n\t\tstruct xen_core_header header;\n\t\tint elf_class;\n\t\tuint64_t format_version;\n\t\toff_t elf_strtab_offset;\n\t\toff_t shared_info_offset;\n\t\toff_t ia64_mapped_regs_offset;\n\t\tstruct elf_index_pfn elf_index_pfn[INDEX_PFN_COUNT];\n\t\tstruct last_batch last_batch;\n\t\tElf32_Ehdr *elf32;\n\t\tElf64_Ehdr *elf64;\n\t} xc_core;\n\n\tstruct xc_save_data {\n\t\tulong nr_pfns;\n\t\tint vmconfig_size;\n\t\tchar *vmconfig_buf;\n\t\tulong *p2m_frame_list;\n\t\tuint pfns_not;\n\t\toff_t pfns_not_offset;\n\t\toff_t vcpu_ctxt_offset;\n\t\toff_t shared_info_page_offset;\n\t\toff_t *batch_offsets;\n\t\tulong batch_count;\n\t\tulong *region_pfn_type;\n\t\tulong ia64_version;\n\t\tulong *ia64_page_offsets;\n\t} xc_save;\n\n\tulong panic_pc;\n\tulong panic_sp;\n};\n\n/* from xendump.h */\nstruct xen_dumpcore_p2m {\n\tuint64_t pfn;\n\tuint64_t gmfn; \n};\n```\n\n\n## Upstream Fix\n```diff\n\ncrash patch c3413456599161cabc4e910a0ae91dfe5eec3c21 (xen: Add support for\ndom0 with Linux kernel 3.19 and newer) from Daniel made crash utility\nsupport xen dom0 vmcores after linux kernel commit\n054954eb051f35e74b75a566a96fe756015352c8 (xen: switch to linear virtual\nmapped sparse p2m list).\n\nThis patch can be deemed as a subsequent and make this utility support Xen\nPV domU dumpfiles again.\n\nBasically speaking, readmem() can't be used to read xen_p2m_addr associate\nmemory directly during m2p translation. It introduces infinite recursion.\nFollowing call sequence shows the scenario, it comes from a section of\nbacktrace with only kvaddr, machine addr and mfn left as parameter:\n\nmodule_init()\n\n/* The first readmem() from module_init(). */\nreadmem(addr=0xffffffffa02fe4a0)\n\n/* readmem() needs physical address, so calls kvtop(). */\nkvtop(kvaddr=0xffffffffa02fe4a0)\nx86_64_kvtop(kvaddr=ffffffffa02fe4a0)\n\n/* Calculate physical address by traversing page tables. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffffffa02fe4a0)\n\n/*\n * x86_64_kvtop_xen_wpt() is going to traverse the page table to\n * get the physical address for 0xffffffffa02fe4a0. So, at first it\n * is needed to translate the pgd from machine address to physical\n * address. So invoke xen_m2p() here to do the translation. 0x58687f000\n * is the pgd machine address in x86_64_kvtop_xen_wpt() and is needed\n * to be translated to its physical address.\n */\nxen_m2p(machine=0x58687f000)\n__xen_m2p(machine=0x58687f000, mfn=0x58687f)\n\n/*\n * __xen_m2p() is going to search mfn 0x58687f in p2m VMA which starts\n * at VMA 0xffffc900001cf000. It compares every mfn stored in it with\n * 0x58687f. Once it's proved 0x58687f is one mfn in the p2m, its offset\n * will be used to calculate the pfn.\n *\n * readmem() is invoked by __xen_m2p() to read the page from VMA\n * 0xffffc900001cf000 here.\n */\nreadmem(addr=0xffffc900001cf000)\n\n/*\n * readmem() needs physical address of 0xffffc900001cf000 to make the\n * reading done. So it invokes kvtop() to get the physical address.\n */\nkvtop(kvaddr=0xffffc900001cf000)\nx86_64_kvtop(kvaddr=0xffffc900001cf000)\n\n/* It needs to calculate physical address by traversing page tables. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffc900001cf000)\n\n/*\n * 0x581b7e000 is the machine address of pgd need to be translated here.\n * The mfn is calculated in this way at x86_64_kvtop_xen_wpt():\n *\n * pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);\n * pgd_paddr = (*pml4) & PHYSICAL_PAGE_MASK;\n *\n * The kvaddr 0xffffc900001cf000 here is quite different from the one\n * above, so the machine address of pgd is not the same one. And this\n * pgd is the one we use to access the VMA of p2m table.\n */\nxen_m2p(machine=0x581b7e000)\n__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)\n\n/*\n * Looking for mfn 0x581b7e in the range of p2m page which starts at\n * VMA 0xffffc900001f5000.\n */\nreadmem(addr=0xffffc900001f5000)\n\n/* Need physical address of VMA 0xffffc900001f5000 as same reason above. */\nkvtop(kvaddr=0xffffc900001f5000)\nx86_64_kvtop(kvaddr=0xffffc900001f5000)\n\n/* Need to traverse page tables to calculate physical address for it. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffc900001f5000)\n\n/*\n * Unfortunately, machine address 0x581b7e000 have to be translated again.\n * Endless loop starts from here.\n */\nxen_m2p(machine=0x581b7e000)\n__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)\nreadmem(addr=0xffffc900001f5000)\n\nFortunately, PV domU p2m mapping is also stored at xd->xfd + xch_index_offset\nand organized as struct xen_dumpcore_p2m. We have a chance to read the p2m\nstuff directly from there, and then we avoid the loop above.\n\nSo, this patch implements a special reading function read_xc_p2m() to extract\nthe mfns from xd->xfd + xch_index_offset. This function does not need to read\nmfns from p2m VMA like readmem() does, so, we avoid the endless loop introduced\nby the address translation.\n\nSigned-off-by: Honglei Wang \nReviewed-by: Daniel Kiper \n---\n kernel.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------\n xendump.c | 2 \n xendump.h | 2 \n 3 files changed, 140 insertions(+), 15 deletions(-)\n\n--- a/kernel.c\n+++ b/kernel.c\n@@ -22,6 +22,7 @@\n #include \n #include \n #include \n+#include \"xendump.h\"\n \n static void do_module_cmd(ulong, char *, ulong, char *, char *);\n static void show_module_taint(void);\n@@ -67,6 +68,9 @@ static ulong __xen_m2p(ulonglong, ulong)\n static ulong __xen_pvops_m2p_l2(ulonglong, ulong);\n static ulong __xen_pvops_m2p_l3(ulonglong, ulong);\n static ulong __xen_pvops_m2p_hyper(ulonglong, ulong);\n+static ulong __xen_pvops_m2p_domU(ulonglong, ulong);\n+static int read_xc_p2m(ulonglong addr, void *buffer, long size);\n+static void read_p2m(ulong cache_index, int memtype, void *buffer);\n static int search_mapping_page(ulong, ulong *, ulong *, ulong *);\n static void read_in_kernel_config_err(int, char *);\n static void BUG_bytes_init(void);\n@@ -181,10 +185,7 @@ kernel_init()\n \t\t\t\t\t\t&kt->pvops_xen.p2m_mid_missing);\n \t\t\tget_symbol_data(\"p2m_missing\", sizeof(ulong),\n \t\t\t\t\t\t&kt->pvops_xen.p2m_missing);\n-\t\t} else if (symbol_exists(\"xen_p2m_addr\")) {\n-\t\t\tif (!XEN_CORE_DUMPFILE())\n-\t\t\t\terror(FATAL, \"p2m array in new format is unreadable.\");\n-\t\t} else {\n+\t\t} else if (!symbol_exists(\"xen_p2m_addr\")) {\n \t\t\tkt->pvops_xen.p2m_top_entries = get_array_length(\"p2m_top\", NULL, 0);\n \t\t\tkt->pvops_xen.p2m_top = symbol_value(\"p2m_top\");\n \t\t\tkt->pvops_xen.p2m_missing = symbol_value(\"p2m_missing\");\n@@ -9312,13 +9313,7 @@ __xen_m2p(ulonglong machine, ulong mfn)\n \t\t\t\tif (memtype == PHYSADDR)\n \t\t\t\t\tpc->curcmd_flags |= XEN_MACHINE_ADDR;\n \n-\t\t\t\tif (!readmem(kt->p2m_mapping_cache[c].mapping, memtype,\n-\t\t\t \t mp, PAGESIZE(), \"phys_to_machine_mapping page (cached)\", \n-\t\t\t \t RETURN_ON_ERROR))\n- \terror(FATAL, \"cannot access \"\n- \t \"phys_to_machine_mapping page\\n\");\n-\t\t\t\telse\n-\t\t\t\t\tkt->last_mapping_read = kt->p2m_mapping_cache[c].mapping;\n+\t\t\t\tread_p2m(c, memtype, mp);\n \n \t\t\t\tif (memtype == PHYSADDR)\n \t\t\t\t\tpc->curcmd_flags &= ~XEN_MACHINE_ADDR;\n@@ -9356,9 +9351,12 @@ __xen_m2p(ulonglong machine, ulong mfn)\n \t\t */\n \t\tif (symbol_exists(\"p2m_mid_missing\"))\n \t\t\tpfn = __xen_pvops_m2p_l3(machine, mfn);\n-\t\telse if (symbol_exists(\"xen_p2m_addr\"))\n-\t\t\tpfn = __xen_pvops_m2p_hyper(machine, mfn);\n-\t\telse\n+\t\telse if (symbol_exists(\"xen_p2m_addr\")) {\n+\t\t\tif (XEN_CORE_DUMPFILE())\n+\t\t\t\tpfn = __xen_pvops_m2p_hyper(machine, mfn);\n+\t\t\telse\n+\t\t\t\tpfn = __xen_pvops_m2p_domU(machine, mfn);\n+\t\t} else\n \t\t\tpfn = __xen_pvops_m2p_l2(machine, mfn);\n \n \t\tif (pfn != XEN_MFN_NOT_FOUND)\n@@ -9566,6 +9564,131 @@ __xen_pvops_m2p_hyper(ulonglong machine,\n \treturn XEN_MFN_NOT_FOUND;\n }\n \n+static void read_p2m(ulong cache_index, int memtype, void *buffer)\n+{\n+\t/* \n+\t * Use special read function for PV domain p2m reading.\n+\t * See the comments of read_xc_p2m().\n+\t */\n+\tif (symbol_exists(\"xen_p2m_addr\") && !XEN_CORE_DUMPFILE()) {\n+\t\tif (!read_xc_p2m(kt->p2m_mapping_cache[cache_index].mapping, \n+\t\t\tbuffer, PAGESIZE()))\n+\t\t\terror(FATAL, \"cannot access phys_to_machine_mapping page\\n\");\n+\t} else if (!readmem(kt->p2m_mapping_cache[cache_index].mapping, memtype,\n+\t\t\tbuffer, PAGESIZE(), \"phys_to_machine_mapping page (cached)\",\n+\t\t\tRETURN_ON_ERROR))\n+\t\terror(FATAL, \"cannot access phys_to_machine_mapping page\\n\");\n+\t\n+\tkt->last_mapping_read = kt->p2m_mapping_cache[cache_index].mapping;\n+}\n+\n+/*\n+ * PV domain p2m mapping info is stored in xd->xfd at xch_index_offset. It \n+ * is organized as struct xen_dumpcore_p2m and the pfns are progressively\n+ * increased by 1 from 0.\n+ *\n+ * This is a special p2m reading function for xen PV domain vmcores after\n+ * kernel commit 054954eb051f35e74b75a566a96fe756015352c8 (xen: switch\n+ * to linear virtual mapped sparse p2m list). It is invoked for reading\n+ * p2m associate stuff by read_p2m().\n+ */\n+static int read_xc_p2m(ulonglong addr, void *buffer, long size)\n+{\n+\tulong i, new_p2m_buf_size;\n+\toff_t offset;\n+\tstruct xen_dumpcore_p2m *new_p2m_buf;\n+\tstatic struct xen_dumpcore_p2m *p2m_buf;\n+\tstatic ulong p2m_buf_size = 0;\n+\n+\tif (size <= 0) {\n+\t\tif ((CRASHDEBUG(1) && !STREQ(pc->curcmd, \"search\")) ||\n+\t\t\tCRASHDEBUG(2))\n+\t\t\terror(INFO, \"invalid size request: %ld\\n\", size);\n+\t\treturn FALSE;\n+\t}\n+\n+\t/* \n+\t * We extract xen_dumpcore_p2m.gmfn and copy them into the \n+\t * buffer. So, we need temporary p2m_buf whose size is \n+\t * (size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong)))\n+\t * to put xen_dumpcore_p2m structures read from xd->xfd.\n+\t */\n+\tnew_p2m_buf_size = size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\n+\tif (p2m_buf_size != new_p2m_buf_size) {\n+\t\tp2m_buf_size = new_p2m_buf_size;\n+\n+\t\tnew_p2m_buf = realloc(p2m_buf, p2m_buf_size);\n+\t\tif (new_p2m_buf == NULL) {\n+\t\t\tfree(p2m_buf);\n+\t\t\terror(FATAL, \"cannot realloc p2m buffer\\n\");\n+\t\t}\n+\t\tp2m_buf = new_p2m_buf;\n+\t}\n+\n+\toffset = addr * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\toffset += xd->xc_core.header.xch_index_offset;\n+\n+\tif (lseek(xd->xfd, offset, SEEK_SET) == -1)\n+\t\terror(FATAL,\n+\t\t \"cannot lseek to xch_index_offset offset 0x%lx\\n\", offset);\n+\tif (read(xd->xfd, (void*)p2m_buf, p2m_buf_size) != p2m_buf_size)\n+\t\terror(FATAL,\n+\t\t \"cannot read from xch_index_offset offset 0x%lx\\n\", offset);\n+\n+\tfor (i = 0; i < size / sizeof(ulong); i++)\n+\t\t*((ulong *)buffer + i) = p2m_buf[i].gmfn;\n+\n+\treturn TRUE;\n+}\n+\n+static ulong\n+__xen_pvops_m2p_domU(ulonglong machine, ulong mfn)\n+{\n+\tulong c, end, i, mapping, p, pfn, start;\n+\n+\t/* \n+\t * xch_nr_pages is the number of pages of p2m mapping. It is composed\n+\t * of struct xen_dumpcore_p2m. The stuff we want to copy into the mapping\n+\t * page is mfn whose type is unsigned long.\n+\t * So actual number of p2m pages should be:\n+\t *\n+\t * xch_nr_pages / (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong))\n+\t */\n+\tfor (p = 0;\n+\t p < xd->xc_core.header.xch_nr_pages / \n+\t\t(sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\t ++p) {\n+\n+\t\tmapping = p * PAGESIZE();\n+\n+\t\tif (mapping != kt->last_mapping_read) {\n+\t\t\tif (!read_xc_p2m(mapping, (void *)kt->m2p_page, PAGESIZE()))\n+\t\t\t\terror(FATAL, \"cannot read the last mapping page\\n\");\n+\t\t\tkt->last_mapping_read = mapping;\n+\t\t}\n+\t\tkt->p2m_pages_searched++;\n+\n+\t\tif (search_mapping_page(mfn, &i, &start, &end)) {\n+\t\t\tpfn = p * XEN_PFNS_PER_PAGE + i;\n+\t\t\tc = kt->p2m_cache_index;\n+\t\t\tif (CRASHDEBUG (1))\n+\t\t\t\tconsole(\"mfn: %lx (%llx) i: %ld pfn: %lx (%llx)\\n\",\n+\t\t\t\t\tmfn, machine, i, pfn, XEN_PFN_TO_PSEUDO(pfn));\n+\n+\t\t\tkt->p2m_mapping_cache[c].start = start;\n+\t\t\tkt->p2m_mapping_cache[c].end = end;\n+\t\t\tkt->p2m_mapping_cache[c].mapping = mapping;\n+\t\t\tkt->p2m_mapping_cache[c].pfn = p * XEN_PFNS_PER_PAGE;\n+\t\t\tkt->p2m_cache_index = (c+1) % P2M_MAPPING_CACHE;\n+\t\t\t\n+\t\t\treturn pfn;\n+\t\t}\n+\t}\n+\t\n+\treturn XEN_MFN_NOT_FOUND;\n+}\n+\n /*\n * Search for an mfn in the current mapping page, and if found, \n * determine the range of contiguous mfns that it's contained\n--- a/xendump.c\n+++ b/xendump.c\n@@ -19,7 +19,7 @@\n #include \"xendump.h\"\n \n static struct xendump_data xendump_data = { 0 };\n-static struct xendump_data *xd = &xendump_data;\n+struct xendump_data *xd = &xendump_data;\n \n static int xc_save_verify(char *);\n static int xc_core_verify(char *, char *);\n--- a/xendump.h\n+++ b/xendump.h\n@@ -192,3 +192,5 @@ struct xen_dumpcore_p2m {\n \tuint64_t pfn;\n \tuint64_t gmfn; \n };\n+\n+extern struct xendump_data *xd;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "\ncrash patch c3413456599161cabc4e910a0ae91dfe5eec3c21 (xen: Add support for\ndom0 with Linux kernel 3.19 and newer) from Daniel made crash utility\nsupport xen dom0 vmcores after linux kernel commit\n054954eb051f35e74b75a566a96fe756015352c8 (xen: switch to linear virtual\nmapped sparse p2m list).\n\nThis patch can be deemed as a subsequent and make this utility support Xen\nPV domU dumpfiles again.\n\nBasically speaking, readmem() can't be used to read xen_p2m_addr associate\nmemory directly during m2p translation. It introduces infinite recursion.\nFollowing call sequence shows the scenario, it comes from a section of\nbacktrace with only kvaddr, machine addr and mfn left as parameter:\n\nmodule_init()\n\n/* The first readmem() from module_init(). */\nreadmem(addr=0xffffffffa02fe4a0)\n\n/* readmem() needs physical address, so calls kvtop(). */\nkvtop(kvaddr=0xffffffffa02fe4a0)\nx86_64_kvtop(kvaddr=ffffffffa02fe4a0)\n\n/* Calculate physical address by traversing page tables. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffffffa02fe4a0)\n\n/*\n * x86_64_kvtop_xen_wpt() is going to traverse the page table to\n * get the physical address for 0xffffffffa02fe4a0. So, at first it\n * is needed to translate the pgd from machine address to physical\n * address. So invoke xen_m2p() here to do the translation. 0x58687f000\n * is the pgd machine address in x86_64_kvtop_xen_wpt() and is needed\n * to be translated to its physical address.\n */\nxen_m2p(machine=0x58687f000)\n__xen_m2p(machine=0x58687f000, mfn=0x58687f)\n\n/*\n * __xen_m2p() is going to search mfn 0x58687f in p2m VMA which starts\n * at VMA 0xffffc900001cf000. It compares every mfn stored in it with\n * 0x58687f. Once it's proved 0x58687f is one mfn in the p2m, its offset\n * will be used to calculate the pfn.\n *\n * readmem() is invoked by __xen_m2p() to read the page from VMA\n * 0xffffc900001cf000 here.\n */\nreadmem(addr=0xffffc900001cf000)\n\n/*\n * readmem() needs physical address of 0xffffc900001cf000 to make the\n * reading done. So it invokes kvtop() to get the physical address.\n */\nkvtop(kvaddr=0xffffc900001cf000)\nx86_64_kvtop(kvaddr=0xffffc900001cf000)\n\n/* It needs to calculate physical address by traversing page tables. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffc900001cf000)\n\n/*\n * 0x581b7e000 is the machine address of pgd need to be translated here.\n * The mfn is calculated in this way at x86_64_kvtop_xen_wpt():\n *\n * pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);\n * pgd_paddr = (*pml4) & PHYSICAL_PAGE_MASK;\n *\n * The kvaddr 0xffffc900001cf000 here is quite different from the one\n * above, so the machine address of pgd is not the same one. And this\n * pgd is the one we use to access the VMA of p2m table.\n */\nxen_m2p(machine=0x581b7e000)\n__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)\n\n/*\n * Looking for mfn 0x581b7e in the range of p2m page which starts at\n * VMA 0xffffc900001f5000.\n */\nreadmem(addr=0xffffc900001f5000)\n\n/* Need physical address of VMA 0xffffc900001f5000 as same reason above. */\nkvtop(kvaddr=0xffffc900001f5000)\nx86_64_kvtop(kvaddr=0xffffc900001f5000)\n\n/* Need to traverse page tables to calculate physical address for it. */\nx86_64_kvtop_xen_wpt(kvaddr=0xffffc900001f5000)\n\n/*\n * Unfortunately, machine address 0x581b7e000 have to be translated again.\n * Endless loop starts from here.\n */\nxen_m2p(machine=0x581b7e000)\n__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)\nreadmem(addr=0xffffc900001f5000)\n\nFortunately, PV domU p2m mapping is also stored at xd->xfd + xch_index_offset\nand organized as struct xen_dumpcore_p2m. We have a chance to read the p2m\nstuff directly from there, and then we avoid the loop above.\n\nSo, this patch implements a special reading function read_xc_p2m() to extract\nthe mfns from xd->xfd + xch_index_offset. This function does not need to read\nmfns from p2m VMA like readmem() does, so, we avoid the endless loop introduced\nby the address translation.\n\nSigned-off-by: Honglei Wang \nReviewed-by: Daniel Kiper \n---\n kernel.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------\n xendump.c | 2 \n xendump.h | 2 \n 3 files changed, 140 insertions(+), 15 deletions(-)\n\n--- a/kernel.c\n+++ b/kernel.c\n@@ -22,6 +22,7 @@\n #include \n #include \n #include \n+#include \"xendump.h\"\n \n static void do_module_cmd(ulong, char *, ulong, char *, char *);\n static void show_module_taint(void);\n@@ -67,6 +68,9 @@ static ulong __xen_m2p(ulonglong, ulong)\n static ulong __xen_pvops_m2p_l2(ulonglong, ulong);\n static ulong __xen_pvops_m2p_l3(ulonglong, ulong);\n static ulong __xen_pvops_m2p_hyper(ulonglong, ulong);\n+static ulong __xen_pvops_m2p_domU(ulonglong, ulong);\n+static int read_xc_p2m(ulonglong addr, void *buffer, long size);\n+static void read_p2m(ulong cache_index, int memtype, void *buffer);\n static int search_mapping_page(ulong, ulong *, ulong *, ulong *);\n static void read_in_kernel_config_err(int, char *);\n static void BUG_bytes_init(void);\n@@ -181,10 +185,7 @@ kernel_init()\n \t\t\t\t\t\t&kt->pvops_xen.p2m_mid_missing);\n \t\t\tget_symbol_data(\"p2m_missing\", sizeof(ulong),\n \t\t\t\t\t\t&kt->pvops_xen.p2m_missing);\n-\t\t} else if (symbol_exists(\"xen_p2m_addr\")) {\n-\t\t\tif (!XEN_CORE_DUMPFILE())\n-\t\t\t\terror(FATAL, \"p2m array in new format is unreadable.\");\n-\t\t} else {\n+\t\t} else if (!symbol_exists(\"xen_p2m_addr\")) {\n \t\t\tkt->pvops_xen.p2m_top_entries = get_array_length(\"p2m_top\", NULL, 0);\n \t\t\tkt->pvops_xen.p2m_top = symbol_value(\"p2m_top\");\n \t\t\tkt->pvops_xen.p2m_missing = symbol_value(\"p2m_missing\");\n@@ -9312,13 +9313,7 @@ __xen_m2p(ulonglong machine, ulong mfn)\n \t\t\t\tif (memtype == PHYSADDR)\n \t\t\t\t\tpc->curcmd_flags |= XEN_MACHINE_ADDR;\n \n-\t\t\t\tif (!readmem(kt->p2m_mapping_cache[c].mapping, memtype,\n-\t\t\t \t mp, PAGESIZE(), \"phys_to_machine_mapping page (cached)\", \n-\t\t\t \t RETURN_ON_ERROR))\n- \terror(FATAL, \"cannot access \"\n- \t \"phys_to_machine_mapping page\\n\");\n-\t\t\t\telse\n-\t\t\t\t\tkt->last_mapping_read = kt->p2m_mapping_cache[c].mapping;\n+\t\t\t\tread_p2m(c, memtype, mp);\n \n \t\t\t\tif (memtype == PHYSADDR)\n \t\t\t\t\tpc->curcmd_flags &= ~XEN_MACHINE_ADDR;\n@@ -9356,9 +9351,12 @@ __xen_m2p(ulonglong machine, ulong mfn)\n \t\t */\n \t\tif (symbol_exists(\"p2m_mid_missing\"))\n \t\t\tpfn = __xen_pvops_m2p_l3(machine, mfn);\n-\t\telse if (symbol_exists(\"xen_p2m_addr\"))\n-\t\t\tpfn = __xen_pvops_m2p_hyper(machine, mfn);\n-\t\telse\n+\t\telse if (symbol_exists(\"xen_p2m_addr\")) {\n+\t\t\tif (XEN_CORE_DUMPFILE())\n+\t\t\t\tpfn = __xen_pvops_m2p_hyper(machine, mfn);\n+\t\t\telse\n+\t\t\t\tpfn = __xen_pvops_m2p_domU(machine, mfn);\n+\t\t} else\n \t\t\tpfn = __xen_pvops_m2p_l2(machine, mfn);\n \n \t\tif (pfn != XEN_MFN_NOT_FOUND)\n@@ -9566,6 +9564,131 @@ __xen_pvops_m2p_hyper(ulonglong machine,\n \treturn XEN_MFN_NOT_FOUND;\n }\n \n+static void read_p2m(ulong cache_index, int memtype, void *buffer)\n+{\n+\t/* \n+\t * Use special read function for PV domain p2m reading.\n+\t * See the comments of read_xc_p2m().\n+\t */\n+\tif (symbol_exists(\"xen_p2m_addr\") && !XEN_CORE_DUMPFILE()) {\n+\t\tif (!read_xc_p2m(kt->p2m_mapping_cache[cache_index].mapping, \n+\t\t\tbuffer, PAGESIZE()))\n+\t\t\terror(FATAL, \"cannot access phys_to_machine_mapping page\\n\");\n+\t} else if (!readmem(kt->p2m_mapping_cache[cache_index].mapping, memtype,\n+\t\t\tbuffer, PAGESIZE(), \"phys_to_machine_mapping page (cached)\",\n+\t\t\tRETURN_ON_ERROR))\n+\t\terror(FATAL, \"cannot access phys_to_machine_mapping page\\n\");\n+\t\n+\tkt->last_mapping_read = kt->p2m_mapping_cache[cache_index].mapping;\n+}\n+\n+/*\n+ * PV domain p2m mapping info is stored in xd->xfd at xch_index_offset. It \n+ * is organized as struct xen_dumpcore_p2m and the pfns are progressively\n+ * increased by 1 from 0.\n+ *\n+ * This is a special p2m reading function for xen PV domain vmcores after\n+ * kernel commit 054954eb051f35e74b75a566a96fe756015352c8 (xen: switch\n+ * to linear virtual mapped sparse p2m list). It is invoked for reading\n+ * p2m associate stuff by read_p2m().\n+ */\n+static int read_xc_p2m(ulonglong addr, void *buffer, long size)\n+{\n+\tulong i, new_p2m_buf_size;\n+\toff_t offset;\n+\tstruct xen_dumpcore_p2m *new_p2m_buf;\n+\tstatic struct xen_dumpcore_p2m *p2m_buf;\n+\tstatic ulong p2m_buf_size = 0;\n+\n+\tif (size <= 0) {\n+\t\tif ((CRASHDEBUG(1) && !STREQ(pc->curcmd, \"search\")) ||\n+\t\t\tCRASHDEBUG(2))\n+\t\t\terror(INFO, \"invalid size request: %ld\\n\", size);\n+\t\treturn FALSE;\n+\t}\n+\n+\t/* \n+\t * We extract xen_dumpcore_p2m.gmfn and copy them into the \n+\t * buffer. So, we need temporary p2m_buf whose size is \n+\t * (size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong)))\n+\t * to put xen_dumpcore_p2m structures read from xd->xfd.\n+\t */\n+\tnew_p2m_buf_size = size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\n+\tif (p2m_buf_size != new_p2m_buf_size) {\n+\t\tp2m_buf_size = new_p2m_buf_size;\n+\n+\t\tnew_p2m_buf = realloc(p2m_buf, p2m_buf_size);\n+\t\tif (new_p2m_buf == NULL) {\n+\t\t\tfree(p2m_buf);\n+\t\t\terror(FATAL, \"cannot realloc p2m buffer\\n\");\n+\t\t}\n+\t\tp2m_buf = new_p2m_buf;\n+\t}\n+\n+\toffset = addr * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\toffset += xd->xc_core.header.xch_index_offset;\n+\n+\tif (lseek(xd->xfd, offset, SEEK_SET) == -1)\n+\t\terror(FATAL,\n+\t\t \"cannot lseek to xch_index_offset offset 0x%lx\\n\", offset);\n+\tif (read(xd->xfd, (void*)p2m_buf, p2m_buf_size) != p2m_buf_size)\n+\t\terror(FATAL,\n+\t\t \"cannot read from xch_index_offset offset 0x%lx\\n\", offset);\n+\n+\tfor (i = 0; i < size / sizeof(ulong); i++)\n+\t\t*((ulong *)buffer + i) = p2m_buf[i].gmfn;\n+\n+\treturn TRUE;\n+}\n+\n+static ulong\n+__xen_pvops_m2p_domU(ulonglong machine, ulong mfn)\n+{\n+\tulong c, end, i, mapping, p, pfn, start;\n+\n+\t/* \n+\t * xch_nr_pages is the number of pages of p2m mapping. It is composed\n+\t * of struct xen_dumpcore_p2m. The stuff we want to copy into the mapping\n+\t * page is mfn whose type is unsigned long.\n+\t * So actual number of p2m pages should be:\n+\t *\n+\t * xch_nr_pages / (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong))\n+\t */\n+\tfor (p = 0;\n+\t p < xd->xc_core.header.xch_nr_pages / \n+\t\t(sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));\n+\t ++p) {\n+\n+\t\tmapping = p * PAGESIZE();\n+\n+\t\tif (mapping != kt->last_mapping_read) {\n+\t\t\tif (!read_xc_p2m(mapping, (void *)kt->m2p_page, PAGESIZE()))\n+\t\t\t\terror(FATAL, \"cannot read the last mapping page\\n\");\n+\t\t\tkt->last_mapping_read = mapping;\n+\t\t}\n+\t\tkt->p2m_pages_searched++;\n+\n+\t\tif (search_mapping_page(mfn, &i, &start, &end)) {\n+\t\t\tpfn = p * XEN_PFNS_PER_PAGE + i;\n+\t\t\tc = kt->p2m_cache_index;\n+\t\t\tif (CRASHDEBUG (1))\n+\t\t\t\tconsole(\"mfn: %lx (%llx) i: %ld pfn: %lx (%llx)\\n\",\n+\t\t\t\t\tmfn, machine, i, pfn, XEN_PFN_TO_PSEUDO(pfn));\n+\n+\t\t\tkt->p2m_mapping_cache[c].start = start;\n+\t\t\tkt->p2m_mapping_cache[c].end = end;\n+\t\t\tkt->p2m_mapping_cache[c].mapping = mapping;\n+\t\t\tkt->p2m_mapping_cache[c].pfn = p * XEN_PFNS_PER_PAGE;\n+\t\t\tkt->p2m_cache_index = (c+1) % P2M_MAPPING_CACHE;\n+\t\t\t\n+\t\t\treturn pfn;\n+\t\t}\n+\t}\n+\t\n+\treturn XEN_MFN_NOT_FOUND;\n+}\n+\n /*\n * Search for an mfn in the current mapping page, and if found, \n * determine the range of contiguous mfns that it's contained\n--- a/xendump.c\n+++ b/xendump.c\n@@ -19,7 +19,7 @@\n #include \"xendump.h\"\n \n static struct xendump_data xendump_data = { 0 };\n-static struct xendump_data *xd = &xendump_data;\n+struct xendump_data *xd = &xendump_data;\n \n static int xc_save_verify(char *);\n static int xc_core_verify(char *, char *);\n--- a/xendump.h\n+++ b/xendump.h\n@@ -192,3 +192,5 @@ struct xen_dumpcore_p2m {\n \tuint64_t pfn;\n \tuint64_t gmfn; \n };\n+\n+extern struct xendump_data *xd;\n"}], "metadata": {"id": "crash-8217-crash-xen_add_support_for_domU_with_linux_kernel_from_3.19.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash-xen_add_support_for_domU_with_linux_kernel_from_3.19.patch", "tier": "identical", "language": "c", "patch_lines_changed": 155, "patch_files_count": 0, "total_tokens_est": 5841, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-8217-crash_enable_lzo_support.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- CFLAGS.extra\n- LDFLAGS.extra\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n"}], "metadata": {"id": "crash-8217-crash_enable_snappy_support.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "crash_enable_snappy_support.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 333, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nFrom: Luc Chouinard \n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic/applications/crash/eppic.c\n\n## Target Source Code\n\n### eppic/applications/crash/eppic.c\n\n#### _init() [lines 984-5]\n```c\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Luc Chouinard \nDate: Thu Jun 19 12:28:40 2014 -0700\nSubject: Support for ARM64\nReferences: FATE#320844\nPatch-mainline: yes\nGit-commit: 5391d3dd0e6710c22ec5801f99a6788a2e4b132a\n\nAcked-by: Petr Tesarik \n\n---\n extensions/eppic/applications/crash/eppic.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\n--- a/extensions/eppic/applications/crash/eppic.c\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -1033,10 +1033,14 @@ _init() /* Register the command set. */\n #ifdef PPC64\n #define EPPIC_ABI ABI_PPC64\n #else\n+#ifdef ARM64\n+#define EPPIC_ABI ABI_ARM64\n+#else\n #error eppic: Unkown ABI \n #endif\n #endif\n #endif\n+#endif\n #endif\n #endif\n #endif\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Luc Chouinard \nDate: Thu Jun 19 12:28:40 2014 -0700\nSubject: Support for ARM64\nReferences: FATE#320844\nPatch-mainline: yes\nGit-commit: 5391d3dd0e6710c22ec5801f99a6788a2e4b132a\n\nAcked-by: Petr Tesarik \n\n---\n extensions/eppic/applications/crash/eppic.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\n--- a/extensions/eppic/applications/crash/eppic.c\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -1033,10 +1033,14 @@ _init() /* Register the command set. */\n #ifdef PPC64\n #define EPPIC_ABI ABI_PPC64\n #else\n+#ifdef ARM64\n+#define EPPIC_ABI ABI_ARM64\n+#else\n #error eppic: Unkown ABI \n #endif\n #endif\n #endif\n+#endif\n #endif\n #endif\n #endif\n"}], "metadata": {"id": "crash-8217-eppic-support-arm64.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "eppic-support-arm64.patch", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 497, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nextensions/eppic.mk | 26\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n extensions/eppic.mk | 26 \n extensions/eppic/applications/crash/eppic.c | 1110 ++++++++++++++++++++++++++++\n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -31,29 +31,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GITHUB)\" ] ; then \\\n-\t\t git clone https://github.com/lucchouina/eppic.git eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -64,8 +42,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-8217-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "crash", "incident_id": 8217, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nfilesys.c | 37 ++++++++++++++++++++++++++++---------\n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 481-587]\n```c\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\n---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n"}], "metadata": {"id": "crash-6050-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 37, "patch_files_count": 0, "total_tokens_est": 1130, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-6050-crash-debuginfo-compressed.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 0, "total_tokens_est": 1177, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-6050-crash-make-emacs-default.diff", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 0, "total_tokens_est": 449, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-6050-crash-missing-declarations.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 0, "total_tokens_est": 479, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-6050-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 341, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-6050-crash-sles9-quirk.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1439, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 633-739]\n```c\n#define KMOD_V2 (0x2000)\n#define KALLSYMS_V2 (0x2000)\n#define TVEC_BASES_V2 (0x4000)\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n```\n\n#### region() [lines 5487-5593]\n```c\n */\n#define HELP_COLUMNS 5\n#define START_OF_HELP_DATA(X) \"START_OF_HELP_DATA\" X\n#define END_OF_HELP_DATA \"END_OF_HELP_DATA\"\nvoid help_init(void);\nvoid cmd_usage(char *, int);\nvoid display_version(void);\nvoid display_help_screen(char *);\n#ifdef ARM\n#define dump_machdep_table(X) arm_dump_machdep_table(X)\n#endif\n#ifdef ARM64\n#define dump_machdep_table(X) arm64_dump_machdep_table(X)\n#endif\n#ifdef X86\n#define dump_machdep_table(X) x86_dump_machdep_table(X)\n#endif\n#ifdef ALPHA\n#define dump_machdep_table(X) alpha_dump_machdep_table(X)\n#endif\n#ifdef PPC\n#define dump_machdep_table(X) ppc_dump_machdep_table(X)\n#endif\n#ifdef IA64\n#define dump_machdep_table(X) ia64_dump_machdep_table(X)\n#endif\n#ifdef S390\n#define dump_machdep_table(X) s390_dump_machdep_table(X)\n#endif\n#ifdef S390X\n#define dump_machdep_table(X) s390x_dump_machdep_table(X)\n#endif\n#ifdef X86_64\n#define dump_machdep_table(X) x86_64_dump_machdep_table(X)\n#endif\n#ifdef PPC64\n#define dump_machdep_table(X) ppc64_dump_machdep_table(X)\n#endif\n#ifdef MIPS\n#define dump_machdep_table(X) mips_dump_machdep_table(X)\n#endif\n#ifdef MIPS64\n#define dump_machdep_table(X) mips64_dump_machdep_table(X)\n#endif\n#ifdef SPARC64\n#define dump_machdep_table(X) sparc64_dump_machdep_table(X)\n#endif\nextern char *help_pointer[];\nextern char *help_alias[];\nextern char *help_ascii[];\nextern char *help_bpf[];\nextern char *help_bt[];\nextern char *help_btop[];\nextern char *help_dev[];\nextern char *help_dis[];\nextern char *help_eval[];\nextern char *help_exit[];\nextern char *help_extend[];\nextern char *help_files[];\nextern char *help_foreach[];\nextern char *help_fuser[];\nextern char *help_gdb[];\nextern char *help_help[];\nextern char *help_irq[];\nextern char *help_kmem[];\nextern char *help__list[];\nextern char *help_tree[];\nextern char *help_log[];\nextern char *help_mach[];\nextern char *help_mod[];\nextern char *help_mount[];\nextern char *help_net[];\nextern char *help_p[];\nextern char *help_ps[];\nextern char *help_pte[];\nextern char *help_ptob[];\nextern char *help_ptov[];\nextern char *help_quit[];\nextern char *help_rd[];\nextern char *help_repeat[];\nextern char *help_runq[];\nextern char *help_ipcs[];\nextern char *help_search[];\nextern char *help_set[];\nextern char *help_sig[];\nextern char *help_struct[];\nextern char *help_swap[];\nextern char *help_sym[];\nextern char *help_sys[];\nextern char *help_task[];\nextern char *help_timer[];\nextern char *help_union[];\nextern char *help_vm[];\nextern char *help_vtop[];\nextern char *help_waitq[];\nextern char *help_whatis[];\nextern char *help_wr[];\n#if defined(S390) || defined(S390X)\nextern char *help_s390dbf[];\n#endif\nextern char *help_map[];\n\n/*\n * task.c\n */ \nvoid task_init(void);\nint set_context(ulong, ulong);\n```\n\n#### kernel_init() [lines 188-294]\n```c\n\n#ifdef roundup\n#undef roundup\n#endif\n#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))\n\ntypedef uint64_t physaddr_t;\n\n#define PADDR_NOT_AVAILABLE (0x1ULL)\n#define KCORE_USE_VADDR (-1ULL)\n\ntypedef unsigned long long int ulonglong;\nstruct number_option {\n ulong num;\n ulonglong ll_num;\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n```\n\n#### get_uptime() [lines 4509-4616]\n```c\n#define LONG_DEC (0x8)\n#define LONG_HEX (0x10)\n#define INT_DEC (0x20)\n#define INT_HEX (0x40)\n#define LONGLONG_HEX (0x80)\n#define ZERO_FILL (0x100)\n#define SLONG_DEC (0x200)\n\n#define INIT_TIME (1)\n#define RUN_TIME (2)\n\n/*\n * IRQ line status.\n * For kernels up to and including 2.6.17\n */\n#define IRQ_INPROGRESS_2_6_17 1 /* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_17 2 /* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_17 4 /* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_17 8 /* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_17 16 /* IRQ is being autodetected */\n#define IRQ_WAITING_2_6_17 32 /* IRQ not yet seen - for autodetection */\n#define IRQ_LEVEL_2_6_17 64 /* IRQ level triggered */\n#define IRQ_MASKED_2_6_17 128 /* IRQ masked - shouldn't be seen again */\n\n/*\n * For kernel 2.6.21 and later\n */\n#define IRQ_TYPE_NONE_2_6_21\t\t0x00000000\t/* Default, unspecified type */\n#define IRQ_TYPE_EDGE_RISING_2_6_21\t0x00000001\t/* Edge rising type */\n#define IRQ_TYPE_EDGE_FALLING_2_6_21\t0x00000002\t/* Edge falling type */\n#define IRQ_TYPE_EDGE_BOTH_2_6_21 \t(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)\n#define IRQ_TYPE_LEVEL_HIGH_2_6_21\t0x00000004\t/* Level high type */\n#define IRQ_TYPE_LEVEL_LOW_2_6_21\t0x00000008\t/* Level low type */\n#define IRQ_TYPE_SENSE_MASK_2_6_21\t0x0000000f\t/* Mask of the above */\n#define IRQ_TYPE_PROBE_2_6_21\t\t0x00000010\t/* Probing in progress */\n\n#define IRQ_INPROGRESS_2_6_21\t\t0x00000100\t/* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_21\t\t0x00000200\t/* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_21\t\t0x00000400\t/* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_21\t\t0x00000800\t/* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_21\t\t0x00001000\t/* IRQ is being autodetected */\n#define I\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-6050-crash-sles9-time.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1461, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-6050-crash_enable_lzo_support.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-9576, CVE-2016-9794\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-6050-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2016-9576", "cves": ["CVE-2016-9576", "CVE-2016-9794"], "package": "crash", "incident_id": 6050, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nfilesys.c | 37 ++++++++++++++++++++++++++++---------\n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 481-587]\n```c\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\n---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n"}], "metadata": {"id": "crash-6026-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 37, "patch_files_count": 0, "total_tokens_est": 1133, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-6026-crash-debuginfo-compressed.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 0, "total_tokens_est": 1181, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-6026-crash-make-emacs-default.diff", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 0, "total_tokens_est": 453, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-6026-crash-missing-declarations.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 0, "total_tokens_est": 483, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-6026-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 345, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-6026-crash-sles9-quirk.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1443, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 633-739]\n```c\n#define KMOD_V2 (0x2000)\n#define KALLSYMS_V2 (0x2000)\n#define TVEC_BASES_V2 (0x4000)\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n```\n\n#### region() [lines 5487-5593]\n```c\n */\n#define HELP_COLUMNS 5\n#define START_OF_HELP_DATA(X) \"START_OF_HELP_DATA\" X\n#define END_OF_HELP_DATA \"END_OF_HELP_DATA\"\nvoid help_init(void);\nvoid cmd_usage(char *, int);\nvoid display_version(void);\nvoid display_help_screen(char *);\n#ifdef ARM\n#define dump_machdep_table(X) arm_dump_machdep_table(X)\n#endif\n#ifdef ARM64\n#define dump_machdep_table(X) arm64_dump_machdep_table(X)\n#endif\n#ifdef X86\n#define dump_machdep_table(X) x86_dump_machdep_table(X)\n#endif\n#ifdef ALPHA\n#define dump_machdep_table(X) alpha_dump_machdep_table(X)\n#endif\n#ifdef PPC\n#define dump_machdep_table(X) ppc_dump_machdep_table(X)\n#endif\n#ifdef IA64\n#define dump_machdep_table(X) ia64_dump_machdep_table(X)\n#endif\n#ifdef S390\n#define dump_machdep_table(X) s390_dump_machdep_table(X)\n#endif\n#ifdef S390X\n#define dump_machdep_table(X) s390x_dump_machdep_table(X)\n#endif\n#ifdef X86_64\n#define dump_machdep_table(X) x86_64_dump_machdep_table(X)\n#endif\n#ifdef PPC64\n#define dump_machdep_table(X) ppc64_dump_machdep_table(X)\n#endif\n#ifdef MIPS\n#define dump_machdep_table(X) mips_dump_machdep_table(X)\n#endif\n#ifdef MIPS64\n#define dump_machdep_table(X) mips64_dump_machdep_table(X)\n#endif\n#ifdef SPARC64\n#define dump_machdep_table(X) sparc64_dump_machdep_table(X)\n#endif\nextern char *help_pointer[];\nextern char *help_alias[];\nextern char *help_ascii[];\nextern char *help_bpf[];\nextern char *help_bt[];\nextern char *help_btop[];\nextern char *help_dev[];\nextern char *help_dis[];\nextern char *help_eval[];\nextern char *help_exit[];\nextern char *help_extend[];\nextern char *help_files[];\nextern char *help_foreach[];\nextern char *help_fuser[];\nextern char *help_gdb[];\nextern char *help_help[];\nextern char *help_irq[];\nextern char *help_kmem[];\nextern char *help__list[];\nextern char *help_tree[];\nextern char *help_log[];\nextern char *help_mach[];\nextern char *help_mod[];\nextern char *help_mount[];\nextern char *help_net[];\nextern char *help_p[];\nextern char *help_ps[];\nextern char *help_pte[];\nextern char *help_ptob[];\nextern char *help_ptov[];\nextern char *help_quit[];\nextern char *help_rd[];\nextern char *help_repeat[];\nextern char *help_runq[];\nextern char *help_ipcs[];\nextern char *help_search[];\nextern char *help_set[];\nextern char *help_sig[];\nextern char *help_struct[];\nextern char *help_swap[];\nextern char *help_sym[];\nextern char *help_sys[];\nextern char *help_task[];\nextern char *help_timer[];\nextern char *help_union[];\nextern char *help_vm[];\nextern char *help_vtop[];\nextern char *help_waitq[];\nextern char *help_whatis[];\nextern char *help_wr[];\n#if defined(S390) || defined(S390X)\nextern char *help_s390dbf[];\n#endif\nextern char *help_map[];\n\n/*\n * task.c\n */ \nvoid task_init(void);\nint set_context(ulong, ulong);\n```\n\n#### kernel_init() [lines 188-294]\n```c\n\n#ifdef roundup\n#undef roundup\n#endif\n#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))\n\ntypedef uint64_t physaddr_t;\n\n#define PADDR_NOT_AVAILABLE (0x1ULL)\n#define KCORE_USE_VADDR (-1ULL)\n\ntypedef unsigned long long int ulonglong;\nstruct number_option {\n ulong num;\n ulonglong ll_num;\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n```\n\n#### get_uptime() [lines 4509-4616]\n```c\n#define LONG_DEC (0x8)\n#define LONG_HEX (0x10)\n#define INT_DEC (0x20)\n#define INT_HEX (0x40)\n#define LONGLONG_HEX (0x80)\n#define ZERO_FILL (0x100)\n#define SLONG_DEC (0x200)\n\n#define INIT_TIME (1)\n#define RUN_TIME (2)\n\n/*\n * IRQ line status.\n * For kernels up to and including 2.6.17\n */\n#define IRQ_INPROGRESS_2_6_17 1 /* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_17 2 /* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_17 4 /* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_17 8 /* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_17 16 /* IRQ is being autodetected */\n#define IRQ_WAITING_2_6_17 32 /* IRQ not yet seen - for autodetection */\n#define IRQ_LEVEL_2_6_17 64 /* IRQ level triggered */\n#define IRQ_MASKED_2_6_17 128 /* IRQ masked - shouldn't be seen again */\n\n/*\n * For kernel 2.6.21 and later\n */\n#define IRQ_TYPE_NONE_2_6_21\t\t0x00000000\t/* Default, unspecified type */\n#define IRQ_TYPE_EDGE_RISING_2_6_21\t0x00000001\t/* Edge rising type */\n#define IRQ_TYPE_EDGE_FALLING_2_6_21\t0x00000002\t/* Edge falling type */\n#define IRQ_TYPE_EDGE_BOTH_2_6_21 \t(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)\n#define IRQ_TYPE_LEVEL_HIGH_2_6_21\t0x00000004\t/* Level high type */\n#define IRQ_TYPE_LEVEL_LOW_2_6_21\t0x00000008\t/* Level low type */\n#define IRQ_TYPE_SENSE_MASK_2_6_21\t0x0000000f\t/* Mask of the above */\n#define IRQ_TYPE_PROBE_2_6_21\t\t0x00000010\t/* Probing in progress */\n\n#define IRQ_INPROGRESS_2_6_21\t\t0x00000100\t/* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_21\t\t0x00000200\t/* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_21\t\t0x00000400\t/* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_21\t\t0x00000800\t/* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_21\t\t0x00001000\t/* IRQ is being autodetected */\n#define I\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-6026-crash-sles9-time.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1465, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-6026-crash_enable_lzo_support.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8632, CVE-2016-8655, CVE-2016-9555\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-6026-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2016-8632", "cves": ["CVE-2016-8632", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6026, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 480-586]\n```c\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: b/filesys.c\n===================================================================\n--- a/filesys.c\n+++ b/filesys.c\n@@ -529,6 +529,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -578,16 +579,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -607,10 +616,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: b/filesys.c\n===================================================================\n--- a/filesys.c\n+++ b/filesys.c\n@@ -529,6 +529,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -578,16 +579,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -607,10 +616,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n"}], "metadata": {"id": "crash-6025-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 26, "patch_files_count": 1, "total_tokens_est": 1090, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -192,9 +192,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -253,13 +253,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -280,14 +283,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -192,9 +192,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -253,13 +253,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -280,14 +283,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-6025-crash-debuginfo-compressed.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 1, "total_tokens_est": 1258, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- b/main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: b/main.c\n===================================================================\n--- a/main.c\n+++ b/main.c\n@@ -1037,12 +1037,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1092,7 +1086,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: b/main.c\n===================================================================\n--- a/main.c\n+++ b/main.c\n@@ -1037,12 +1037,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1092,7 +1086,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-6025-crash-make-emacs-default.diff", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 1, "total_tokens_est": 529, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: b/gdb-7.6.patch\n===================================================================\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: b/gdb-7.6.patch\n===================================================================\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-6025-crash-missing-declarations.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 1, "total_tokens_est": 562, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- Makefile\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\t2014-09-17 10:54:23.070488397 -0400\n+++ b/Makefile\t2014-09-17 10:54:59.557726952 -0400\n@@ -260,8 +260,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \n library: make_build_data ${OBJECT_FILES}\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Apply custom patches to gdb\nPatch-mainline: never\n\nEnhance the crash specfile to allow applying custom patches.\n\nUpdate jeffm 17 Sep 2014: What used to be in the series file is now in\ngdb-7.6-ppc64le-support.patch. We used to apply it unconditionally so\nwe'll continue to do so.\n\nSigned-off-by: Petr Tesarik \n\n---\n Makefile | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\n--- a/Makefile\t2014-09-17 10:54:23.070488397 -0400\n+++ b/Makefile\t2014-09-17 10:54:59.557726952 -0400\n@@ -260,8 +260,11 @@ gdb_unzip:\n gdb_patch:\n \tif [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ]; then \\\n \t\tpatch -p0 < ${GDB}.patch; cp ${GDB}.patch ${GDB}; fi\n-\tif [ \"${ARCH}\" = \"ppc64le\" ] && [ -f ${GDB}-ppc64le-support.patch ]; then \\\n-\t\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tpatch -d ${GDB} -p1 -F0 < ${GDB}-ppc64le-support.patch ; \\\n+\tif [ -f ${GDB}.series ]; then \\\n+\t\twhile read p; do \\\n+\t\t\tpatch -d ${GDB} -p1 -F0 < \"$$p\" ; \\\n+\t\tdone < ${GDB}.series ; \\\n \tfi\n \n library: make_build_data ${OBJECT_FILES}\n"}], "metadata": {"id": "crash-6025-crash-patch-gdb.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-patch-gdb.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 7, "patch_files_count": 0, "total_tokens_est": 704, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-6025-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 379, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- b/lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\nIndex: b/lkcd_v8.c\n===================================================================\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\nIndex: b/lkcd_v8.c\n===================================================================\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-6025-crash-sles9-quirk.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 1, "total_tokens_est": 1520, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 636-742]\n```c\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n (((kt->p2m_mapping_cache[c].mapping - kt->phys_to_machine_mapping)/PAGESIZE()) \\\n * XEN_PFNS_PER_PAGE))\n\tulong last_mapping_read;\n```\n\n#### region() [lines 5786-5892]\n```c\n\tint fd;\n\tint flags;\n\tint type;\n\tlong csum;\n\toff_t size;\n};\n\n#define REMOTE_VERBOSE (O_RDWR << 1)\n#define REMOTE_COPY_DONE (REMOTE_VERBOSE << 1)\n#define TYPE_ELF (REMOTE_VERBOSE << 2)\n#define TYPE_DEVMEM (REMOTE_VERBOSE << 3)\n#define TYPE_MCLXCD (REMOTE_VERBOSE << 4)\n#define TYPE_LKCD (REMOTE_VERBOSE << 5)\n#define TYPE_S390D (REMOTE_VERBOSE << 6)\n#define TYPE_NETDUMP (REMOTE_VERBOSE << 7)\n\nulonglong xen_m2p(ulonglong);\n\nvoid read_in_kernel_config(int);\n\n#define IKCFG_INIT (0)\n#define IKCFG_READ (1)\n#define IKCFG_SETUP (2)\n#define IKCFG_FREE (3)\n\nint get_kernel_config(char *, char **);\nenum {\n\tIKCONFIG_N,\n\tIKCONFIG_Y,\n\tIKCONFIG_M,\n\tIKCONFIG_STR,\n};\n\n#define MAGIC_START \"IKCFG_ST\"\n#define MAGIC_END \"IKCFG_ED\"\n#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)\n\n/*\n * dev.c\n */\nvoid dev_init(void);\nvoid dump_dev_table(void);\nvoid devdump_extract(void *, ulonglong, char *, FILE *);\nvoid devdump_info(void *, ulonglong, FILE *);\n\n/*\n * ipcs.c\n */\nvoid ipcs_init(void);\nulong idr_find(ulong, int);\n\n#ifdef ARM\nvoid arm_init(int);\nvoid arm_dump_machdep_table(ulong);\nint arm_is_vmalloc_addr(ulong);\nvoid arm_dump_backtrace_entry(struct bt_info *, int, ulong, ulong);\n\n#define display_idt_table() \\\n error(FATAL, \"-d option is not applicable to ARM architecture\\n\")\n\nstruct arm_pt_regs {\n\tulong uregs[18];\n};\n\n#define ARM_cpsr\turegs[16]\n#define ARM_pc\t\turegs[15]\n#define ARM_lr\t\turegs[14]\n#define ARM_sp\t\turegs[13]\n#define ARM_ip\t\turegs[12]\n#define ARM_fp\t\turegs[11]\n#define ARM_r10\t\turegs[10]\n#define ARM_r9\t\turegs[9]\n#define ARM_r8\t\turegs[8]\n#define ARM_r7\t\turegs[7]\n#define ARM_r6\t\turegs[6]\n#define ARM_r5\t\turegs[5]\n#define ARM_r4\t\turegs[4]\n#define ARM_r3\t\turegs[3]\n#define ARM_r2\t\turegs[2]\n#define ARM_r1\t\turegs[1]\n#define ARM_r0\t\turegs[0]\n#define ARM_ORIG_r0\turegs[17]\n\n#define KSYMS_START\t(0x1)\n#define PHYS_BASE\t(0x2)\n#define PGTABLE_V2\t(0x4)\n#define IDMAP_PGD\t(0x8)\n\n#define KVBASE_MASK\t(0x1ffffff)\n\nstruct machine_specific {\n\tulong phys_base;\n\tulong vmalloc_start_addr;\n\tulong modules_vaddr;\n\tulong modules_end;\n\tulong kernel_text_start;\n\tulong kernel_text_end;\n\tulong exception_text_start;\n\tulong exception_text_end;\n\tulonglong last_pgd_read_lpae;\n\tulonglong last_pmd_read_lpae;\n\tulonglong last_ptbl_read_lpae;\n\tstruct arm_pt_regs *crash_task_regs;\n\tint unwind_index_prel31;\n};\n\nint init_unwind_tables(void);\n```\n\n#### kernel_init() [lines 203-309]\n```c\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n#define KVMDUMP_DUMPFILE() (pc->flags & KVMDUMP)\n#define SADUMP_DUMPFILE() (pc->flags & SADUMP)\n#define VMSS_DUMPFILE() (pc->flags & VMWARE_VMSS)\n#define QEMU_MEM_DUMP_NO_VMCOREINFO() \\\n\t ((pc->flags2 & (QEMU_MEM_DUMP_ELF|QEMU_MEM_DUMP_COMPRESSED)) && !(pc->flags2 & VMCOREINFO))\n\n\n#define NETDUMP_LOCAL (0x1) /* netdump_data flags */\n#define NETDUMP_REMOTE (0x2) \n#define VMCORE_VALID() (nd->flags & (NETDUMP_LOCAL|NETDUMP_REMOTE|KDUMP_LOCAL))\n#define NETDUMP_ELF32 (0x4)\n#define NETDUMP_ELF64 (0x8)\n#define PARTIAL_DUMP (0x10) /* netdump or diskdump */\n#define KDUMP_ELF32 (0x20)\n#define KDUMP_ELF64 (0x40)\n```\n\n#### get_uptime() [lines 4757-4864]\n```c\n#define GNU_ADD_SYMBOL_FILE (11)\n#define GNU_DELETE_SYMBOL_FILE (12)\n#define GNU_VERSION (13)\n#define GNU_PATCH_SYMBOL_VALUES (14)\n#define GNU_GET_SYMBOL_TYPE (15)\n#define GNU_USER_PRINT_OPTION (16)\n#define GNU_SET_CRASH_BLOCK (17)\n#define GNU_GET_FUNCTION_RANGE (18)\n#define GNU_GET_NEXT_DATATYPE (19)\n#define GNU_LOOKUP_STRUCT_CONTENTS (20)\n#define GNU_DEBUG_COMMAND (100)\n/*\n * GNU flags\n */\n#define GNU_PRINT_LINE_NUMBERS (0x1)\n#define GNU_FUNCTION_ONLY (0x2)\n#define GNU_PRINT_ENUMERATORS (0x4)\n#define GNU_RETURN_ON_ERROR (0x8)\n#define GNU_COMMAND_FAILED (0x10)\n#define GNU_FROM_TTY_OFF (0x20)\n#define GNU_NO_READMEM (0x40)\n#define GNU_VAR_LENGTH_TYPECODE (0x80)\n\n#undef TRUE\n#undef FALSE\n\n#define TRUE (1)\n#define FALSE (0)\n\n#ifdef GDB_COMMON\n/*\n * function prototypes required by modified gdb source files.\n */\nint console(char *, ...);\nint gdb_CRASHDEBUG(ulong);\nint gdb_readmem_callback(ulong, void *, int, int);\nvoid patch_load_module(struct objfile *objfile, struct minimal_symbol *msymbol);\nint patch_kernel_symbol(struct gnu_request *);\nstruct syment *symbol_search(char *);\nint gdb_line_number_callback(ulong, ulong, ulong);\nint gdb_print_callback(ulong);\n#endif\n\n#ifndef GDB_COMMON\n/*\n * WARNING: the following type codes are type_code enums from gdb/gdbtypes.h\n */\nenum type_code {\n TYPE_CODE_UNDEF, /* Not used; catches errors */\n TYPE_CODE_PTR, /* Pointer type */\n TYPE_CODE_ARRAY, /* Array type with lower & upper bounds. */\n TYPE_CODE_STRUCT, /* C struct or Pascal record */\n TYPE_CODE_UNION, /* C union or Pascal variant part */\n TYPE_CODE_ENUM, /* Enumeration type */\n#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) || defined(GD\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -685,6 +685,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5835,6 +5836,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -252,6 +252,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4806,7 +4812,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5358,6 +5364,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -685,6 +685,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5835,6 +5836,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -252,6 +252,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4806,7 +4812,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5358,6 +5364,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-6025-crash-sles9-time.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1498, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Files to modify\n- b/CFLAGS.extra\n- b/LDFLAGS.extra\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\nIndex: b/CFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\nIndex: b/LDFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\nIndex: b/CFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\nIndex: b/LDFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-6025-crash_enable_lzo_support.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 2, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- CFLAGS.extra\n- LDFLAGS.extra\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n"}], "metadata": {"id": "crash-6025-crash_enable_snappy_support.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "crash_enable_snappy_support.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 375, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8655, CVE-2016-7910, CVE-2015-8962, CVE-2016-7911, CVE-2016-7913, CVE-2016-9555, CVE-2015-8963, CVE-2016-7916, CVE-2016-7914, CVE-2016-8646, CVE-2016-8633, CVE-2016-7042\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- b/extensions/eppic.mk\n- b/extensions/eppic/applications/crash/eppic.c\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\nIndex: b/extensions/eppic.mk\n===================================================================\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\nIndex: b/extensions/eppic/applications/crash/eppic.c\n===================================================================\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\nIndex: b/extensions/eppic.mk\n===================================================================\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\nIndex: b/extensions/eppic/applications/crash/eppic.c\n===================================================================\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-6025-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2016-8655", "cves": ["CVE-2015-8962", "CVE-2015-8963", "CVE-2016-7042", "CVE-2016-7910", "CVE-2016-7911", "CVE-2016-7913", "CVE-2016-7914", "CVE-2016-7916", "CVE-2016-8633", "CVE-2016-8646", "CVE-2016-8655", "CVE-2016-9555"], "package": "crash", "incident_id": 6025, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "c", "patch_files_count": 2, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nfilesys.c | 37 ++++++++++++++++++++++++++++---------\n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 481-587]\n```c\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\n---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n"}], "metadata": {"id": "crash-5948-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 37, "patch_files_count": 0, "total_tokens_est": 1167, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-5948-crash-debuginfo-compressed.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 0, "total_tokens_est": 1214, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-5948-crash-make-emacs-default.diff", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 0, "total_tokens_est": 486, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-5948-crash-missing-declarations.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 0, "total_tokens_est": 516, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-5948-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 379, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-5948-crash-sles9-quirk.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1476, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 633-739]\n```c\n#define KMOD_V2 (0x2000)\n#define KALLSYMS_V2 (0x2000)\n#define TVEC_BASES_V2 (0x4000)\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n```\n\n#### region() [lines 5487-5593]\n```c\n */\n#define HELP_COLUMNS 5\n#define START_OF_HELP_DATA(X) \"START_OF_HELP_DATA\" X\n#define END_OF_HELP_DATA \"END_OF_HELP_DATA\"\nvoid help_init(void);\nvoid cmd_usage(char *, int);\nvoid display_version(void);\nvoid display_help_screen(char *);\n#ifdef ARM\n#define dump_machdep_table(X) arm_dump_machdep_table(X)\n#endif\n#ifdef ARM64\n#define dump_machdep_table(X) arm64_dump_machdep_table(X)\n#endif\n#ifdef X86\n#define dump_machdep_table(X) x86_dump_machdep_table(X)\n#endif\n#ifdef ALPHA\n#define dump_machdep_table(X) alpha_dump_machdep_table(X)\n#endif\n#ifdef PPC\n#define dump_machdep_table(X) ppc_dump_machdep_table(X)\n#endif\n#ifdef IA64\n#define dump_machdep_table(X) ia64_dump_machdep_table(X)\n#endif\n#ifdef S390\n#define dump_machdep_table(X) s390_dump_machdep_table(X)\n#endif\n#ifdef S390X\n#define dump_machdep_table(X) s390x_dump_machdep_table(X)\n#endif\n#ifdef X86_64\n#define dump_machdep_table(X) x86_64_dump_machdep_table(X)\n#endif\n#ifdef PPC64\n#define dump_machdep_table(X) ppc64_dump_machdep_table(X)\n#endif\n#ifdef MIPS\n#define dump_machdep_table(X) mips_dump_machdep_table(X)\n#endif\n#ifdef MIPS64\n#define dump_machdep_table(X) mips64_dump_machdep_table(X)\n#endif\n#ifdef SPARC64\n#define dump_machdep_table(X) sparc64_dump_machdep_table(X)\n#endif\nextern char *help_pointer[];\nextern char *help_alias[];\nextern char *help_ascii[];\nextern char *help_bpf[];\nextern char *help_bt[];\nextern char *help_btop[];\nextern char *help_dev[];\nextern char *help_dis[];\nextern char *help_eval[];\nextern char *help_exit[];\nextern char *help_extend[];\nextern char *help_files[];\nextern char *help_foreach[];\nextern char *help_fuser[];\nextern char *help_gdb[];\nextern char *help_help[];\nextern char *help_irq[];\nextern char *help_kmem[];\nextern char *help__list[];\nextern char *help_tree[];\nextern char *help_log[];\nextern char *help_mach[];\nextern char *help_mod[];\nextern char *help_mount[];\nextern char *help_net[];\nextern char *help_p[];\nextern char *help_ps[];\nextern char *help_pte[];\nextern char *help_ptob[];\nextern char *help_ptov[];\nextern char *help_quit[];\nextern char *help_rd[];\nextern char *help_repeat[];\nextern char *help_runq[];\nextern char *help_ipcs[];\nextern char *help_search[];\nextern char *help_set[];\nextern char *help_sig[];\nextern char *help_struct[];\nextern char *help_swap[];\nextern char *help_sym[];\nextern char *help_sys[];\nextern char *help_task[];\nextern char *help_timer[];\nextern char *help_union[];\nextern char *help_vm[];\nextern char *help_vtop[];\nextern char *help_waitq[];\nextern char *help_whatis[];\nextern char *help_wr[];\n#if defined(S390) || defined(S390X)\nextern char *help_s390dbf[];\n#endif\nextern char *help_map[];\n\n/*\n * task.c\n */ \nvoid task_init(void);\nint set_context(ulong, ulong);\n```\n\n#### kernel_init() [lines 188-294]\n```c\n\n#ifdef roundup\n#undef roundup\n#endif\n#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))\n\ntypedef uint64_t physaddr_t;\n\n#define PADDR_NOT_AVAILABLE (0x1ULL)\n#define KCORE_USE_VADDR (-1ULL)\n\ntypedef unsigned long long int ulonglong;\nstruct number_option {\n ulong num;\n ulonglong ll_num;\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n```\n\n#### get_uptime() [lines 4509-4616]\n```c\n#define LONG_DEC (0x8)\n#define LONG_HEX (0x10)\n#define INT_DEC (0x20)\n#define INT_HEX (0x40)\n#define LONGLONG_HEX (0x80)\n#define ZERO_FILL (0x100)\n#define SLONG_DEC (0x200)\n\n#define INIT_TIME (1)\n#define RUN_TIME (2)\n\n/*\n * IRQ line status.\n * For kernels up to and including 2.6.17\n */\n#define IRQ_INPROGRESS_2_6_17 1 /* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_17 2 /* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_17 4 /* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_17 8 /* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_17 16 /* IRQ is being autodetected */\n#define IRQ_WAITING_2_6_17 32 /* IRQ not yet seen - for autodetection */\n#define IRQ_LEVEL_2_6_17 64 /* IRQ level triggered */\n#define IRQ_MASKED_2_6_17 128 /* IRQ masked - shouldn't be seen again */\n\n/*\n * For kernel 2.6.21 and later\n */\n#define IRQ_TYPE_NONE_2_6_21\t\t0x00000000\t/* Default, unspecified type */\n#define IRQ_TYPE_EDGE_RISING_2_6_21\t0x00000001\t/* Edge rising type */\n#define IRQ_TYPE_EDGE_FALLING_2_6_21\t0x00000002\t/* Edge falling type */\n#define IRQ_TYPE_EDGE_BOTH_2_6_21 \t(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)\n#define IRQ_TYPE_LEVEL_HIGH_2_6_21\t0x00000004\t/* Level high type */\n#define IRQ_TYPE_LEVEL_LOW_2_6_21\t0x00000008\t/* Level low type */\n#define IRQ_TYPE_SENSE_MASK_2_6_21\t0x0000000f\t/* Mask of the above */\n#define IRQ_TYPE_PROBE_2_6_21\t\t0x00000010\t/* Probing in progress */\n\n#define IRQ_INPROGRESS_2_6_21\t\t0x00000100\t/* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_21\t\t0x00000200\t/* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_21\t\t0x00000400\t/* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_21\t\t0x00000800\t/* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_21\t\t0x00001000\t/* IRQ is being autodetected */\n#define I\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-5948-crash-sles9-time.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1498, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-5948-crash_enable_lzo_support.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## 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\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-5948-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2013-5634", "cves": ["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"], "package": "crash", "incident_id": 5948, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 480-586]\n```c\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: b/filesys.c\n===================================================================\n--- a/filesys.c\n+++ b/filesys.c\n@@ -529,6 +529,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -578,16 +579,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -607,10 +616,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Automatically detect compressed booted kernel\nReferences: bnc#777516, bnc#828260\nPatch-mainline: not yet\n\nSigned-off-by: Petr Tesarik \n\n---\n filesys.c | 26 ++++++++++++++++++++++----\n 1 file changed, 22 insertions(+), 4 deletions(-)\n\nIndex: b/filesys.c\n===================================================================\n--- a/filesys.c\n+++ b/filesys.c\n@@ -529,6 +529,7 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -578,16 +579,24 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (!is_compressed_kernel(kernel, &real_kernel))\n+\t\t\t\treal_kernel = kernel;\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel)) {\n+\t\t\t\tif (real_kernel != kernel)\n+\t\t\t\t\tfree(real_kernel);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -607,10 +616,19 @@ find_booted_kernel(void)\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (real_kernel != kernel) {\n+\t\t\t\tpc->namelist_orig = pc->namelist;\n+\t\t\t\tpc->namelist = real_kernel;\n+\t\t\t}\n return TRUE;\n }\n \t}\n \n+\tif (real_kernel != kernel) {\n+\t\tremove(real_kernel);\n+\t\tfree(real_kernel);\n+\t}\n+\n \terror(INFO, \n \"cannot find booted kernel -- please enter namelist argument\\n\\n\");\n \treturn FALSE;\n"}], "metadata": {"id": "crash-5752-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 26, "patch_files_count": 1, "total_tokens_est": 1090, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -192,9 +192,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -253,13 +253,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -280,14 +283,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\nIndex: b/symbols.c\n===================================================================\n--- a/symbols.c\n+++ b/symbols.c\n@@ -192,9 +192,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -253,13 +253,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -280,14 +283,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-5752-crash-debuginfo-compressed.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 1, "total_tokens_est": 1258, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- b/main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: b/main.c\n===================================================================\n--- a/main.c\n+++ b/main.c\n@@ -1037,12 +1037,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1092,7 +1086,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\nIndex: b/main.c\n===================================================================\n--- a/main.c\n+++ b/main.c\n@@ -1037,12 +1037,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1092,7 +1086,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-5752-crash-make-emacs-default.diff", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 1, "total_tokens_est": 529, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- b/gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: b/gdb-7.6.patch\n===================================================================\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\nIndex: b/gdb-7.6.patch\n===================================================================\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-5752-crash-missing-declarations.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 1, "total_tokens_est": 562, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-5752-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 379, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- b/lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\nIndex: b/lkcd_v8.c\n===================================================================\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\nIndex: b/lkcd_v8.c\n===================================================================\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-5752-crash-sles9-quirk.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 1, "total_tokens_est": 1520, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 636-742]\n```c\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n (((kt->p2m_mapping_cache[c].mapping - kt->phys_to_machine_mapping)/PAGESIZE()) \\\n * XEN_PFNS_PER_PAGE))\n\tulong last_mapping_read;\n```\n\n#### region() [lines 5786-5892]\n```c\n\tint fd;\n\tint flags;\n\tint type;\n\tlong csum;\n\toff_t size;\n};\n\n#define REMOTE_VERBOSE (O_RDWR << 1)\n#define REMOTE_COPY_DONE (REMOTE_VERBOSE << 1)\n#define TYPE_ELF (REMOTE_VERBOSE << 2)\n#define TYPE_DEVMEM (REMOTE_VERBOSE << 3)\n#define TYPE_MCLXCD (REMOTE_VERBOSE << 4)\n#define TYPE_LKCD (REMOTE_VERBOSE << 5)\n#define TYPE_S390D (REMOTE_VERBOSE << 6)\n#define TYPE_NETDUMP (REMOTE_VERBOSE << 7)\n\nulonglong xen_m2p(ulonglong);\n\nvoid read_in_kernel_config(int);\n\n#define IKCFG_INIT (0)\n#define IKCFG_READ (1)\n#define IKCFG_SETUP (2)\n#define IKCFG_FREE (3)\n\nint get_kernel_config(char *, char **);\nenum {\n\tIKCONFIG_N,\n\tIKCONFIG_Y,\n\tIKCONFIG_M,\n\tIKCONFIG_STR,\n};\n\n#define MAGIC_START \"IKCFG_ST\"\n#define MAGIC_END \"IKCFG_ED\"\n#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)\n\n/*\n * dev.c\n */\nvoid dev_init(void);\nvoid dump_dev_table(void);\nvoid devdump_extract(void *, ulonglong, char *, FILE *);\nvoid devdump_info(void *, ulonglong, FILE *);\n\n/*\n * ipcs.c\n */\nvoid ipcs_init(void);\nulong idr_find(ulong, int);\n\n#ifdef ARM\nvoid arm_init(int);\nvoid arm_dump_machdep_table(ulong);\nint arm_is_vmalloc_addr(ulong);\nvoid arm_dump_backtrace_entry(struct bt_info *, int, ulong, ulong);\n\n#define display_idt_table() \\\n error(FATAL, \"-d option is not applicable to ARM architecture\\n\")\n\nstruct arm_pt_regs {\n\tulong uregs[18];\n};\n\n#define ARM_cpsr\turegs[16]\n#define ARM_pc\t\turegs[15]\n#define ARM_lr\t\turegs[14]\n#define ARM_sp\t\turegs[13]\n#define ARM_ip\t\turegs[12]\n#define ARM_fp\t\turegs[11]\n#define ARM_r10\t\turegs[10]\n#define ARM_r9\t\turegs[9]\n#define ARM_r8\t\turegs[8]\n#define ARM_r7\t\turegs[7]\n#define ARM_r6\t\turegs[6]\n#define ARM_r5\t\turegs[5]\n#define ARM_r4\t\turegs[4]\n#define ARM_r3\t\turegs[3]\n#define ARM_r2\t\turegs[2]\n#define ARM_r1\t\turegs[1]\n#define ARM_r0\t\turegs[0]\n#define ARM_ORIG_r0\turegs[17]\n\n#define KSYMS_START\t(0x1)\n#define PHYS_BASE\t(0x2)\n#define PGTABLE_V2\t(0x4)\n#define IDMAP_PGD\t(0x8)\n\n#define KVBASE_MASK\t(0x1ffffff)\n\nstruct machine_specific {\n\tulong phys_base;\n\tulong vmalloc_start_addr;\n\tulong modules_vaddr;\n\tulong modules_end;\n\tulong kernel_text_start;\n\tulong kernel_text_end;\n\tulong exception_text_start;\n\tulong exception_text_end;\n\tulonglong last_pgd_read_lpae;\n\tulonglong last_pmd_read_lpae;\n\tulonglong last_ptbl_read_lpae;\n\tstruct arm_pt_regs *crash_task_regs;\n\tint unwind_index_prel31;\n};\n\nint init_unwind_tables(void);\n```\n\n#### kernel_init() [lines 203-309]\n```c\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n#define KVMDUMP_DUMPFILE() (pc->flags & KVMDUMP)\n#define SADUMP_DUMPFILE() (pc->flags & SADUMP)\n#define VMSS_DUMPFILE() (pc->flags & VMWARE_VMSS)\n#define QEMU_MEM_DUMP_NO_VMCOREINFO() \\\n\t ((pc->flags2 & (QEMU_MEM_DUMP_ELF|QEMU_MEM_DUMP_COMPRESSED)) && !(pc->flags2 & VMCOREINFO))\n\n\n#define NETDUMP_LOCAL (0x1) /* netdump_data flags */\n#define NETDUMP_REMOTE (0x2) \n#define VMCORE_VALID() (nd->flags & (NETDUMP_LOCAL|NETDUMP_REMOTE|KDUMP_LOCAL))\n#define NETDUMP_ELF32 (0x4)\n#define NETDUMP_ELF64 (0x8)\n#define PARTIAL_DUMP (0x10) /* netdump or diskdump */\n#define KDUMP_ELF32 (0x20)\n#define KDUMP_ELF64 (0x40)\n```\n\n#### get_uptime() [lines 4757-4864]\n```c\n#define GNU_ADD_SYMBOL_FILE (11)\n#define GNU_DELETE_SYMBOL_FILE (12)\n#define GNU_VERSION (13)\n#define GNU_PATCH_SYMBOL_VALUES (14)\n#define GNU_GET_SYMBOL_TYPE (15)\n#define GNU_USER_PRINT_OPTION (16)\n#define GNU_SET_CRASH_BLOCK (17)\n#define GNU_GET_FUNCTION_RANGE (18)\n#define GNU_GET_NEXT_DATATYPE (19)\n#define GNU_LOOKUP_STRUCT_CONTENTS (20)\n#define GNU_DEBUG_COMMAND (100)\n/*\n * GNU flags\n */\n#define GNU_PRINT_LINE_NUMBERS (0x1)\n#define GNU_FUNCTION_ONLY (0x2)\n#define GNU_PRINT_ENUMERATORS (0x4)\n#define GNU_RETURN_ON_ERROR (0x8)\n#define GNU_COMMAND_FAILED (0x10)\n#define GNU_FROM_TTY_OFF (0x20)\n#define GNU_NO_READMEM (0x40)\n#define GNU_VAR_LENGTH_TYPECODE (0x80)\n\n#undef TRUE\n#undef FALSE\n\n#define TRUE (1)\n#define FALSE (0)\n\n#ifdef GDB_COMMON\n/*\n * function prototypes required by modified gdb source files.\n */\nint console(char *, ...);\nint gdb_CRASHDEBUG(ulong);\nint gdb_readmem_callback(ulong, void *, int, int);\nvoid patch_load_module(struct objfile *objfile, struct minimal_symbol *msymbol);\nint patch_kernel_symbol(struct gnu_request *);\nstruct syment *symbol_search(char *);\nint gdb_line_number_callback(ulong, ulong, ulong);\nint gdb_print_callback(ulong);\n#endif\n\n#ifndef GDB_COMMON\n/*\n * WARNING: the following type codes are type_code enums from gdb/gdbtypes.h\n */\nenum type_code {\n TYPE_CODE_UNDEF, /* Not used; catches errors */\n TYPE_CODE_PTR, /* Pointer type */\n TYPE_CODE_ARRAY, /* Array type with lower & upper bounds. */\n TYPE_CODE_STRUCT, /* C struct or Pascal record */\n TYPE_CODE_UNION, /* C union or Pascal variant part */\n TYPE_CODE_ENUM, /* Enumeration type */\n#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) || defined(GD\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -685,6 +685,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5835,6 +5836,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -252,6 +252,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4806,7 +4812,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5358,6 +5364,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -685,6 +685,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5835,6 +5836,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -252,6 +252,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4806,7 +4812,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5358,6 +5364,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-5752-crash-sles9-time.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1498, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Files to modify\n- b/CFLAGS.extra\n- b/LDFLAGS.extra\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\nIndex: b/CFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\nIndex: b/LDFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\nIndex: b/CFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\nIndex: b/LDFLAGS.extra\n===================================================================\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-5752-crash_enable_lzo_support.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 2, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- CFLAGS.extra\n- LDFLAGS.extra\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: enably snappy support\nPatch-mainline: never, configurable default\n\nSigned-off-by: Petr Tesarik \n\n---\n CFLAGS.extra | 2 +-\n LDFLAGS.extra | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n--- a/CFLAGS.extra\n+++ b/CFLAGS.extra\n@@ -1 +1 @@\n--DLZO\n+-DLZO -DSNAPPY\n--- a/LDFLAGS.extra\n+++ b/LDFLAGS.extra\n@@ -1 +1 @@\n--llzo2\n+-llzo2 -lsnappy\n"}], "metadata": {"id": "crash-5752-crash_enable_snappy_support.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "crash_enable_snappy_support.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 375, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-8956, CVE-2016-5195, CVE-2016-8658, CVE-2016-7117, CVE-2016-0823, CVE-2016-7425, CVE-2016-6327, CVE-2016-6828, CVE-2016-5696, CVE-2016-6480, CVE-2015-7513, CVE-2016-1237\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- b/extensions/eppic.mk\n- b/extensions/eppic/applications/crash/eppic.c\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\nIndex: b/extensions/eppic.mk\n===================================================================\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\nIndex: b/extensions/eppic/applications/crash/eppic.c\n===================================================================\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\nIndex: b/extensions/eppic.mk\n===================================================================\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\nIndex: b/extensions/eppic/applications/crash/eppic.c\n===================================================================\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-5752-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2015-8956", "cves": ["CVE-2015-7513", "CVE-2015-8956", "CVE-2016-0823", "CVE-2016-1237", "CVE-2016-5195", "CVE-2016-5696", "CVE-2016-6327", "CVE-2016-6480", "CVE-2016-6828", "CVE-2016-7117", "CVE-2016-7425", "CVE-2016-8658"], "package": "crash", "incident_id": 5752, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "c", "patch_files_count": 2, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nfilesys.c | 37 ++++++++++++++++++++++++++++---------\n\n## Package\ncrash\n\n## Files to modify\n- filesys.c\n\n## Target Source Code\n\n### filesys.c\n\n#### region() [lines 481-587]\n```c\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (i != start);\n\t}\n\n\treturn searchdirs;\n}\n\nstatic int\nbuild_kernel_directory(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/lib/modules/\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (*p1 != ' ')\n\t\t*p2++ = *p1++;\n\n\tstrcat(buf, \"/build\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v1(char *buf)\n{\n\tchar *p1, *p2;\n\n\tif (!strstr(kt->proc_version, \"Linux version \"))\n\t\treturn FALSE;\n\n\tBZERO(buf, BUFSIZE);\n\tsprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n\tp1 = &kt->proc_version[strlen(\"Linux version \")];\n\tp2 = &buf[strlen(buf)];\n\n\twhile (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n\t\t*p2++ = *p1++;\t\n\n\tstrcat(buf, \"/linux\");\n\treturn TRUE;\n}\n\nstatic int\nredhat_kernel_directory_v2(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"/usr/src/redhat/BUILD/kernel-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n strcat(buf, \"/linux-\");\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.'))\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n\nstatic int\nredhat_debug_directory(char *buf)\n{\n char *p1, *p2;\n\n if (!strstr(kt->proc_version, \"Linux version \"))\n return FALSE;\n\n BZERO(buf, BUFSIZE);\n sprintf(buf, \"%s/\", pc->redhat_debug_loc);\n\n p1 = &kt->proc_version[strlen(\"Linux version \")];\n p2 = &buf[strlen(buf)];\n\n while (*p1 != ' ')\n *p2++ = *p1++;\n\n return TRUE;\n}\n\n/*\n * If a namelist was not entered, presume we're using the currently-running\n * kernel. Read its version string from /proc/version, and then look in\n * the search directories for a kernel with the same version string embedded\n * in it.\n */\nstatic int\nfind_booted_kernel(void)\n```\n\n#### find_booted_kernel() [lines 116-197]\n```c\n\t\t\t}\n\t\t\tif (!pc->dumpfile)\n\t\t\t\tcheck_live_arch_mismatch();\n\t\t\tif (!find_booted_kernel())\n\t \tprogram_usage(SHORT_FORM);\n\t\t}\n\t\n\t\tif (!pc->dumpfile) {\n\t\t\tpc->flags |= LIVE_SYSTEM;\n\t\t\tget_live_memory_source();\n\t\t}\n\t\n\t\tif ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0) \n\t\t\terror(FATAL, \"%s: %s\\n\", pc->namelist, strerror(errno));\n\t\telse {\n\t\t\tclose(pc->nfd);\n\t\t\tpc->nfd = -1;\n\t\t}\n\n\t\tif (LOCAL_ACTIVE() && !(pc->namelist_debug || pc->system_map)) {\n\t\t\tmemory_source_init();\n\t\t\tmatch_proc_version();\n\t\t}\n\t\n\t}\n\n\tmemory_source_init();\n\n\tif (ACTIVE())\n\t\tproc_kcore_init(fp, UNUSED);\n\n\tif (CRASHDEBUG(1)) {\n\t\tfprintf(fp, \"readmem: %s() \", readmem_function_name());\n\t\tif (ACTIVE()) {\n\t\t\tfprintf(fp, \"-> %s \", pc->live_memsrc);\n\t\t\tif (pc->flags & MEMMOD)\n\t\t\t\tfprintf(fp, \"(module)\");\n\t\t\telse if (pc->flags & CRASHBUILTIN)\n\t\t\t\tfprintf(fp, \"(built-in)\");\n\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n}\n\n/*\n * Do whatever's necessary to handle the memory source.\n */\nstatic void\nmemory_source_init(void)\n{\n\tif (REMOTE() && !(pc->flags2 & MEMSRC_LOCAL))\n\t\treturn;\n\n\tif (pc->flags & KERNEL_DEBUG_QUERY)\n\t\treturn;\n\n if (LOCAL_ACTIVE()) {\n\t\tif (pc->mfd != -1) /* already been here */\n\t\t\treturn;\n\n\t\tif (!STREQ(pc->live_memsrc, \"/dev/mem\") &&\n\t\t STREQ(pc->live_memsrc, pc->memory_device)) {\n\t\t\tif (memory_driver_init())\n\t\t\t\treturn;\n\n\t\t\terror(INFO, \"cannot initialize crash memory driver\\n\");\n\t\t\terror(INFO, \"using /dev/mem\\n\\n\");\n\t\t\tpc->flags &= ~MEMMOD;\n\t\t\tpc->flags |= DEVMEM;\n\t\t\tpc->readmem = read_dev_mem;\n\t\t\tpc->writemem = write_dev_mem;\n\t\t\tpc->live_memsrc = \"/dev/mem\";\n\t\t} \n\n\t\tif (STREQ(pc->live_memsrc, \"/dev/mem\")) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDWR)) < 0) {\n\t if ((pc->mfd = open(\"/dev/mem\", O_RDONLY)) < 0)\n\t error(FATAL, \"/dev/mem: %s\\n\",\n\t strerror(errno));\n\t } else\n\t pc->flags |= MFD_RDWR;\n\t\t} else if (STREQ(pc->live_memsrc, \"/proc/kcore\")) {\n```\n\n\n## Upstream Fix\n```diff\n---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n filesys.c | 37 ++++++++++++++++++++++++++++---------\n 1 file changed, 28 insertions(+), 9 deletions(-)\n\n--- a/filesys.c\n+++ b/filesys.c\n@@ -530,6 +530,8 @@ static int\n find_booted_kernel(void)\n {\n \tchar kernel[BUFSIZE];\n+\tchar *kernel_unpacked;\n+\tchar *real_kernel;\n \tchar buffer[BUFSIZE];\n \tchar **searchdirs;\n \tint i, preferred, wrapped;\n@@ -579,16 +581,25 @@ find_booted_kernel(void)\n \t\t\tsprintf(kernel, \"%s%s\", searchdirs[i], dp->d_name);\n \n \t\t\tif (mount_point(kernel) ||\n-\t\t\t !file_readable(kernel) || \n- !is_elf_file(kernel))\n+\t\t\t !file_readable(kernel))\n \t\t\t\tcontinue;\n \n+\t\t\tif (is_compressed_kernel(kernel, &kernel_unpacked))\n+\t\t\t\treal_kernel = kernel_unpacked;\n+\t\t\telse {\n+\t\t\t\tkernel_unpacked = NULL;\n+\t\t\t\treal_kernel = kernel;\n+\t\t\t}\n+\n \t\t\tif (CRASHDEBUG(1)) \n \t\t\t\tfprintf(fp, \"find_booted_kernel: check: %s\\n\", \n \t\t\t\t\tkernel);\n \n-\t\t\tfound = match_file_string(kernel, kt->proc_version, buffer);\n-\t\n+\t\t\tif (!is_elf_file(real_kernel))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfound = match_file_string(real_kernel, kt->proc_version, buffer);\n+\n \t\t\tif (found)\n \t\t\t\tbreak;\n \t }\n@@ -599,17 +610,25 @@ find_booted_kernel(void)\n \tbuild_searchdirs(DESTROY, NULL);\n \n \tif (found) {\n- if ((pc->namelist = (char *)malloc\n-\t\t (strlen(kernel)+1)) == NULL) \n+\t\tif ((pc->namelist_orig = strdup(kernel)) == NULL)\n+\t\t\terror(FATAL, \"booted kernel real name malloc: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\telse if ((pc->namelist = strdup(real_kernel)) == NULL)\n \t\t\terror(FATAL, \"booted kernel name malloc: %s\\n\",\n \t\t\t\tstrerror(errno));\n- else {\n- strcpy(pc->namelist, kernel);\n+ else\n \t\t\tif (CRASHDEBUG(1))\n \t\t\t\tfprintf(fp, \"find_booted_kernel: found: %s\\n\", \n \t\t\t\t\tpc->namelist);\n+\t\t\tif (kernel_unpacked)\n+\t\t\t\tfree(kernel_unpacked);\n return TRUE;\n- }\n+\t}\n+\n+\tif (kernel_unpacked) {\n+\t\tremove(kernel_unpacked);\n+\t\tif (kernel_unpacked)\n+\t\t\tfree(kernel_unpacked);\n \t}\n \n \terror(INFO, \n"}], "metadata": {"id": "crash-5739-crash-compressed-booted-kernel.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-compressed-booted-kernel.patch", "tier": "identical", "language": "c", "patch_lines_changed": 37, "patch_files_count": 0, "total_tokens_est": 1130, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- symbols.c\n\n## Target Source Code\n\n### symbols.c\n\n#### symtab_init() [lines 161-255]\n```c\n * sorts, and stores, them in a static table for quick reference.\n */\nvoid\nsymtab_init(void)\n{\n\tchar **matching;\n \tlong symcount;\n \tvoid *minisyms;\n \tunsigned int size;\n\tasymbol *sort_x;\n\tasymbol *sort_y;\n\n \tif ((st->bfd = bfd_openr(pc->namelist, NULL)) == NULL) \n\t\terror(FATAL, \"cannot open object file: %s\\n\", pc->namelist);\n\n \tif (!bfd_check_format_matches(st->bfd, bfd_object, &matching))\n\t\terror(FATAL, \"cannot determine object file format: %s\\n\",\n\t\t\tpc->namelist);\n\t/*\n\t * Check whether the namelist is a kerntypes file built by\n\t * dwarfextract, which places a magic number in e_version.\n\t */\n\tif (file_elf_version(pc->namelist) == EV_DWARFEXTRACT)\n\t\tpc->flags |= KERNTYPES;\n\n\tif (pc->flags & SYSMAP) {\n\t\tbfd_map_over_sections(st->bfd, section_header_info, \n\t\t\tVERIFY_SECTIONS);\n\t\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, pc->flags & SYSMAP_ARG ? \n\t\t\t\tDEBUGINFO_ERROR_MESSAGE1 :\n\t\t\t\tDEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t\tstore_sysmap_symbols();\n\t\treturn;\n\t} else if (LKCD_KERNTYPES())\n\t\terror(FATAL, \"%s: use of kerntypes requires a system map\\n\",\n\t\t\tpc->namelist);\n\n\t/*\n\t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n\tsymcount = bfd_read_minisymbols(st->bfd, FALSE, &minisyms, &size);\n\n\tif (symcount <= 0)\n\t\tno_debugging_data(FATAL);\n\n\tsort_x = bfd_make_empty_symbol(st->bfd);\n\tsort_y = bfd_make_empty_symbol(st->bfd);\n\tif (sort_x == NULL || sort_y == NULL)\n\t\terror(FATAL, \"bfd_make_empty_symbol() failed\\n\");\n\n\tkaslr_init();\n\n\tgnu_qsort(st->bfd, minisyms, symcount, size, sort_x, sort_y);\n\n\tstore_symbols(st->bfd, FALSE, minisyms, symcount, size);\n\n\tfree(minisyms);\n\n\tsymname_hash_init();\n\tsymval_hash_init();\n} \n\n/*\n```\n\n#### check_gnu_debuglink() [lines 206-232]\n```c\n\t */\n\tif (!(LKCD_KERNTYPES()) &&\n\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n\t\tif (!check_gnu_debuglink(st->bfd))\n\t\t\tno_debugging_data(FATAL);\n\t}\n\t\n\t/*\n\t * Gather references to the kernel sections.\n\t */\n if ((st->sections = (struct sec *)\n malloc(st->bfd->section_count * sizeof(struct sec *))) == NULL)\n error(FATAL, \"symbol table section array malloc: %s\\n\",\n strerror(errno));\n\tBZERO(st->sections, st->bfd->section_count * sizeof(struct sec *));\n\tst->first_section_start = st->last_section_end = 0;\n\n\tbfd_map_over_sections(st->bfd, section_header_info, KERNEL_SECTIONS);\n\tif ((st->flags & (NO_SEC_LOAD|NO_SEC_CONTENTS)) ==\n\t (NO_SEC_LOAD|NO_SEC_CONTENTS)) {\n\t\tif (!pc->namelist_debug && !pc->debuginfo_file) {\n\t\t\terror(INFO, \"%s: no text and data contents\\n\",\n\t\t\t\tpc->namelist);\n\t\t\terror(FATAL, DEBUGINFO_ERROR_MESSAGE2);\n\t\t}\n\t}\n\n```\n\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Search debuginfo files in the original directory\nReferences: bnc#723639\n\nIf debuginfo is in a separate file and the kernel image is compressed,\nthen it should be found in the same directory as the original (compressed)\nimage, not in the directory with the uncompressed image (TMPDIR).\n\nSigned-off-by: Petr Tesarik \n\n---\n symbols.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n--- a/symbols.c\n+++ b/symbols.c\n@@ -183,9 +183,9 @@ symtab_init(void)\n \t * Pull a bait-and-switch on st->bfd if we've got a separate\n * .gnu_debuglink file that matches the CRC. Not done for kerntypes.\n \t */\n-\tif (!(LKCD_KERNTYPES()) &&\n-\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS)) {\n-\t\tif (!check_gnu_debuglink(st->bfd))\n+\tif (!(LKCD_KERNTYPES())) {\n+\t\tif (!check_gnu_debuglink(st->bfd) &&\n+\t\t !(bfd_get_file_flags(st->bfd) & HAS_SYMS))\n \t\t\tno_debugging_data(FATAL);\n \t}\n \t\n@@ -244,13 +244,16 @@ check_gnu_debuglink(bfd *bfd)\n \tchar *contents;\n \tint crc_offset;\t\n \tunsigned long crc32;\n+\tchar *namelist;\n \tchar *dirname;\n \tchar *namelist_debug;\n char **matching;\n \n+\tnamelist = pc->namelist_orig ? pc->namelist_orig : pc->namelist;\n+\n sect = bfd_get_section_by_name(bfd, \".gnu_debuglink\");\n \tif (!sect) {\n-\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", pc->namelist);\n+\t\terror(INFO, \"%s: no .gnu_debuglink section\\n\", namelist);\n \t\treturn FALSE;\n \t}\n \n@@ -271,14 +274,14 @@ check_gnu_debuglink(bfd *bfd)\n \t\t\tcontents, crc32);\n \n \tif ((pc->debuginfo_file = (char *)\n-\t malloc(((strlen(pc->namelist) + strlen(\"/.debug/\") +\n+\t malloc(((strlen(namelist) + strlen(\"/.debug/\") +\n \t + strlen(\".debug\") + strlen(\" /usr/lib/debug/boot/ \"))*10)\n \t + strlen(pc->namelist_debug ? pc->namelist_debug : \" \"))) == NULL)\n \t\terror(FATAL, \"debuginfo file name malloc: %s\\n\", \n \t\t\tstrerror(errno));\n \n-\tdirname = GETBUF(strlen(pc->namelist)+1);\n-\tstrcpy(dirname, pc->namelist);\n+\tdirname = GETBUF(strlen(namelist)+1);\n+\tstrcpy(dirname, namelist);\n \n \tfor (i = strlen(dirname)-1; i >= 0; i--)\n \t{\n"}], "metadata": {"id": "crash-5739-crash-debuginfo-compressed.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-debuginfo-compressed.patch", "tier": "identical", "language": "c", "patch_lines_changed": 17, "patch_files_count": 0, "total_tokens_est": 1177, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nmain.c | 8 +-------\n\n## Package\ncrash\n\n## Files to modify\n- main.c\n\n## Target Source Code\n\n### main.c\n\n#### setup_environment() [lines 1080-1245]\n```c\n\n\nstatic void\nsetup_environment(int argc, char **argv)\n{\n\tint i;\n\tchar *p1;\n\tchar buf[BUFSIZE];\n\tchar homerc[BUFSIZE];\n\tchar localrc[BUFSIZE];\n\tFILE *afp;\n\tchar *program;\n\n\tprogram = argv[0];\n\n\t/*\n\t * Program output typically goes via \"fprintf(fp, ...)\", but the \n\t * contents of fp are modified on the fly to handle redirection\n\t * to pipes or output files.\n\t */\n\tfp = stdout;\n\n\tif (!set_error(\"default\")) {\n\t\tfprintf(stderr, \"crash: cannot malloc error() path string\\n\");\n\t\tclean_exit(1);\n\t}\n\n\t/*\n\t * Start populating the program_context structure. It's used so\n\t * frequently that \"pc\" has been declared globally to point to the\n\t * \"program_context\" structure.\n\t */\n pc->program_name = (char *)basename(program);\n\tpc->program_path = program;\n pc->program_version = build_version;\n\tpc->program_pid = (ulong)getpid();\n pc->curcmd = pc->program_name;\n pc->flags = (HASH|SCROLL);\n\tpc->flags |= DATADEBUG; /* default until unnecessary */\n\tpc->flags2 |= REDZONE;\n/* ... 114 lines omitted ... */\n\t !(pc->flags & NOCRASHRC) && file_exists(localrc, NULL)) {\n\t\tif ((afp = fopen(localrc, \"r\")) == NULL)\n error(INFO, \"cannot open %s: %s\\n\",\n\t\t\t\tlocalrc, strerror(errno));\n\t\telse if (untrusted_file(afp, localrc))\n\t\t\tfclose(afp);\n\t\telse {\n\t\t\twhile (fgets(buf, BUFSIZE, afp)) \n\t\t\t\tresolve_rc_cmd(buf, ALIAS_RCLOCAL);\n\t\t\tfclose(afp);\n\t\t}\n\t}\n\n\tif (STREQ(pc->editing_mode, \"no_mode\"))\n\t\tpc->editing_mode = \"vi\";\n\n\tmachdep_init(SETUP_ENV);\n}\n\n\n```\n\n\n## Upstream Fix\n```diff\n---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n main.c | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\n--- a/main.c\n+++ b/main.c\n@@ -1048,12 +1048,6 @@ setup_environment(int argc, char **argv)\n \tpc->flags |= READLINE;\n \tpc->editing_mode = \"no_mode\";\n \n-\tif ((p1 = getenv(\"EDITOR\"))) {\n-\t\tif (strstr(p1, \"vi\"))\n-\t\t\tpc->editing_mode = \"vi\";\n-\t\tif (strstr(p1, \"emacs\"))\n-\t\t\tpc->editing_mode = \"emacs\";\n-\t}\n \n \t/*\n \t * Resolve $HOME .rc file first, then the one in the local directory.\n@@ -1103,7 +1097,7 @@ setup_environment(int argc, char **argv)\n \t}\n \n \tif (STREQ(pc->editing_mode, \"no_mode\"))\n-\t\tpc->editing_mode = \"vi\";\n+\t\tpc->editing_mode = \"emacs\";\n \n \tmachdep_init(SETUP_ENV);\n }\n"}], "metadata": {"id": "crash-5739-crash-make-emacs-default.diff", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-make-emacs-default.diff", "tier": "identical", "language": "c", "patch_lines_changed": 8, "patch_files_count": 0, "total_tokens_est": 449, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nFrom: Petr Tesarik \n\n## Package\ncrash\n\n## Files to modify\n- gdb-7.6.patch\n\n## Upstream Fix\n```diff\nFrom: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Petr Tesarik \nSubject: Add missing includes\n\nThis fixes a compilation failure on ppc64.\n\n---\n gdb-7.6.patch | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--- a/gdb-7.6.patch\n+++ b/gdb-7.6.patch\n@@ -17,6 +17,16 @@\n \t./pex-djgpp.$(objext) ./pex-msdos.$(objext)\t\t\t\\\n \t ./pex-unix.$(objext) ./pex-win32.$(objext)\t\t\t\\\n \t ./putenv.$(objext)\t\t\t\t\t\t\\\n+--- gdb-7.6/sim/common/gentmap.c.orig\n++++ gdb-7.6/sim/common/gentmap.c\n+@@ -2,6 +2,7 @@\n+ \n+ #include \n+ #include \n++#include \n+ \n+ struct tdefs {\n+ char *symbol;\n --- gdb-7.6/opcodes/i386-dis.c.orig\n +++ gdb-7.6/opcodes/i386-dis.c\n @@ -11510,6 +11510,10 @@ print_insn (bfd_vma pc, disassemble_info\n"}], "metadata": {"id": "crash-5739-crash-missing-declarations.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-missing-declarations.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 9, "patch_files_count": 0, "total_tokens_est": 479, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\ndiff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "diff -Nurp sial-scripts-2008-02-08.orig//ps.c sial-scripts-2008-02-08/ps.c\n--- sial-scripts-2008-02-08.orig//ps.c\t2010-03-12 19:59:03.227788951 +0100\n+++ sial-scripts-2008-02-08/ps.c\t2010-03-12 19:59:16.690665574 +0100\n@@ -192,7 +192,11 @@ string cmd;\n \n \tprintf(\"%p %7d %7d %7d 0x%02x 0x%08x %5d:%-5d %s\\n\"\n \t\t, t\n+#if LINUX_RELEASE > 0x02061d\n+\t\t, t->real_cred->uid\n+#else\n \t\t, t->uid\n+#endif\n \t\t, t->pid\n #if LINUX_2_6_X\n \t\t, t->parent->pid\n"}], "metadata": {"id": "crash-5739-crash-sial-ps-2.6.29.diff", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-sial-ps-2.6.29.diff", "tier": "identical", "language": "c", "patch_lines_changed": 4, "patch_files_count": 0, "total_tokens_est": 341, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nAdd quirk for SLES9 LKCD header\n\n## Package\ncrash\n\n## Files to modify\n- lkcd_v8.c\n\n## Target Source Code\n\n### lkcd_v8.c\n\n#### lkcd_dump_init_v8_arch() [lines 90-195]\n```c\n\n#ifndef HAVE_NO_DUMP_HEADER_ASM\nint\nlkcd_dump_init_v8_arch(dump_header_t *dh)\n{\n\toff_t \t\t\tret_of;\n\tssize_t \t\tret_sz;\n\tuint32_t \t\thdr_size, offset, nr_cpus;\n\tdump_header_asm_t \tarch_hdr;\n\tchar \t\t\t*hdr_buf = NULL;\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size +\n\t\t\toffsetof(dump_header_asm_t, dha_header_size),\n\t\t\tSEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)&hdr_size, sizeof(hdr_size));\n\tif (ret_sz != sizeof(hdr_size)) {\n\t\tperror(\"Reading hdr_size failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\tret_of = lseek(lkcd->fd, dh->dh_header_size, SEEK_SET);\n\tif (ret_of < 0) {\n\t\tperror(\"lseek failed in \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\thdr_buf = (char *)malloc(hdr_size);\n\tif (!hdr_buf) {\n\t\tperror(\"Could not allocate memory for dump header\\n\");\n\t\tgoto err;\n\t}\n\n\tret_sz = read(lkcd->fd, (char *)hdr_buf, hdr_size);\n\tif (ret_sz != hdr_size) {\n\t\tperror(\"Could not read header \" __FILE__ \":\" STR(__LINE__));\n\t\tgoto err;\n\t}\n\n\n\t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n * CONFIG_NR_CPUS might be different in the kernel. Hence, need\n * to find out how many CPUs are configured.\n */\n offset = offsetof(dump_header_asm_t, dha_smp_regs[0]);\n nr_cpus = (hdr_size - offset) / sizeof(dump_CPU_info_t);\n\n\t/* check for CPU overflow */\n\tif (nr_cpus > NR_CPUS) {\n\t\tfprintf(stderr, \"CPU number too high %d (%s:%d)\\n\",\n\t\t\t\tnr_cpus, __FILE__, __LINE__);\n\t\tgoto err;\n\t}\n\n\t/* parts that don't depend on the number of CPUs */\n\tmemcpy(&arch_hdr, (void *)hdr_buf, offset);\n\n\t/* registers */\n\tmemcpy(&arch_hdr.dha_smp_regs, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(struct pt_regs));\n\toffset += nr_cpus * sizeof(struct pt_regs);\n\n\t/* current task */\n\tmemcpy(&arch_hdr.dha_smp_current_task, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_smp_current_task[0]);\n\n\t/* stack */\n\tmemcpy(&arch_hdr.dha_stack, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack[0]);\n\n\t/* stack_ptr */\n\tmemcpy(&arch_hdr.dha_stack_ptr, (void *)&hdr_buf[offset],\n\t\t\tnr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]));\n\toffset += nr_cpus * sizeof(&arch_hdr.dha_stack_ptr[0]);\n\n\tif (arch_hdr.dha_magic_number != DUMP_ASM_MAGIC_NUMBER) {\n\t\tfprintf(stderr, \"Invalid magic number for x86_64\\n\");\n\t\tgoto err;\n\t}\n\n\t/*\n\t * read the kernel load address on IA64 -- other architectures have\n\t * no relocatable kernel at the lifetime of LKCD\n\t */\n#ifdef IA64\n\tmemcpy(&arch_hdr.dha_kernel_addr, (void *)&hdr_buf[offset], sizeof(uint64_t));\n#endif\n\n\tmemcpy(&dump_header_asm_v8, &arch_hdr, sizeof(dump_header_asm_t));\n\n\tfree(hdr_buf);\n\treturn 0;\n\nerr:\n\tfree(hdr_buf);\n\treturn -1;\n}\n\n#else /* architecture that has no lkcd_dump_init_v8 */\n```\n\n\n### Type definitions\n\n```c\n/* from lkcd_dump_v8.h */\nstruct pt_regs {\n\tlong ebx;\n\tlong ecx;\n\tlong edx;\n\tlong esi;\n\tlong edi;\n\tlong ebp;\n\tlong eax;\n\tint xds;\n\tint xes;\n\tlong orig_eax;\n\tlong eip;\n\tint xcs;\n\tlong eflags;\n\tlong esp;\n\tint xss;\n};\n```\n\n\n## Upstream Fix\n```diff\nFrom: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Bernhard Walle \nSubject: [PATCH] Add quirk for SLES9 LKCD header\nPatch-mainline: never\n\nOn SLES9, we have a different header on IA64:\n\n SLES 10:\n\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n uint64_t dha_kernel_addr;\n } __attribute__((packed)) dump_header_asm_t;\n\n SLES 9:\n typedef struct __dump_header_asm {\n uint64_t dha_magic_number;\n uint32_t dha_version;\n uint32_t dha_header_size;\n uint64_t dha_kernel_addr;\n uint64_t dha_pt_regs;\n struct pt_regs dha_regs;\n uint64_t dha_rnat;\n uint64_t dha_pfs;\n uint64_t dha_bspstore;\n uint32_t\t dha_smp_num_cpus;\n uint32_t\t dha_dumping_cpu;\t\n struct pt_regs\tdha_smp_regs[NR_CPUS];\n uint64_t\t dha_smp_current_task[NR_CPUS];\n uint64_t\t dha_stack[NR_CPUS];\n uint64_t\t dha_stack_ptr[NR_CPUS];\n } __attribute__((packed)) dump_header_asm_t;\n\nThat patch tries to guess if it's a SLES 9 or a SLES 10 header\nat runtime.\n\n\nSigned-off-by: Bernhard Walle \n\n---\n lkcd_v8.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\n--- a/lkcd_v8.c\n+++ b/lkcd_v8.c\n@@ -130,6 +130,17 @@ lkcd_dump_init_v8_arch(dump_header_t *dh\n \t\tgoto err;\n \t}\n \n+#if IA64\n+\t/* SLES9 on IA64? */\n+\tif ( *((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) <= NR_CPUS) {\n+\t\tuint64_t kernel_addr;\n+\t\tkernel_addr = ((dump_header_asm_t *)hdr_buf)->dha_pt_regs;\n+\t\tmemmove(hdr_buf + offsetof(dump_header_asm_t, dha_pt_regs),\n+\t\t\t\thdr_buf + offsetof(dump_header_asm_t, dha_regs),\n+\t\t\t\thdr_size - offsetof(dump_header_asm_t, dha_regs));\n+\t\t*((uint64_t *)(hdr_buf + hdr_size - sizeof(uint64_t))) = kernel_addr;\n+\t}\n+#endif\n \n \t/*\n * Though we have KL_NR_CPUS is 128, the header size is different\n"}], "metadata": {"id": "crash-5739-crash-sles9-quirk.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-sles9-quirk.patch", "tier": "identical", "language": "c", "patch_lines_changed": 11, "patch_files_count": 0, "total_tokens_est": 1439, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nFix \"uptime\" and \"ps -t\" for SLES9\n\n## Package\ncrash\n\n## Files to modify\n- defs.h\n- kernel.c\n- task.c\n\n## Target Source Code\n\n### defs.h\n\n#### region() [lines 633-739]\n```c\n#define KMOD_V2 (0x2000)\n#define KALLSYMS_V2 (0x2000)\n#define TVEC_BASES_V2 (0x4000)\n#define GCC_3_3_3 (0x8000)\n#define USE_OLD_BT (0x10000)\n#define USE_OPT_BT (0x10000)\n#define ARCH_XEN (0x20000)\n#define NO_IKCONFIG (0x40000)\n#define DWARF_UNWIND (0x80000)\n#define NO_DWARF_UNWIND (0x100000)\n#define DWARF_UNWIND_MEMORY (0x200000)\n#define DWARF_UNWIND_EH_FRAME (0x400000)\n#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)\n#define DWARF_UNWIND_MODULES (0x800000)\n#define BUGVERBOSE_OFF (0x1000000)\n#define RELOC_SET (0x2000000)\n#define RELOC_FORCE (0x4000000)\n#define ARCH_OPENVZ (0x8000000)\n#define ARCH_PVOPS (0x10000000)\n#define PRE_KERNEL_INIT (0x20000000)\n#define ARCH_PVOPS_XEN (0x40000000)\n\n#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)\n\n/* flags2 */\n#define RELOC_AUTO (0x1ULL)\n#define KASLR (0x2ULL)\n#define KASLR_CHECK (0x4ULL)\n#define GET_TIMESTAMP (0x8ULL)\n#define TVEC_BASES_V3 (0x10ULL)\n#define TIMER_BASES (0x20ULL)\n#define IRQ_DESC_TREE_RADIX (0x40ULL)\n#define IRQ_DESC_TREE_XARRAY (0x80ULL)\n#define KMOD_PAX (0x100ULL)\n\n#define XEN() (kt->flags & ARCH_XEN)\n#define OPENVZ() (kt->flags & ARCH_OPENVZ)\n#define PVOPS() (kt->flags & ARCH_PVOPS)\n#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)\n\n#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)\n\n#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())\n#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())\n\n#define XEN_MFN_NOT_FOUND (~0UL)\n#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))\n#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))\n\n#define XEN_MACHADDR_NOT_FOUND (~0ULL) \n\n#define XEN_P2M_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long))\n#define XEN_P2M_MID_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long *))\n#define XEN_P2M_TOP_PER_PAGE\t(PAGESIZE() / sizeof(unsigned long **))\n\nstruct kernel_table { /* kernel data */\n\tulong flags;\n\tulong stext;\n\tulong etext;\n\tulong stext_init;\n\tulong etext_init;\n\tulong init_begin;\n\tulong init_end;\n\tulong end;\n\tint cpus;\n\tchar *cpus_override;\n\tvoid (*display_bh)(void);\n ulong module_list;\n ulong kernel_module;\n\tint mods_installed;\n\tstruct timespec date;\n\tchar proc_version[BUFSIZE];\n\tstruct new_utsname utsname;\n\tuint kernel_version[3];\n\tuint gcc_version[3];\n\tint runq_siblings;\n\tint kernel_NR_CPUS;\n\tlong __per_cpu_offset[NR_CPUS];\n\tlong *__rq_idx;\n\tlong *__cpu_idx;\n\tulong *cpu_flags;\n#define POSSIBLE (0x1)\n#define PRESENT (0x2)\n#define ONLINE (0x4)\n#define NMI (0x8)\n#define POSSIBLE_MAP (POSSIBLE)\n#define PRESENT_MAP (PRESENT)\n#define ONLINE_MAP (ONLINE)\n#define ACTIVE_MAP (0x10)\n\tint BUG_bytes;\n\tulong xen_flags;\n#define WRITABLE_PAGE_TABLES (0x1)\n#define SHADOW_PAGE_TABLES (0x2)\n#define CANONICAL_PAGE_TABLES (0x4)\n#define XEN_SUSPEND (0x8)\n\tchar *m2p_page;\n\tulong phys_to_machine_mapping;\n\tulong p2m_table_size;\n#define P2M_MAPPING_CACHE (512)\n\tstruct p2m_mapping_cache {\n\t\tulong mapping;\n\t\tulong pfn;\n\t\tulong start;\n\t\tulong end;\n\t} p2m_mapping_cache[P2M_MAPPING_CACHE];\n#define P2M_MAPPING_PAGE_PFN(c) \\\n (PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \\\n```\n\n#### region() [lines 5487-5593]\n```c\n */\n#define HELP_COLUMNS 5\n#define START_OF_HELP_DATA(X) \"START_OF_HELP_DATA\" X\n#define END_OF_HELP_DATA \"END_OF_HELP_DATA\"\nvoid help_init(void);\nvoid cmd_usage(char *, int);\nvoid display_version(void);\nvoid display_help_screen(char *);\n#ifdef ARM\n#define dump_machdep_table(X) arm_dump_machdep_table(X)\n#endif\n#ifdef ARM64\n#define dump_machdep_table(X) arm64_dump_machdep_table(X)\n#endif\n#ifdef X86\n#define dump_machdep_table(X) x86_dump_machdep_table(X)\n#endif\n#ifdef ALPHA\n#define dump_machdep_table(X) alpha_dump_machdep_table(X)\n#endif\n#ifdef PPC\n#define dump_machdep_table(X) ppc_dump_machdep_table(X)\n#endif\n#ifdef IA64\n#define dump_machdep_table(X) ia64_dump_machdep_table(X)\n#endif\n#ifdef S390\n#define dump_machdep_table(X) s390_dump_machdep_table(X)\n#endif\n#ifdef S390X\n#define dump_machdep_table(X) s390x_dump_machdep_table(X)\n#endif\n#ifdef X86_64\n#define dump_machdep_table(X) x86_64_dump_machdep_table(X)\n#endif\n#ifdef PPC64\n#define dump_machdep_table(X) ppc64_dump_machdep_table(X)\n#endif\n#ifdef MIPS\n#define dump_machdep_table(X) mips_dump_machdep_table(X)\n#endif\n#ifdef MIPS64\n#define dump_machdep_table(X) mips64_dump_machdep_table(X)\n#endif\n#ifdef SPARC64\n#define dump_machdep_table(X) sparc64_dump_machdep_table(X)\n#endif\nextern char *help_pointer[];\nextern char *help_alias[];\nextern char *help_ascii[];\nextern char *help_bpf[];\nextern char *help_bt[];\nextern char *help_btop[];\nextern char *help_dev[];\nextern char *help_dis[];\nextern char *help_eval[];\nextern char *help_exit[];\nextern char *help_extend[];\nextern char *help_files[];\nextern char *help_foreach[];\nextern char *help_fuser[];\nextern char *help_gdb[];\nextern char *help_help[];\nextern char *help_irq[];\nextern char *help_kmem[];\nextern char *help__list[];\nextern char *help_tree[];\nextern char *help_log[];\nextern char *help_mach[];\nextern char *help_mod[];\nextern char *help_mount[];\nextern char *help_net[];\nextern char *help_p[];\nextern char *help_ps[];\nextern char *help_pte[];\nextern char *help_ptob[];\nextern char *help_ptov[];\nextern char *help_quit[];\nextern char *help_rd[];\nextern char *help_repeat[];\nextern char *help_runq[];\nextern char *help_ipcs[];\nextern char *help_search[];\nextern char *help_set[];\nextern char *help_sig[];\nextern char *help_struct[];\nextern char *help_swap[];\nextern char *help_sym[];\nextern char *help_sys[];\nextern char *help_task[];\nextern char *help_timer[];\nextern char *help_union[];\nextern char *help_vm[];\nextern char *help_vtop[];\nextern char *help_waitq[];\nextern char *help_whatis[];\nextern char *help_wr[];\n#if defined(S390) || defined(S390X)\nextern char *help_s390dbf[];\n#endif\nextern char *help_map[];\n\n/*\n * task.c\n */ \nvoid task_init(void);\nint set_context(ulong, ulong);\n```\n\n#### kernel_init() [lines 188-294]\n```c\n\n#ifdef roundup\n#undef roundup\n#endif\n#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))\n\ntypedef uint64_t physaddr_t;\n\n#define PADDR_NOT_AVAILABLE (0x1ULL)\n#define KCORE_USE_VADDR (-1ULL)\n\ntypedef unsigned long long int ulonglong;\nstruct number_option {\n ulong num;\n ulonglong ll_num;\n\tulong retflags;\n};\n\n/*\n * program_context flags\n */\n#define LIVE_SYSTEM (0x1ULL)\n#define TTY (0x2ULL)\n#define RUNTIME (0x4ULL)\n#define IN_FOREACH (0x8ULL)\n#define MCLXCD (0x10ULL)\n#define CMDLINE_IFILE (0x20ULL)\n#define MFD_RDWR (0x40ULL)\n#define KVMDUMP (0x80ULL)\n#define SILENT (0x100ULL)\n#define SADUMP (0x200ULL)\n#define HASH (0x400ULL)\n#define SCROLL (0x800ULL)\n#define NO_CONSOLE (0x1000ULL)\n#define RUNTIME_IFILE (0x2000ULL)\n#define DROP_CORE (0x4000ULL)\n#define LKCD (0x8000ULL)\n#define GDB_INIT (0x10000ULL)\n#define IN_GDB (0x20000ULL)\n#define RCLOCAL_IFILE (0x40000ULL)\n#define RCHOME_IFILE (0x80000ULL)\n#define VMWARE_VMSS (0x100000ULL)\n#define READLINE (0x200000ULL) \n#define _SIGINT_ (0x400000ULL)\n#define IN_RESTART (0x800000ULL)\n#define KERNEL_DEBUG_QUERY (0x1000000ULL)\n#define DEVMEM (0x2000000ULL)\n#define REM_LIVE_SYSTEM (0x4000000ULL)\n#define NAMELIST_LOCAL (0x8000000ULL)\n#define LIVE_RAMDUMP (0x10000000ULL)\n#define NAMELIST_SAVED (0x20000000ULL)\n#define DUMPFILE_SAVED (0x40000000ULL)\n#define UNLINK_NAMELIST (0x80000000ULL) \n#define NAMELIST_UNLINKED (0x100000000ULL)\n#define REM_MCLXCD (0x200000000ULL)\n#define REM_LKCD (0x400000000ULL)\n#define NAMELIST_NO_GZIP (0x800000000ULL)\n#define UNLINK_MODULES (0x1000000000ULL)\n#define S390D (0x2000000000ULL)\n#define REM_S390D (0x4000000000ULL)\n#define SYSRQ (0x8000000000ULL)\n#define KDUMP (0x10000000000ULL)\n#define NETDUMP (0x20000000000ULL)\n#define REM_NETDUMP (0x40000000000ULL)\n#define SYSMAP (0x80000000000ULL)\n#define SYSMAP_ARG (0x100000000000ULL)\n#define MEMMOD (0x200000000000ULL)\n#define MODPRELOAD (0x400000000000ULL)\n#define DISKDUMP (0x800000000000ULL)\n#define DATADEBUG (0x1000000000000ULL)\n#define FINDKERNEL (0x2000000000000ULL)\n#define VERSION_QUERY (0x4000000000000ULL)\n#define READNOW (0x8000000000000ULL)\n#define NOCRASHRC (0x10000000000000ULL)\n#define INIT_IFILE (0x20000000000000ULL)\n#define XENDUMP (0x40000000000000ULL)\n#define XEN_HYPER (0x80000000000000ULL)\n#define XEN_CORE (0x100000000000000ULL)\n#define PLEASE_WAIT (0x200000000000000ULL)\n#define IFILE_ERROR (0x400000000000000ULL)\n#define KERNTYPES (0x800000000000000ULL)\n#define MINIMAL_MODE (0x1000000000000000ULL)\n#define CRASHBUILTIN (0x2000000000000000ULL)\n#define PRELOAD_EXTENSIONS \\\n\t\t (0x4000000000000000ULL)\n#define PROC_KCORE (0x8000000000000000ULL)\n\n#define ACTIVE() (pc->flags & LIVE_SYSTEM)\n#define LOCAL_ACTIVE() ((pc->flags & (LIVE_SYSTEM|LIVE_RAMDUMP)) == LIVE_SYSTEM)\n#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))\n#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)\n#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP|VMWARE_VMSS|LIVE_RAMDUMP)\n#define REMOTE() (pc->flags2 & REMOTE_DAEMON)\n#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM) \n#define REMOTE_DUMPFILE() \\\n\t (pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))\n#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())\n#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))\n#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))\n#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)\n#define KDUMP_DUMPFILE() (pc->flags & KDUMP)\n#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)\n#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)\n#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))\n#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)\n#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)\n```\n\n#### get_uptime() [lines 4509-4616]\n```c\n#define LONG_DEC (0x8)\n#define LONG_HEX (0x10)\n#define INT_DEC (0x20)\n#define INT_HEX (0x40)\n#define LONGLONG_HEX (0x80)\n#define ZERO_FILL (0x100)\n#define SLONG_DEC (0x200)\n\n#define INIT_TIME (1)\n#define RUN_TIME (2)\n\n/*\n * IRQ line status.\n * For kernels up to and including 2.6.17\n */\n#define IRQ_INPROGRESS_2_6_17 1 /* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_17 2 /* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_17 4 /* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_17 8 /* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_17 16 /* IRQ is being autodetected */\n#define IRQ_WAITING_2_6_17 32 /* IRQ not yet seen - for autodetection */\n#define IRQ_LEVEL_2_6_17 64 /* IRQ level triggered */\n#define IRQ_MASKED_2_6_17 128 /* IRQ masked - shouldn't be seen again */\n\n/*\n * For kernel 2.6.21 and later\n */\n#define IRQ_TYPE_NONE_2_6_21\t\t0x00000000\t/* Default, unspecified type */\n#define IRQ_TYPE_EDGE_RISING_2_6_21\t0x00000001\t/* Edge rising type */\n#define IRQ_TYPE_EDGE_FALLING_2_6_21\t0x00000002\t/* Edge falling type */\n#define IRQ_TYPE_EDGE_BOTH_2_6_21 \t(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)\n#define IRQ_TYPE_LEVEL_HIGH_2_6_21\t0x00000004\t/* Level high type */\n#define IRQ_TYPE_LEVEL_LOW_2_6_21\t0x00000008\t/* Level low type */\n#define IRQ_TYPE_SENSE_MASK_2_6_21\t0x0000000f\t/* Mask of the above */\n#define IRQ_TYPE_PROBE_2_6_21\t\t0x00000010\t/* Probing in progress */\n\n#define IRQ_INPROGRESS_2_6_21\t\t0x00000100\t/* IRQ handler active - do not enter! */\n#define IRQ_DISABLED_2_6_21\t\t0x00000200\t/* IRQ disabled - do not enter! */\n#define IRQ_PENDING_2_6_21\t\t0x00000400\t/* IRQ pending - replay on enable */\n#define IRQ_REPLAY_2_6_21\t\t0x00000800\t/* IRQ has been replayed but not acked yet */\n#define IRQ_AUTODETECT_2_6_21\t\t0x00001000\t/* IRQ is being autodetected */\n#define I\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\nFrom: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From: Alan Tyson \nSubject: [PATCH] Fix \"uptime\" and \"ps -t\" for SLES9\nReferences: 352836\n\nThis patch adds a quirk for SLES9 jiffies initialisation and corrects the time\ndata in \"uptime\" and \"ps -t\" command.\n\n\nAcked-by: Bernhard Walle \n\n---\n defs.h | 8 ++++++++\n kernel.c | 9 ++++++++-\n task.c | 11 +++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\n--- a/defs.h\n+++ b/defs.h\n@@ -682,6 +682,7 @@ struct kernel_table {\n \t\tulong p2m_missing;\n \t} pvops_xen;\n \tint highest_irq;\n+ int is_suse_kernel;\n #define IKCONFIG_AVAIL\t0x1\t/* kernel contains ikconfig data */\n #define IKCONFIG_LOADED\t0x2\t/* ikconfig data is currently loaded */\n \tint ikconfig_flags;\n@@ -5536,6 +5537,13 @@ extern struct lkcd_environment *lkcd;\n \n #endif /* LKCD_COMMON */\n \n+\n+/*\n+ * SUSE specific\n+ */\n+#define is_SLES9() \\\n+\t((THIS_KERNEL_VERSION == LINUX(2,6,5)) && kt->is_suse_kernel)\n+\n /*\n * gdb_interface.c\n */\n--- a/kernel.c\n+++ b/kernel.c\n@@ -237,6 +237,12 @@ kernel_init()\n \n \tverify_version();\n \n+\t/*\n+\t * check if we have a suse kernel (this is the module supported\n+\t * patch of agruen@suse.de\n+\t */\n+\tkt->is_suse_kernel = symbol_exists(\"unsupported\");\n+\n \tif (symbol_exists(\"__per_cpu_offset\")) {\n \t\tif (LKCD_KERNTYPES())\n \t\t\ti = get_cpus_possible();\n@@ -4558,7 +4564,7 @@ get_uptime(char *buf, ulonglong *j64p)\n \n \tif (symbol_exists(\"jiffies_64\")) {\n \t\tget_symbol_data(\"jiffies_64\", sizeof(ulonglong), &jiffies_64);\n-\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0)) {\n+\t\tif (THIS_KERNEL_VERSION >= LINUX(2,6,0) && !is_SLES9()) {\n \t\t\twrapped = (jiffies_64 & 0xffffffff00000000ULL);\n \t\t\tif (wrapped) {\n \t\t\t\twrapped -= 0x100000000ULL;\n@@ -5110,6 +5116,7 @@ no_cpu_flags:\n \tif (symbol_exists(\"p2m_mid_missing\"))\n \t\tfprintf(fp, \" p2m_mid_missing: %lx\\n\", kt->pvops_xen.p2m_mid_missing);\n \tfprintf(fp, \" p2m_missing: %lx\\n\", kt->pvops_xen.p2m_missing);\n+\tfprintf(fp, \" is_suse_kernel: %ld\\n\", kt->is_suse_kernel);\n }\n \n /*\n--- a/task.c\n+++ b/task.c\n@@ -3669,6 +3669,12 @@ start_time_timespec(void)\n \tdefault:\n \t\tbreak;\n \t}\n+\t/* SLES9 stores start_time in nanoseconds, so set TIMESPEC in order */\n+\t/* to do the right calculations in convert_start_time */\n+\tif (is_SLES9()) {\n+\t\ttt->flags |= TIMESPEC;\n+\t\treturn TRUE;\n+\t}\n \n \ttt->flags |= NO_TIMESPEC;\n \n@@ -3700,6 +3706,11 @@ convert_start_time(ulonglong start_time,\n \tulong tmp1, tmp2;\n \tulonglong wrapped;\n \n+\t/* SLES9's start_time is neither jiffies nor a timespec. It's ns */\n+\tif (is_SLES9()) {\n+\t\tstart_time = start_time / 1000000000;\n+\t}\n+\n switch(tt->flags & (TIMESPEC | NO_TIMESPEC))\n {\n case TIMESPEC:\n"}], "metadata": {"id": "crash-5739-crash-sles9-time.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash-sles9-time.patch", "tier": "identical", "language": "c", "patch_lines_changed": 28, "patch_files_count": 0, "total_tokens_est": 1461, "has_source_context": true, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\nCFLAGS.extra | 1 +\n\n## Package\ncrash\n\n## Upstream Fix\n```diff\n---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n CFLAGS.extra | 1 +\n LDFLAGS.extra | 1 +\n 2 files changed, 2 insertions(+)\n\n--- /dev/null\n+++ b/CFLAGS.extra\n@@ -0,0 +1 @@\n+-DLZO\n--- /dev/null\n+++ b/LDFLAGS.extra\n@@ -0,0 +1 @@\n+-llzo2\n"}], "metadata": {"id": "crash-5739-crash_enable_lzo_support.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "crash_enable_lzo_support.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2016-8666, CVE-2016-5195\n\neppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n\n## Package\ncrash\n\n## Files to modify\n- extensions/eppic.mk\n\n## Upstream Fix\n```diff\n---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "---\n eppic/applications/crash/eppic.c | 1110 +++++++++++++++++++++++++++++++++++++++\n extensions/eppic.mk | 26 \n 2 files changed, 1112 insertions(+), 24 deletions(-)\n\n--- a/extensions/eppic.mk\n+++ b/extensions/eppic.mk\n@@ -28,29 +28,7 @@ all:\n \t@if [ -f /usr/bin/flex ] && [ -f /usr/bin/bison ]; then \\\n \t if [ -f ../$(GDB)/crash.target ]; \\\n then \\\n- if [ ! -f $(APPFILE) ]; \\\n- then \\\n- if [ -f \"$(GIT)\" ]; \\\n- then \\\n- if [ -n \"$(EPPIC_GIT_URL)\" ]; then \\\n- git clone \"$(EPPIC_GIT_URL)\" eppic; \\\n- else \\\n-\t if [ -n \"$(GOOGLE)\" ] ; then \\\n-\t git clone https://code.google.com/p/eppic eppic; \\\n-\t fi; \\\n- fi; \\\n- else \\\n-\t if [ ! -f \"$(GIT)\" ]; then \\\n-\t echo \"eppic.so: git command is needed for pulling eppic extension code\"; \\\n-\t fi; \\\n- fi; \\\n- fi; \\\n- if [ -f $(APPFILE) ]; \\\n- then \\\n \t make -f eppic.mk eppic.so; \\\n- else \\\n- echo \"eppic.so: failed to pull eppic code from git repo\"; \\\n- fi; \\\n else \\\n \t echo \"eppic.so: build failed: requires the crash $(GDB) module\"; \\\n fi ;\\\n@@ -61,8 +39,8 @@ all:\n lib-eppic: \n \tcd eppic/libeppic && make\n \n-eppic.so: ../defs.h $(APPFILE) lib-eppic\n-\tgcc -g -Ieppic/libeppic -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Leppic/libeppic -leppic \n+eppic.so: ../defs.h $(APPFILE)\n+\tgcc -g -I../$(GDB)/gdb -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o eppic.so $(APPFILE) -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -leppic\n \n clean:\n \tif [ -d eppic/libeppic ]; \\\n--- /dev/null\n+++ b/extensions/eppic/applications/crash/eppic.c\n@@ -0,0 +1,1110 @@\n+/*\n+ * $Id: eppic.c,v 1.15 2012/01/04 14:46:57 anderson Exp $\n+ *\n+ * This file is part of lcrash, an analysis tool for Linux memory dumps.\n+ *\n+ * Created by Silicon Graphics, Inc.\n+ * Contributions by IBM, and others\n+ *\n+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.\n+ * Copyright (C) 2001, 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version. See the file COPYING for more\n+ * information.\n+ */\n+\n+#include \"gdb/defs.h\"\n+#include \"target.h\"\n+#include \"symtab.h\"\n+#include \"gdbtypes.h\"\n+#include \"gdbcore.h\"\n+#include \"frame.h\"\n+#include \"value.h\"\n+#include \"symfile.h\"\n+#include \"objfiles.h\"\n+#include \"gdbcmd.h\"\n+/*#include \"call-cmds.h\"*/\n+#include \"gdb_regex.h\"\n+#include \"expression.h\"\n+#include \"language.h\"\n+#include \"demangle.h\"\n+#include \"inferior.h\"\n+#include \"linespec.h\"\n+#include \"source.h\"\n+#include \"filenames.h\"\t\t/* for FILENAME_CMP */\n+#include \"objc-lang.h\"\n+\n+#include \"hashtab.h\"\n+\n+#include \"gdb_obstack.h\"\n+#include \"block.h\"\n+#include \"dictionary.h\"\n+\n+#include \n+#include \n+#include \"gdb_string.h\"\n+#include \"gdb_stat.h\"\n+#include \n+#include \"cp-abi.h\"\n+\n+#include \n+#include \n+#include \n+#include \n+\n+/////////////////////////////////////////////////////////////////////////\n+// some stuff from crash's defs.h, file which cannot be included here.\n+// Hate to do this but this is a quick port. \n+// If anyone cares to work on the include and defs structure to make\n+// this work cleanly...\n+//\n+/*\n+ * Global data (global_data.c) \n+ */\n+extern char *args[]; \n+extern int argcnt; \n+extern int argerrs;\n+#define SYNOPSIS (0x1)\n+#define COMPLETE_HELP (0x2)\n+#define PIPE_TO_LESS (0x4)\n+#define KVADDR (0x1)\n+#define QUIET (0x4)\n+\n+typedef void (*cmd_func_t)(void);\n+\n+struct command_table_entry { /* one for each command in menu */\n+\tchar *name;\n+\tcmd_func_t func;\n+\tchar **help_data;\n+\tulong flags;\n+};\n+extern FILE *fp; \n+extern char *crash_global_cmd();\n+\n+typedef unsigned long long int ulonglong;\n+extern int readmem(ulonglong, int, void *, long, char *, ulong);\n+extern int symbol_exists(char *);\n+extern ulong symbol_value(char *);\n+extern void cmd_usage(char *, int);\n+extern void register_extension(struct command_table_entry *);\n+\n+\n+//\n+/////////////////////////////////////////////////////////////////////////\n+/*\n+\tThis is the glue between the eppic interpreter and crash.\n+*/\n+\n+static int\n+apigetmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn readmem(iaddr, KVADDR, p, nbytes, NULL, QUIET);\n+}\n+\n+// Since crash is target dependant (build for the \n+static uint8_t apigetuint8(void* ptr)\n+{\n+uint8_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint8_t)-1;\n+ return val;\n+}\n+\n+static uint16_t apigetuint16(void* ptr)\n+{\n+uint16_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint16_t)-1;\n+ return val;\n+}\n+\n+static uint32_t apigetuint32(void* ptr)\n+{\n+uint32_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint32_t)-1;\n+ return val;\n+}\n+\n+static uint64_t apigetuint64(void* ptr)\n+{\n+uint64_t val;\n+ if(!readmem((unsigned long)ptr, KVADDR, (char*)&val, sizeof val, NULL, QUIET)) return (uint64_t)-1;\n+ return val;\n+}\n+\n+static int\n+apiputmem(ull iaddr, void *p, int nbytes)\n+{\n+\treturn 1;\n+}\n+\n+/* extract a complex type (struct, union and enum) */\n+static int\n+apigetctype(int ctype, char *name, TYPE_S *tout)\n+{\n+ struct symbol *sym;\n+ struct type *type;\n+ int v=0;\n+ \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Looking for type %d name [%s] in struct domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if(!sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Not found.\\nLooking for type %d name [%s] in var domain...\", ctype, name);\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, VAR_DOMAIN, 0);\n+#endif\n+ if(sym) {\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"found class=%d\\n\", sym->aclass);\n+ if(sym->aclass == LOC_TYPEDEF) v=1;\n+ }\n+ }\n+ \n+ if (sym) {\n+ type=sym->type;\n+ if(eppic_is_typedef(ctype) && v) goto match;\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"TYPE_CODE is %d ctype %d\\n\", TYPE_CODE(type), ctype);\n+ switch(TYPE_CODE(type)) {\n+\t case TYPE_CODE_INT: \n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Variable is integer\\n\");\n+\t\tif (eppic_is_typedef(ctype)) {\n+\t\t eppic_dbg_named(DBG_TYPE, name, 2, \n+\t\t\t\t \"integer is not a typedef\\n\");\n+\t\t break;\n+\t\t\t\n+\t\t}\n+\t\n+ case TYPE_CODE_TYPEDEF:\n+ if(eppic_is_typedef(ctype)) goto match; break;\n+ case TYPE_CODE_ENUM: if(eppic_is_enum(ctype)) goto match; break;\n+ case TYPE_CODE_STRUCT: if(eppic_is_struct(ctype)) goto match; break;\n+ case TYPE_CODE_UNION: if(eppic_is_union(ctype)) goto match; break;\n+ }\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found but no match.\\n\");\n+ }\n+ else eppic_dbg_named(DBG_TYPE, name, 2, \"Not Found.\\n\");\n+\n+ return 0;\n+\n+match:\n+ eppic_dbg_named(DBG_TYPE, name, 2, \"Found.\\n\");\n+ /* populate */\n+ eppic_type_settype(tout, ctype);\n+ eppic_type_setsize(tout, TYPE_LENGTH(type));\n+ eppic_type_setidx(tout, (ull)(unsigned long)type);\n+ eppic_pushref(tout, 0);\n+ return 1;\n+}\n+\n+/* set idx value to actual array indexes from specified size */\n+static void\n+eppic_setupidx(TYPE_S*t, int ref, int nidx, int *idxlst)\n+{\n+ /* put the idxlst in index size format */\n+ if(nidx) {\n+\n+ int i;\n+\n+ for(i=0;itype;\n+ } \n+ }\n+ switch(TYPE_CODE(type)) {\n+\n+\t\t/* typedef inserts a level of reference to the 1'dactual type */\n+\t\tcase TYPE_CODE_PTR:\n+\t\n+\t\t\tref++;\n+ type=TYPE_TARGET_TYPE(type);\n+ \t\t\t/* this could be a void*, in which case the drill down stops here */\n+\t\t\tif(!type) {\n+\n+\t\t\t\t/* make it a char* */\n+\t\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\t\treturn 0;\n+\n+\t\t\t}\n+\t\tbreak;\n+\n+\t\t/* handle pointer to functions */\n+\t\tcase TYPE_CODE_FUNC:\n+\n+\t\t\tfctflg=1;\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* Is this an array ? if so then just skip this type info and\n+\t\t we only need information on the elements themselves */\n+\t\tcase TYPE_CODE_ARRAY:\n+ if(!idxlst) idxlst=eppic_calloc(sizeof(int)*(MAXIDX+1));\n+ if(nidx >= MAXIDX) eppic_error(\"Too many indexes! max=%d\\n\", MAXIDX);\n+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)\n+\t {\n+ idxlst[nidx++]=TYPE_LENGTH (type) / TYPE_LENGTH (check_typedef(TYPE_TARGET_TYPE (type)));\n+ }\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\t/* typedef points to a typedef itself */\n+\t\tcase TYPE_CODE_TYPEDEF:\n+ type=TYPE_TARGET_TYPE(type);\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_INT:\n+\n+\t\t\teppic_parsetype(tstr=TYPE_NAME(type), t, 0);\n+\t\t\ttype=0;\n+\t\tbreak;\n+\n+\t\tcase TYPE_CODE_BOOL:\n+\t\t\teppic_parsetype(\"char\", t, ref);\n+\t\t\ttype=0;\n+\t\t\tbreak;\n+\n+\t\tcase TYPE_CODE_UNION: \n+\t\t\teppic_type_mkunion(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_ENUM:\n+\t\t\teppic_type_mkenum(t);\n+\t\t\tgoto label;\n+\n+\t\tcase TYPE_CODE_STRUCT:\n+\t\t{\n+\t\t\teppic_type_mkstruct(t);\n+\n+label:\n+\t\t\teppic_type_setsize(t, TYPE_LENGTH(type));\n+\t\t\teppic_type_setidx(t, (ull)(unsigned long)type);\n+\t\t\ttstr=TYPE_TAG_NAME(type);\n+ if(tstr) apigetctype(V_STRUCT, tstr, t);\n+ type=0;\n+\t\t}\n+\t\tbreak;\n+\n+\t\t/* we don;t have all the info about it */\n+\t\tcase TYPE_CODE_VOID:\n+\t\t\teppic_parsetype(\"int\", t, 0);\n+ type=0;\n+\t\tbreak;\n+\n+\n+\t\tdefault: \n+\t\t\teppic_error(\"Oops drilldowntype\");\n+\t\tbreak;\n+\t\t}\n+\n+\n+\t}\n+\teppic_setupidx(t, ref, nidx, idxlst);\n+\tif(fctflg) eppic_type_setfct(t, 1);\n+\teppic_pushref(t, ref+(nidx?1:0));\n+\tif(tstr) return eppic_strdup(tstr);\n+\treturn eppic_strdup(\"\");\n+}\n+\n+static char *\n+apigetrtype(ull idx, TYPE_S *t)\n+{\n+\treturn drilldowntype((struct type*)(unsigned long)(idx), t);\n+}\n+\n+/*\n+ \tReturn the name of a symbol at an address (if any)\n+*/\n+static char*\n+apifindsym(char *p)\n+{\n+ return NULL;\n+}\n+\n+\n+/* \n+\tGet the type, size and position information for a member of a structure.\n+*/\n+static char*\n+apimember(char *mname, ull tnum, TYPE_S *tm, MEMBER_S *m, ull *lnum)\n+{\n+struct type *type=(struct type*)(unsigned long)tnum;\n+int midx;\n+#define LASTNUM (*lnum)\n+\n+\t/* if we're being asked the next member in a getfirst/getnext sequence */\n+\tif(mname && !mname[0] && LASTNUM) {\n+\n+\t\tmidx = LASTNUM;\n+\n+\t} else {\n+\n+\t\tif (TYPE_CODE(type) == TYPE_CODE_TYPEDEF) {\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif ((TYPE_CODE(type) != TYPE_CODE_STRUCT) && (TYPE_CODE(type) != TYPE_CODE_UNION)) {\n+\t\t\treturn 0;\n+\t\t}\n+ midx=0;\n+\t}\n+\twhile(midx < TYPE_NFIELDS(type)) {\n+ \n+\t\tif (!mname || !mname[0] || !strcmp(mname, TYPE_FIELD_NAME(type, midx))) {\n+\n+ check_typedef(TYPE_FIELD_TYPE(type, midx));\n+\t\t\teppic_member_soffset(m, TYPE_FIELD_BITPOS(type, midx)/8);\n+\t\t\teppic_member_ssize(m, TYPE_FIELD_TYPE(type, midx)->length);\n+\t\t\teppic_member_snbits(m, TYPE_FIELD_BITSIZE(type, midx));\n+\t\t\teppic_member_sfbit(m, TYPE_FIELD_BITPOS(type, midx)%8);\n+\t\t\teppic_member_sname(m, TYPE_FIELD_NAME(type, midx));\n+\t\t\tLASTNUM=midx+1;\n+\t\t\treturn drilldowntype(TYPE_FIELD_TYPE(type, midx), tm);\n+\t\t}\n+\t\tmidx++;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+\tThis function gets the proper allignment value for a type.\n+*/\n+static int\n+apialignment(ull idx)\n+{\n+struct type *type=(struct type *)(unsigned long)idx;\n+\n+ while(1)\n+ {\n+\tswitch(TYPE_CODE(type)) {\n+\n+\t case TYPE_CODE_ARRAY: case TYPE_CODE_TYPEDEF:\n+\t\t type=TYPE_TARGET_TYPE(type);\n+\t break;\n+\n+\t case TYPE_CODE_STRUCT:\n+\t case TYPE_CODE_UNION:\n+\t {\n+\t\tint max=0, cur;\n+\t\tint midx=0;\n+\n+\t\twhile(midx < TYPE_NFIELDS(type)) {\n+ cur=apialignment((ull)(unsigned long)TYPE_FIELD_TYPE(type, midx));\n+\t if(cur > max) max=cur;\n+\t midx++;\n+\t\t}\n+\t\treturn max;\n+ }\n+ \n+\n+\t case TYPE_CODE_PTR:\n+\t case TYPE_CODE_ENUM:\n+\t case TYPE_CODE_INT:\n+\n+\t\t return TYPE_LENGTH (type);\n+\n+\t default:\n+\n+\t\t eppic_error(\"Oops apialignment\");\n+\t}\n+ }\n+}\n+\n+/* get the value of a symbol */\n+static int\n+apigetval(char *name, ull *val, VALUE_S *value)\n+{\n+ if (symbol_exists(name)) {\n+\n+ *val=symbol_value(name);\n+\n+ if(value) {\n+ struct expression *expr;\n+ struct value *sval;\n+ struct cleanup *old_chain = NULL;\n+ struct type *type;\n+ VALUE_S *vref;\n+ TYPE_S *stype;\n+ expr = parse_expression (name);\n+ old_chain = make_cleanup (free_current_contents, &expr);\n+ sval = evaluate_type (expr);\n+ type = value_type(sval);\n+ stype=eppic_gettype(value);\n+ apigetrtype((ull)type, stype);\n+ eppic_pushref(stype, 1);\n+ eppic_setmemaddr(value, *val);\n+ eppic_do_deref(1, value, value);\n+ *val=eppic_getval(value);\n+ if(!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {\n+ char *tname;\n+ type=(struct type*)((long)eppic_type_getidx(stype));\n+ if(type->main_type) tname=type->main_type->tag_name;\n+ if(tname) eppic_chktype(stype, tname);\n+ }\n+ do_cleanups (old_chain);\n+ }\n+ return 1;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tGet the list of enum symbols.\n+*/\n+ENUM_S*\n+apigetenum(char *name)\n+{\n+ struct symbol *sym;\n+\n+#ifdef GDB_6_1\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);\n+#else\n+ sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0);\n+#endif\n+ if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) {\n+\tENUM_S *et=0;\n+ struct type *type=sym->type;\n+ int n=0;\n+\twhile(n < TYPE_NFIELDS (type)) {\n+ \t et=eppic_add_enum(et, eppic_strdup(TYPE_FIELD_NAME(type, n)), TYPE_FIELD_BITPOS(type, n));\n+ n++;\n+\t}\n+ return et;\n+ }\n+ return 0;\n+}\n+\n+/*\n+\tReturn the list of preprocessor defines.\n+\tFor Irix we have to get the die for a startup.c file.\n+\tOf dwarf type DW_TAG_compile_unit.\n+\tthe DW_AT_producer will contain the compile line.\n+\n+\tWe then need to parse that line to get all the -Dname[=value]\n+*/\n+DEF_S *\n+apigetdefs(void)\n+{\n+DEF_S *dt=0;\n+int i;\n+static struct linuxdefs_s {\n+\n+\tchar *name;\n+\tchar *value;\n+\n+} linuxdefs[] = {\n+\n+\t{\"crash\",\t\t\"1\"},\n+\t{\"linux\",\t\t\"1\"},\n+\t{\"__linux\",\t\t\"1\"},\n+\t{\"__linux__\",\t\t\"1\"},\n+\t{\"unix\",\t\t\"1\"},\n+\t{\"__unix\",\t\t\"1\"},\n+\t{\"__unix__\",\t\t\"1\"},\n+\t// helper macros\n+\t{\"LINUX_2_2_16\",\t\"(LINUX_RELEASE==0x020210)\"},\n+\t{\"LINUX_2_2_17\",\t\"(LINUX_RELEASE==0x020211)\"},\n+\t{\"LINUX_2_4_0\",\t\t\"(LINUX_RELEASE==0x020400)\"},\n+\t{\"LINUX_2_2_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020200)\"},\n+\t{\"LINUX_2_4_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020400)\"},\n+\t{\"LINUX_2_6_X\",\t\t\"(((LINUX_RELEASE) & 0xffff00) == 0x020600)\"},\n+\t{\"LINUX_3_X_X\", \"(((LINUX_RELEASE) & 0xff0000) == 0x030000)\"},\n+\t{\"NULL\", \"0\"},\n+#ifdef i386\n+\t{\"i386\", \"1\"},\n+\t{\"__i386\", \"1\"},\n+\t{\"__i386__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390\n+\t{\"s390\", \"1\"},\n+\t{\"__s390\", \"1\"},\n+\t{\"__s390__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef s390x\n+\t {\"s390x\", \"1\"},\n+\t {\"__s390x\", \"1\"},\n+\t {\"__s390x__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"32\"},\n+#endif\n+#ifdef __ia64__\n+\t{\"ia64\", \"1\"},\n+\t{\"__ia64\", \"1\"},\n+\t{\"__ia64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef __x86_64__\n+\t{\"x86_64\", \"1\"},\n+\t{\"_x86_64_\", \"1\"},\n+\t{\"__x86_64__\", \"1\"},\n+\t{\"__LP64__\", \"1\"},\n+\t{\"_LONGLONG\", \"1\"},\n+\t{\"__LONG_MAX__\", \"9223372036854775807L\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+#ifdef ppc64\n+\t{\"ppc64\", \"1\"},\n+\t{\"__ppc64\", \"1\"},\n+\t{\"__ppc64__\", \"1\"},\n+\t{\"BITS_PER_LONG\",\"64\"},\n+#endif\n+\t};\n+ \n+static char *untdef[] = { \n+ \"clock\", \n+ \"mode\", \n+ \"pid\", \n+ \"uid\", \n+ \"xtime\", \n+ \"init_task\", \n+ \"size\", \n+ \"type\",\n+ \"level\",\n+ 0 \n+};\n+\n+#if 0\n+How to extract basic set of -D flags from the kernel image\n+\n+\tprod=eppic_strdup(kl_getproducer());\n+\tfor(p=prod; *p; p++) {\n+\n+\t\tif(*p=='-' && *(p+1)=='D') {\n+\n+\t\t\tchar *def=p+2;\n+\n+\t\t\twhile(*p && *p != '=' && *p != ' ') p++;\n+\n+\t\t\tif(!*p || *p == ' ') {\n+\n+\t\t\t\t*p='\\0';\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(\"1\"));\n+\n+\t\t\t} else {\n+\n+\t\t\t\tchar *val=p+1;\n+\n+\t\t\t\t*p++='\\0';\n+\t\t\t\twhile(*p && *p != ' ') p++;\n+\t\t\t\t*p='\\0';\n+\n+\t\t\t\tdt=eppic_add_def(dt, eppic_strdup(def), eppic_strdup(val));\n+\t\t\t}\n+\t\t}\n+\t}\n+#endif\t\n+\n+ /* remove some tdef with very usual identifier.\n+ could also be cases where the kernel defined a type and variable with same name e.g. xtime.\n+ the same can be accomplished in source using #undef or forcing the evaluation of \n+ a indentifier as a variable name ex: __var(xtime).\n+ \n+ I tried to make the grammar as unambiqguous as I could.\n+ \n+ If this becomes to much of a problem I might diable usage of all image typedefs usage in eppic!\n+ */ \n+ {\n+ char **tdefname=untdef;\n+ while(*tdefname) eppic_addneg(*tdefname++);;\n+ \n+ }\n+ \n+\t/* insert constant defines from list above */\n+\tfor(i=0;i\\n\"\n+\t\t, S_MAJOR, S_MINOR);\n+}\n+\n+static void\n+run_callback(void)\n+{\n+extern char *crash_global_cmd();\n+FILE *ofp = NULL;\n+\n+\tif (fp) {\n+\t\tofp = eppic_getofile();\n+\t\teppic_setofile(fp);\n+\t}\n+\n+\teppic_cmd(crash_global_cmd(), args, argcnt);\n+\n+\tif (ofp) \n+\t\teppic_setofile(ofp);\n+}\n+\n+\n+void\n+edit_cmd(void)\n+{\n+int c, file=0;\n+ while ((c = getopt(argcnt, args, \"lf\")) != EOF) {\n+ switch(c)\n+ {\n+ case 'l':\n+ eppic_vilast();\n+ return;\n+ break;\n+ case 'f':\n+ file++;\n+ break;\n+ default:\n+ argerrs++;\n+ break;\n+ }\n+ }\n+\n+ if (argerrs)\n+ cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\n+ else if(args[optind]) {\n+ while(args[optind]) {\n+\t eppic_vi(args[optind++], file);\n+ }\n+\t}\n+ else cmd_usage(crash_global_cmd(), SYNOPSIS);\n+}\n+\n+char *edit_help[]={\n+\t\t\"edit\",\n+ \"Start a $EDITOR session of a eppic function or file\",\n+ \"<-f fileName>|\",\n+ \"This command can be use during a tight development cycle\",\n+ \"where frequent editing->run->editing sequences are executed.\",\n+ \"To edit a known eppic macro file use the -f option. To edit the file\",\n+ \"at the location of a known function's declaration omit the -f option.\",\n+ \"Use a single -l option to be brought to the last compile error location.\",\n+ \"\",\n+ \"EXAMPLES:\",\n+ \" %s> edit -f ps\",\n+ \" %s> edit ps\",\n+ \" %s> edit ps_opt\",\n+ \" %s> edit -l\",\n+ NULL\n+};\n+\n+\n+// these control debug mode when parsing (pre-processor and compile)\n+int eppicdebug, eppicppdebug;\n+\n+void\n+load_cmd(void)\n+{\n+\tif(argcnt< 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse {\n+ eppic_setofile(fp);\n+ eppic_loadunload(1, args[1], 0);\n+ }\n+}\n+\n+char *load_help[]={\n+\t\t\"load\",\n+ \"Load a eppic file\",\n+ \"|\",\n+ \" Load a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be loaded.\",\n+ NULL\n+ \n+};\n+\n+void\n+unload_cmd(void)\n+{\n+\tif(argcnt < 2) cmd_usage(crash_global_cmd(), SYNOPSIS);\n+\telse eppic_loadunload(0, args[1], 0);\n+}\n+\n+char *unload_help[]={\n+\t\t\"unload\",\n+ \"Unload a eppic file\",\n+ \"|\",\n+ \" Unload a file or a directory. In the case of a directory\",\n+\t\t\" all files in that directory will be unloaded.\",\n+ NULL\n+};\n+\n+void\n+sdebug_cmd(void)\n+{\n+\tif(argcnt < 2) eppic_msg(\"Current eppic debug level is %d\\n\", eppic_getdbg());\n+\telse eppic_setdbg(atoi(args[1]));\n+}\n+\n+char *sdebug_help[]={\n+\t\t\"sdebug\",\n+ \"Print or set eppic debug level\",\n+ \"\",\n+ \" Set the debug of eppic. Without any parameter, shows the current debug level.\",\n+ NULL\n+};\n+\n+void\n+sname_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ if(eppic_getname()) eppic_msg(\"Current eppic name match is '%s'\\n\", eppic_getname());\n+ else eppic_msg(\"No name match specified yet.\\n\");\n+\t} else eppic_setname(args[1]);\n+}\n+\n+char *sname_help[]={\n+\t\t\"sname\",\n+ \"Print or set eppic name match.\",\n+ \"\",\n+ \" Set eppic name string for matches. Debug messages that are object oriented\",\n+ \" will only be displayed if the object name (struct, type, ...) matches this\",\n+\t\t\" value.\",\n+ NULL\n+};\n+\n+void\n+sclass_cmd(void)\n+{\n+\tif(argcnt < 2) {\n+ char **classes=eppic_getclass();\n+ eppic_msg(\"Current eppic classes are :\");\n+ while(*classes) eppic_msg(\"'%s' \", *classes++);\n+ eppic_msg(\"\\n\");\n+\t\n+ }\n+ else {\n+ int i;\n+ for(i=1; i[, ]\",\n+ \" Set eppic debug classes. Only debug messages that are in the specified classes\",\n+ \" will be displayed.\",\n+ NULL\n+};\n+\n+#define NCMDS 200\n+static struct command_table_entry command_table[NCMDS] = {\n+\n+\t{\"edit\", edit_cmd, edit_help},\n+\t{\"load\", load_cmd, load_help},\n+\t{\"unload\", unload_cmd, unload_help},\n+\t{\"sdebug\", sdebug_cmd, sdebug_help},\n+\t{\"sname\", sname_cmd, sname_help},\n+\t{\"sclass\", sclass_cmd, sclass_help},\n+\t{(char *)0 }\n+};\n+\n+static void\n+add_eppic_cmd(char *name, void (*cmd)(void), char **help, int flags)\n+{\n+struct command_table_entry *cp;\n+struct command_table_entry *crash_cmd_table();\n+\n+ // check for a clash with native commands\n+ for (cp = crash_cmd_table(); cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_msg(\"Eppic command name '%s' conflicts with native crash command.\\n\", name);\n+ return;\n+ }\n+ }\n+\n+ // make sure we have enough space for the new command\n+ if(!command_table[NCMDS-2].name) {\n+ for (cp = command_table; cp->name; cp++);\n+ cp->name=eppic_strdup(name);\n+ cp->func=cmd;\n+ cp->help_data=help;\n+ cp->flags=flags;\n+ }\n+}\n+\n+static void\n+rm_eppic_cmd(char *name)\n+{\n+struct command_table_entry *cp, *end;\n+\n+ for (cp = command_table; cp->name; cp++) {\n+ if (!strcmp(cp->name, name)) {\n+ eppic_free(cp->name);\n+ memmove(cp, cp+1, sizeof *cp *(NCMDS-(cp-command_table)-1));\n+ break;\n+ }\n+ }\n+}\n+\n+/*\n+\tThis function is called for every new function\n+\tgenerated by a load command. This enables us to\n+\tregister new commands.\n+\n+\tWe check here is the functions:\n+\n+\tfname_help()\n+\tfname_opt()\n+\tand\n+\tfname_usage()\n+\n+\texist, and if so then we have a new command.\n+\tThen we associated (register) a function with\n+\tthe standard eppic callbacks.\n+*/\n+void\n+reg_callback(char *name, int load)\n+{\n+char fname[MAX_SYMNAMELEN+sizeof(\"_usage\")+1];\n+char *help_str, *opt_str;\n+char **help=malloc(sizeof *help * 5);\n+\n+ if(!help) return;\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ snprintf(fname, sizeof(fname), \"%s_usage\", name);\n+ if(eppic_chkfname(fname, 0)) {\n+ if(load) {\n+ opt_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ snprintf(fname, sizeof(fname), \"%s_help\", name);\n+ help_str=eppic_strdup((char*)(unsigned long)eppic_exefunc(fname, 0));\n+ help[0]=eppic_strdup(name);\n+ help[1]=\"\";\n+ help[2]=eppic_strdup(opt_str);\n+ help[3]=eppic_strdup(help_str);\n+ help[4]=0;\n+ add_eppic_cmd(name, run_callback, help, 0);\n+ eppic_free(help_str);\n+ eppic_free(opt_str);\n+ return;\n+ }\n+ else rm_eppic_cmd(name);\n+ }\n+ }\n+ free(help);\n+ return;\n+}\n+\n+/* \n+ * The _fini() function is called if the shared object is unloaded. \n+ * If desired, perform any cleanups here. \n+ */\n+void _fini() \n+{ \n+ // need to unload any files we have loaded\n+ \n+}\n+\n+VALUE_S *curtask(VALUE_S *v, ...)\n+{\n+unsigned long get_curtask();\n+ return eppic_makebtype((ull)get_curtask());\n+}\n+\n+_init() /* Register the command set. */\n+{ \n+#define LCDIR \"/usr/share/eppic/crash\"\n+#define LCIDIR \"include\"\n+#define LCUDIR \".eppic\"\n+\n+\n+\tif(eppic_open() >= 0) {\n+\n+\t\tchar *path, *ipath;\n+\t\tchar *homepath=0;\n+ \tchar *home=getenv(\"HOME\");\n+\n+\t\t/* set api, default size, and default sign for types */\n+#ifdef i386\n+#define EPPIC_ABI ABI_INTEL_X86\n+#else \n+#ifdef __ia64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __x86_64__\n+#define EPPIC_ABI ABI_INTEL_IA\n+#else\n+#ifdef __s390__\n+#define EPPIC_ABI ABI_S390\n+#else\n+#ifdef __s390x__\n+#define EPPIC_ABI ABI_S390X\n+#else\n+#ifdef PPC64\n+#define EPPIC_ABI ABI_PPC64\n+#else\n+#error eppic: Unkown ABI \n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+#endif\n+\t\teppic_apiset(&icops, EPPIC_ABI, sizeof(long), 0);\n+\n+\t\teppic_version();\n+\n+ \t/* set the macro search path */\n+ \tif(!(path=getenv(\"EPPIC_MPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tpath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+sizeof(LCDIR)+4);\n+\t\t\t\thomepath=eppic_alloc(strlen(home)+sizeof(LCUDIR)+2);\n+\n+\t\t\t\t/* build a path for call to eppic_load() */\n+\t\t\t\tstrcpy(homepath, home);\n+\t\t\t\tstrcat(homepath, \"/\");\n+\t\t\t\tstrcat(homepath, LCUDIR);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(path, LCDIR);\n+ \tstrcat(path, \":\");\n+ \tstrcat(path, home);\n+ \tstrcat(path, \"/\");\n+\t\t\t\tstrcat(path, LCUDIR);\n+ \t}\n+ \telse path=LCDIR;\n+\t\t}\n+\t\teppic_setmpath(path);\n+\n+\t\tfprintf(fp, \"\\tLoading eppic commands from %s .... \",\n+ path);\n+\n+\t\t/* include path */\n+\t\tif(!(ipath=getenv(\"EPPIC_IPATH\"))) {\n+\n+ \tif(home) {\n+\n+ \tipath=eppic_alloc(strlen(home)+sizeof(LCDIR)+sizeof(LCUDIR)+(sizeof(LCIDIR)*2)+(sizeof(\"/usr/include\")+2)+6);\n+\n+\t\t\t\t/* built the official path */\n+ \tstrcpy(ipath, LCDIR);\n+ \tstrcat(ipath, \"/\"LCIDIR\":\");\n+ \tstrcat(ipath, home);\n+ \tstrcat(ipath, \"/\");\n+\t\t\t\tstrcat(ipath, LCUDIR);\n+\t\t\t\tstrcat(ipath, \"/\"LCIDIR);\n+\t\t\t\tstrcat(ipath, \":/usr/include\");\n+ \t}\n+ \telse ipath=LCDIR\"/\"LCIDIR;\n+\t\t}\n+\t\teppic_setipath(ipath);\n+\n+\t\t/* set the new function callback */\n+\t\teppic_setcallback(reg_callback);\n+\n+\t\t/* load the default macros */\n+\t\teppic_loadall();\n+\n+\t\t/* load some eppic specific commands */\n+ register_extension(command_table);\n+ \n+ /* some builtins */\n+ \teppic_builtin(\"int curtask()\", curtask);\n+ \n+ fprintf(fp, \"Done.\\n\");\n+\t} \n+ return 1;\n+}\n+\n"}], "metadata": {"id": "crash-5739-eppic-switch-to-system-lib.patch", "cve_id": "CVE-2016-8666", "cves": ["CVE-2016-5195", "CVE-2016-8666"], "package": "crash", "incident_id": 5739, "patch_name": "eppic-switch-to-system-lib.patch", "tier": "identical", "language": "unknown", "patch_files_count": 0, "has_source_context": false, "upstream_enriched": false, "suse_license": "GFDL-1.2-only AND GPL-3.0-or-later"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2018-5383\n\nlinux-firmware:Update firmware patch for Intel Bluetooth 7265\n\n## Package\nkernel-firmware\n\n## Files to modify\n- WHENCE\n\n## Upstream Fix\n```diff\nFrom 7003c1b32f258952c6aa552ceda0dd05b9a4281d Mon Sep 17 00:00:00 2001\nFrom: \"Cho, Yu-Chen\" \nDate: Thu, 14 Feb 2019 18:20:51 +0800\nSubject: [PATCH] linux-firmware:Update firmware patch for Intel Bluetooth 7265\n (D1)\n\nThis patch updates the firmware file for Intel Bluetooth 7265\nAlso it is known as Intel stonePeak(STPD1).\n\nFW Build: REL_52_00005\n\nRelease Version: 20.70.0.4\n---\n WHENCE | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 7d27600..85dcde7 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -2833,7 +2833,7 @@ Version: BT_StonePeak_C0_REL_59_0001\n File: intel/ibt-hw-37.8.10-fw-1.10.3.11.e.bseq\n Version: BT_StonePeak_D0_REL_37_0002\n File: intel/ibt-hw-37.8.10-fw-22.50.19.14.f.bseq\n-Version: BT_StonePeak_D1_REL_28_0001\n+Version: BT_StonePeak_D1_REL_52_00005\n File: intel/ibt-11-5.ddc\n Version: LnP/SfP_REL0370\n File: intel/ibt-11-5.sfi\n-- \n2.20.1\n\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 7003c1b32f258952c6aa552ceda0dd05b9a4281d Mon Sep 17 00:00:00 2001\nFrom: \"Cho, Yu-Chen\" \nDate: Thu, 14 Feb 2019 18:20:51 +0800\nSubject: [PATCH] linux-firmware:Update firmware patch for Intel Bluetooth 7265\n (D1)\n\nThis patch updates the firmware file for Intel Bluetooth 7265\nAlso it is known as Intel stonePeak(STPD1).\n\nFW Build: REL_52_00005\n\nRelease Version: 20.70.0.4\n---\n WHENCE | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 7d27600..85dcde7 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -2833,7 +2833,7 @@ Version: BT_StonePeak_C0_REL_59_0001\n File: intel/ibt-hw-37.8.10-fw-1.10.3.11.e.bseq\n Version: BT_StonePeak_D0_REL_37_0002\n File: intel/ibt-hw-37.8.10-fw-22.50.19.14.f.bseq\n-Version: BT_StonePeak_D1_REL_28_0001\n+Version: BT_StonePeak_D1_REL_52_00005\n File: intel/ibt-11-5.ddc\n Version: LnP/SfP_REL0370\n File: intel/ibt-11-5.sfi\n-- \n2.20.1\n\n"}], "metadata": {"id": "kernel-firmware-9719-WHENCE-ibt-update.patch", "cve_id": "CVE-2018-5383", "cves": ["CVE-2018-5383"], "package": "kernel-firmware", "incident_id": 9719, "patch_name": "WHENCE-ibt-update.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 3, "patch_files_count": 1, "total_tokens_est": 580, "has_source_context": false, "upstream_enriched": false, "suse_license": "SUSE-Proprietary-or-OSS"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2019-15126\n\n===================================================================\n\n## Package\nkernel-firmware\n\n## Files to modify\n- b/WHENCE\n\n## Upstream Fix\n```diff\nIndex: b/WHENCE\n===================================================================\n--- a/WHENCE\n+++ b/WHENCE\n@@ -2506,6 +2506,7 @@ File: brcm/brcmfmac43143.bin\n File: brcm/brcmfmac43143-sdio.bin\n File: brcm/brcmfmac43430a0-sdio.bin\n File: brcm/brcmfmac43455-sdio.bin\n+File: brcm/brcmfmac43455-sdio.clm_blob\n File: brcm/brcmfmac4350c2-pcie.bin\n File: brcm/brcmfmac4350-pcie.bin\n File: brcm/brcmfmac4356-sdio.bin\n@@ -2523,6 +2524,7 @@ Licence: Redistributable. See LICENCE.br\n File: brcm/brcmfmac43340-sdio.bin\n File: brcm/brcmfmac43362-sdio.bin\n File: brcm/brcmfmac43430-sdio.bin\n+File: brcm/brcmfmac43430-sdio.clm_blob\n File: brcm/brcmfmac4354-sdio.bin\n File: brcm/brcmfmac4356-pcie.bin\n File: brcm/brcmfmac4373-sdio.bin\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "Index: b/WHENCE\n===================================================================\n--- a/WHENCE\n+++ b/WHENCE\n@@ -2506,6 +2506,7 @@ File: brcm/brcmfmac43143.bin\n File: brcm/brcmfmac43143-sdio.bin\n File: brcm/brcmfmac43430a0-sdio.bin\n File: brcm/brcmfmac43455-sdio.bin\n+File: brcm/brcmfmac43455-sdio.clm_blob\n File: brcm/brcmfmac4350c2-pcie.bin\n File: brcm/brcmfmac4350-pcie.bin\n File: brcm/brcmfmac4356-sdio.bin\n@@ -2523,6 +2524,7 @@ Licence: Redistributable. See LICENCE.br\n File: brcm/brcmfmac43340-sdio.bin\n File: brcm/brcmfmac43362-sdio.bin\n File: brcm/brcmfmac43430-sdio.bin\n+File: brcm/brcmfmac43430-sdio.clm_blob\n File: brcm/brcmfmac4354-sdio.bin\n File: brcm/brcmfmac4356-pcie.bin\n File: brcm/brcmfmac4373-sdio.bin\n"}], "metadata": {"id": "kernel-firmware-17333-brcmfmac-whence.patch", "cve_id": "CVE-2019-15126", "cves": ["CVE-2019-15126"], "package": "kernel-firmware", "incident_id": 17333, "patch_name": "brcmfmac-whence.patch", "tier": "identical", "language": "unknown", "patch_files_count": 1, "has_source_context": false, "upstream_enriched": false}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2018-5383\n\nUpdate Intel OPA hfi1 firmware\n\n## Package\nkernel-firmware\n\n## Files to modify\n- WHENCE\n\n## Upstream Fix\n```diff\nFrom 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n"}], "metadata": {"id": "kernel-firmware-9719-Update-Intel-OPA-hfi1-firmware.patch", "cve_id": "CVE-2018-5383", "cves": ["CVE-2018-5383"], "package": "kernel-firmware", "incident_id": 9719, "patch_name": "Update-Intel-OPA-hfi1-firmware.patch", "tier": "identical", "language": "unknown", "patch_files_count": 1, "has_source_context": false, "upstream_enriched": false}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-1142857\n\nUpdate Intel OPA hfi1 firmware\n\n## Package\nkernel-firmware\n\n## Files to modify\n- WHENCE\n\n## Upstream Fix\n```diff\nFrom 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n"}], "metadata": {"id": "kernel-firmware-7900-Update-Intel-OPA-hfi1-firmware.patch", "cve_id": "CVE-2015-1142857", "cves": ["CVE-2015-1142857"], "package": "kernel-firmware", "incident_id": 7900, "patch_name": "Update-Intel-OPA-hfi1-firmware.patch", "tier": "identical", "language": "unknown", "patch_files_count": 1, "has_source_context": false, "upstream_enriched": false}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2015-1142857\n\nVersion 16.242414.0\n\n## Package\nkernel-firmware\n\n## Upstream Fix\n```diff\n--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n"}], "metadata": {"id": "kernel-firmware-7900-WHNCE-iwlwifi-update.patch", "cve_id": "CVE-2015-1142857", "cves": ["CVE-2015-1142857"], "package": "kernel-firmware", "incident_id": 7900, "patch_name": "WHNCE-iwlwifi-update.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 6, "patch_files_count": 0, "total_tokens_est": 432, "has_source_context": false, "upstream_enriched": false, "suse_license": "SUSE-Proprietary-or-OSS"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nUpdate Intel OPA hfi1 firmware\n\n## Package\nkernel-firmware\n\n## Files to modify\n- WHENCE\n\n## Upstream Fix\n```diff\nFrom 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n"}], "metadata": {"id": "kernel-firmware-7634-Update-Intel-OPA-hfi1-firmware.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "kernel-firmware", "incident_id": 7634, "patch_name": "Update-Intel-OPA-hfi1-firmware.patch", "tier": "identical", "language": "unknown", "patch_files_count": 1, "has_source_context": false, "upstream_enriched": false}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-5715\n\nVersion 16.242414.0\n\n## Package\nkernel-firmware\n\n## Upstream Fix\n```diff\n--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n"}], "metadata": {"id": "kernel-firmware-7634-WHNCE-iwlwifi-update.patch", "cve_id": "CVE-2017-5715", "cves": ["CVE-2017-5715"], "package": "kernel-firmware", "incident_id": 7634, "patch_name": "WHNCE-iwlwifi-update.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 6, "patch_files_count": 0, "total_tokens_est": 431, "has_source_context": false, "upstream_enriched": false, "suse_license": "SUSE-Proprietary-or-OSS"}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-13081, CVE-2017-13080\n\nUpdate Intel OPA hfi1 firmware\n\n## Package\nkernel-firmware\n\n## Files to modify\n- WHENCE\n\n## Upstream Fix\n```diff\nFrom 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "From 6560c34569fb22723830fdfa8f0ce50da05116d9 Mon Sep 17 00:00:00 2001\nFrom: John Fleck \nDate: Mon, 26 Jun 2017 11:00:10 -0400\nSubject: [PATCH] Update Intel OPA hfi1 firmware\n\nRevert dc firmware to production signed v0.47\nUpdate version numbers in WHENCE file\n\nSigned-off-by: John Fleck \n---\n WHENCE | 2 +-\n hfi1_dc8051.fw | Bin 32828 -> 32252 bytes\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/WHENCE b/WHENCE\nindex 2ca052f..cda3210 100644\n--- a/WHENCE\n+++ b/WHENCE\n@@ -3506,7 +3506,7 @@ License: Redistributable. See LICENSE.atmel for details\n Driver: hfi1 - Intel OPA Gen 1 adapter\n \n File: hfi1_dc8051.fw\n-Version: 1.18\n+Version: v0.47\n File: hfi1_fabric.fw\n Version: 0x1055\n File: hfi1_pcie.fw\n"}], "metadata": {"id": "kernel-firmware-7528-Update-Intel-OPA-hfi1-firmware.patch", "cve_id": "CVE-2017-13081", "cves": ["CVE-2017-13080", "CVE-2017-13081"], "package": "kernel-firmware", "incident_id": 7528, "patch_name": "Update-Intel-OPA-hfi1-firmware.patch", "tier": "identical", "language": "unknown", "patch_files_count": 1, "has_source_context": false, "upstream_enriched": false}} {"messages": [{"role": "system", "content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."}, {"role": "user", "content": "## CVE: CVE-2017-13081, CVE-2017-13080\n\nVersion 16.242414.0\n\n## Package\nkernel-firmware\n\n## Upstream Fix\n```diff\n--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n\n```\n\nGenerate a backported patch for the SUSE target version."}, {"role": "assistant", "content": "--- kernel-firmware-20170530.old/WHENCE\t2017-05-30 21:23:02.000000000 +0200\n+++ kernel-firmware-20170530/WHENCE\t2017-11-15 14:53:05.255112317 +0100\n@@ -861,7 +861,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7260-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-3160-7.ucode\n Version: 22.1.7.0\n@@ -885,7 +885,7 @@\n Version 16.242414.0\n \n File: iwlwifi-3160-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265-8.ucode\n Version: 22.24.8.0\n@@ -906,7 +906,7 @@\n Version 16.242414.0\n \n File: iwlwifi-7265-17.ucode\n-Version 17.459231.0\n+Version 17.608620.0\n \n File: iwlwifi-7265D-10.ucode\n Version: 23.15.10.0\n"}], "metadata": {"id": "kernel-firmware-7528-WHNCE-iwlwifi-update.patch", "cve_id": "CVE-2017-13081", "cves": ["CVE-2017-13080", "CVE-2017-13081"], "package": "kernel-firmware", "incident_id": 7528, "patch_name": "WHNCE-iwlwifi-update.patch", "tier": "identical", "language": "unknown", "patch_lines_changed": 6, "patch_files_count": 0, "total_tokens_est": 435, "has_source_context": false, "upstream_enriched": false, "suse_license": "SUSE-Proprietary-or-OSS"}}