From: Greg Kroah-Hartman Date: Thu, 31 Aug 2017 06:20:12 +0000 (+0200) Subject: 3.18-stable patches X-Git-Tag: v3.18.69~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e8d0e515770f82cb4a16cc019219ea5a6124aad3;p=thirdparty%2Fkernel%2Fstable-queue.git 3.18-stable patches added patches: arm64-flush-fp-simd-state-correctly-after-execve.patch arm64-fpsimd-prevent-registers-leaking-across-exec.patch clk-si5351-constify-clock-names-and-struct-regmap_config.patch scsi-sg-protect-accesses-to-reserved-page-array.patch scsi-sg-reset-res_in_use-after-unlinking-reserved-array.patch x86-64-handle-pc-relative-relocations-on-per-cpu-data.patch x86-tools-fix-gcc-7-warning-in-relocs.c.patch --- diff --git a/queue-3.18/arm64-flush-fp-simd-state-correctly-after-execve.patch b/queue-3.18/arm64-flush-fp-simd-state-correctly-after-execve.patch new file mode 100644 index 00000000000..19e81b90839 --- /dev/null +++ b/queue-3.18/arm64-flush-fp-simd-state-correctly-after-execve.patch @@ -0,0 +1,45 @@ +From 674c242c9323d3c293fc4f9a3a3a619fe3063290 Mon Sep 17 00:00:00 2001 +From: Ard Biesheuvel +Date: Thu, 27 Aug 2015 07:12:33 +0100 +Subject: arm64: flush FP/SIMD state correctly after execve() + +From: Ard Biesheuvel + +commit 674c242c9323d3c293fc4f9a3a3a619fe3063290 upstream. + +When a task calls execve(), its FP/SIMD state is flushed so that +none of the original program state is observeable by the incoming +program. + +However, since this flushing consists of setting the in-memory copy +of the FP/SIMD state to all zeroes, the CPU field is set to CPU 0 as +well, which indicates to the lazy FP/SIMD preserve/restore code that +the FP/SIMD state does not need to be reread from memory if the task +is scheduled again on CPU 0 without any other tasks having entered +userland (or used the FP/SIMD in kernel mode) on the same CPU in the +mean time. If this happens, the FP/SIMD state of the old program will +still be present in the registers when the new program starts. + +So set the CPU field to the invalid value of NR_CPUS when performing +the flush, by calling fpsimd_flush_task_state(). + +Reported-by: Chunyan Zhang +Reported-by: Janet Liu +Signed-off-by: Ard Biesheuvel +Signed-off-by: Will Deacon +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm64/kernel/fpsimd.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/arm64/kernel/fpsimd.c ++++ b/arch/arm64/kernel/fpsimd.c +@@ -157,6 +157,7 @@ void fpsimd_thread_switch(struct task_st + void fpsimd_flush_thread(void) + { + memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); ++ fpsimd_flush_task_state(current); + set_thread_flag(TIF_FOREIGN_FPSTATE); + } + diff --git a/queue-3.18/arm64-fpsimd-prevent-registers-leaking-across-exec.patch b/queue-3.18/arm64-fpsimd-prevent-registers-leaking-across-exec.patch new file mode 100644 index 00000000000..0f2d2d7a329 --- /dev/null +++ b/queue-3.18/arm64-fpsimd-prevent-registers-leaking-across-exec.patch @@ -0,0 +1,54 @@ +From 096622104e14d8a1db4860bd557717067a0515d2 Mon Sep 17 00:00:00 2001 +From: Dave Martin +Date: Fri, 18 Aug 2017 16:57:01 +0100 +Subject: arm64: fpsimd: Prevent registers leaking across exec + +From: Dave Martin + +commit 096622104e14d8a1db4860bd557717067a0515d2 upstream. + +There are some tricky dependencies between the different stages of +flushing the FPSIMD register state during exec, and these can race +with context switch in ways that can cause the old task's regs to +leak across. In particular, a context switch during the memset() can +cause some of the task's old FPSIMD registers to reappear. + +Disabling preemption for this small window would be no big deal for +performance: preemption is already disabled for similar scenarios +like updating the FPSIMD registers in sigreturn. + +So, instead of rearranging things in ways that might swap existing +subtle bugs for new ones, this patch just disables preemption +around the FPSIMD state flushing so that races of this type can't +occur here. This brings fpsimd_flush_thread() into line with other +code paths. + +Fixes: 674c242c9323 ("arm64: flush FP/SIMD state correctly after execve()") +Reviewed-by: Ard Biesheuvel +Signed-off-by: Dave Martin +Signed-off-by: Will Deacon +Signed-off-by: Greg Kroah-Hartman +--- + +For stable only. + +3.17.x-4.0.x don't appear active, and this patch isn't sufficient to fix +them (they would need 674c242c9323 also). + + arch/arm64/kernel/fpsimd.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/arm64/kernel/fpsimd.c ++++ b/arch/arm64/kernel/fpsimd.c +@@ -156,9 +156,11 @@ void fpsimd_thread_switch(struct task_st + + void fpsimd_flush_thread(void) + { ++ preempt_disable(); + memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); + fpsimd_flush_task_state(current); + set_thread_flag(TIF_FOREIGN_FPSTATE); ++ preempt_enable(); + } + + /* diff --git a/queue-3.18/clk-si5351-constify-clock-names-and-struct-regmap_config.patch b/queue-3.18/clk-si5351-constify-clock-names-and-struct-regmap_config.patch new file mode 100644 index 00000000000..766734a570a --- /dev/null +++ b/queue-3.18/clk-si5351-constify-clock-names-and-struct-regmap_config.patch @@ -0,0 +1,61 @@ +From 8234caed27f7bce141c9fb1f7e76c91a2a66d248 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Fri, 20 Mar 2015 12:34:10 +0100 +Subject: clk: si5351: Constify clock names and struct regmap_config + +From: Krzysztof Kozlowski + +commit 8234caed27f7bce141c9fb1f7e76c91a2a66d248 upstream. + +The regmap_config struct may be const because it is not modified by the +driver and regmap_init() accepts pointer to const. + +Replace doubled const in the arrays of clock names with proper const +pointer to const data. This fixes the warnings: + +drivers/clk/clk-si5351.c:71:25: warning: duplicate const +drivers/clk/clk-si5351.c:74:25: warning: duplicate const +drivers/clk/clk-si5351.c:77:25: warning: duplicate const +drivers/clk/clk-si5351.c:80:25: warning: duplicate const + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Max Filippov +Signed-off-by: Stephen Boyd +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/clk/clk-si5351.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/clk/clk-si5351.c ++++ b/drivers/clk/clk-si5351.c +@@ -68,16 +68,16 @@ struct si5351_driver_data { + struct si5351_hw_data *clkout; + }; + +-static const char const *si5351_input_names[] = { ++static const char * const si5351_input_names[] = { + "xtal", "clkin" + }; +-static const char const *si5351_pll_names[] = { ++static const char * const si5351_pll_names[] = { + "plla", "pllb", "vxco" + }; +-static const char const *si5351_msynth_names[] = { ++static const char * const si5351_msynth_names[] = { + "ms0", "ms1", "ms2", "ms3", "ms4", "ms5", "ms6", "ms7" + }; +-static const char const *si5351_clkout_names[] = { ++static const char * const si5351_clkout_names[] = { + "clk0", "clk1", "clk2", "clk3", "clk4", "clk5", "clk6", "clk7" + }; + +@@ -207,7 +207,7 @@ static bool si5351_regmap_is_writeable(s + return true; + } + +-static struct regmap_config si5351_regmap_config = { ++static const struct regmap_config si5351_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .cache_type = REGCACHE_RBTREE, diff --git a/queue-3.18/scsi-sg-protect-accesses-to-reserved-page-array.patch b/queue-3.18/scsi-sg-protect-accesses-to-reserved-page-array.patch new file mode 100644 index 00000000000..326cc1d2ddc --- /dev/null +++ b/queue-3.18/scsi-sg-protect-accesses-to-reserved-page-array.patch @@ -0,0 +1,172 @@ +From 1bc0eb0446158cc76562176b80623aa119afee5b Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Fri, 7 Apr 2017 09:34:14 +0200 +Subject: scsi: sg: protect accesses to 'reserved' page array + +From: Hannes Reinecke + +commit 1bc0eb0446158cc76562176b80623aa119afee5b upstream. + +The 'reserved' page array is used as a short-cut for mapping data, +saving us to allocate pages per request. However, the 'reserved' array +is only capable of holding one request, so this patch introduces a mutex +for protect 'sg_fd' against concurrent accesses. + +Signed-off-by: Hannes Reinecke +Reviewed-by: Johannes Thumshirn +Tested-by: Johannes Thumshirn +Reviewed-by: Christoph Hellwig +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman + +[toddpoynor@google.com: backport to 3.18-4.9, fixup for bad ioctl +SG_SET_FORCE_LOW_DMA code removed in later versions and not modified by +the original patch.] + +Signed-off-by: Hannes Reinecke +Reviewed-by: Johannes Thumshirn +Tested-by: Johannes Thumshirn +Reviewed-by: Christoph Hellwig +Signed-off-by: Martin K. Petersen +Signed-off-by: Todd Poynor +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/scsi/sg.c | 47 ++++++++++++++++++++++++++--------------------- + 1 file changed, 26 insertions(+), 21 deletions(-) + +--- a/drivers/scsi/sg.c ++++ b/drivers/scsi/sg.c +@@ -153,6 +153,7 @@ typedef struct sg_fd { /* holds the sta + struct sg_device *parentdp; /* owning device */ + wait_queue_head_t read_wait; /* queue read until command done */ + rwlock_t rq_list_lock; /* protect access to list in req_arr */ ++ struct mutex f_mutex; /* protect against changes in this fd */ + int timeout; /* defaults to SG_DEFAULT_TIMEOUT */ + int timeout_user; /* defaults to SG_DEFAULT_TIMEOUT_USER */ + Sg_scatter_hold reserve; /* buffer held for this file descriptor */ +@@ -166,6 +167,7 @@ typedef struct sg_fd { /* holds the sta + unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */ + char keep_orphan; /* 0 -> drop orphan (def), 1 -> keep for read() */ + char mmap_called; /* 0 -> mmap() never called on this fd */ ++ char res_in_use; /* 1 -> 'reserve' array in use */ + struct kref f_ref; + struct execute_work ew; + } Sg_fd; +@@ -209,7 +211,6 @@ static void sg_remove_sfp(struct kref *) + static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); + static Sg_request *sg_add_request(Sg_fd * sfp); + static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); +-static int sg_res_in_use(Sg_fd * sfp); + static Sg_device *sg_get_dev(int dev); + static void sg_device_destroy(struct kref *kref); + +@@ -625,6 +626,7 @@ sg_write(struct file *filp, const char _ + } + buf += SZ_SG_HEADER; + __get_user(opcode, buf); ++ mutex_lock(&sfp->f_mutex); + if (sfp->next_cmd_len > 0) { + cmd_size = sfp->next_cmd_len; + sfp->next_cmd_len = 0; /* reset so only this write() effected */ +@@ -633,6 +635,7 @@ sg_write(struct file *filp, const char _ + if ((opcode >= 0xc0) && old_hdr.twelve_byte) + cmd_size = 12; + } ++ mutex_unlock(&sfp->f_mutex); + SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp, + "sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size)); + /* Determine buffer size. */ +@@ -732,7 +735,7 @@ sg_new_write(Sg_fd *sfp, struct file *fi + sg_remove_request(sfp, srp); + return -EINVAL; /* either MMAP_IO or DIRECT_IO (not both) */ + } +- if (sg_res_in_use(sfp)) { ++ if (sfp->res_in_use) { + sg_remove_request(sfp, srp); + return -EBUSY; /* reserve buffer already being used */ + } +@@ -917,7 +920,7 @@ sg_ioctl(struct file *filp, unsigned int + return result; + if (val) { + sfp->low_dma = 1; +- if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) { ++ if ((0 == sfp->low_dma) && !sfp->res_in_use) { + val = (int) sfp->reserve.bufflen; + sg_remove_scat(sfp, &sfp->reserve); + sg_build_reserve(sfp, val); +@@ -992,12 +995,18 @@ sg_ioctl(struct file *filp, unsigned int + return -EINVAL; + val = min_t(int, val, + max_sectors_bytes(sdp->device->request_queue)); ++ mutex_lock(&sfp->f_mutex); + if (val != sfp->reserve.bufflen) { +- if (sg_res_in_use(sfp) || sfp->mmap_called) ++ if (sfp->mmap_called || ++ sfp->res_in_use) { ++ mutex_unlock(&sfp->f_mutex); + return -EBUSY; ++ } ++ + sg_remove_scat(sfp, &sfp->reserve); + sg_build_reserve(sfp, val); + } ++ mutex_unlock(&sfp->f_mutex); + return 0; + case SG_GET_RESERVED_SIZE: + val = min_t(int, sfp->reserve.bufflen, +@@ -1778,13 +1787,22 @@ sg_start_req(Sg_request *srp, unsigned c + md = &map_data; + + if (md) { +- if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen) ++ mutex_lock(&sfp->f_mutex); ++ if (dxfer_len <= rsv_schp->bufflen && ++ !sfp->res_in_use) { ++ sfp->res_in_use = 1; + sg_link_reserve(sfp, srp, dxfer_len); +- else { ++ } else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) { ++ mutex_unlock(&sfp->f_mutex); ++ return -EBUSY; ++ } else { + res = sg_build_indirect(req_schp, sfp, dxfer_len); +- if (res) ++ if (res) { ++ mutex_unlock(&sfp->f_mutex); + return res; ++ } + } ++ mutex_unlock(&sfp->f_mutex); + + md->pages = req_schp->pages; + md->page_order = req_schp->page_order; +@@ -2191,6 +2209,7 @@ sg_add_sfp(Sg_device * sdp) + rwlock_init(&sfp->rq_list_lock); + + kref_init(&sfp->f_ref); ++ mutex_init(&sfp->f_mutex); + sfp->timeout = SG_DEFAULT_TIMEOUT; + sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER; + sfp->force_packid = SG_DEF_FORCE_PACK_ID; +@@ -2266,20 +2285,6 @@ sg_remove_sfp(struct kref *kref) + schedule_work(&sfp->ew.work); + } + +-static int +-sg_res_in_use(Sg_fd * sfp) +-{ +- const Sg_request *srp; +- unsigned long iflags; +- +- read_lock_irqsave(&sfp->rq_list_lock, iflags); +- for (srp = sfp->headrp; srp; srp = srp->nextrp) +- if (srp->res_used) +- break; +- read_unlock_irqrestore(&sfp->rq_list_lock, iflags); +- return srp ? 1 : 0; +-} +- + #ifdef CONFIG_SCSI_PROC_FS + static int + sg_idr_max_id(int id, void *p, void *data) diff --git a/queue-3.18/scsi-sg-reset-res_in_use-after-unlinking-reserved-array.patch b/queue-3.18/scsi-sg-reset-res_in_use-after-unlinking-reserved-array.patch new file mode 100644 index 00000000000..d7bdacc9b9d --- /dev/null +++ b/queue-3.18/scsi-sg-reset-res_in_use-after-unlinking-reserved-array.patch @@ -0,0 +1,38 @@ +From e791ce27c3f6a1d3c746fd6a8f8e36c9540ec6f9 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Mon, 24 Apr 2017 10:26:36 +0200 +Subject: scsi: sg: reset 'res_in_use' after unlinking reserved array + +From: Hannes Reinecke + +commit e791ce27c3f6a1d3c746fd6a8f8e36c9540ec6f9 upstream. + +Once the reserved page array is unused we can reset the 'res_in_use' +state; here we can do a lazy update without holding the mutex as we only +need to check against concurrent access, not concurrent release. + +[mkp: checkpatch] + +Fixes: 1bc0eb044615 ("scsi: sg: protect accesses to 'reserved' page array") +Signed-off-by: Hannes Reinecke +Reviewed-by: Johannes Thumshirn +Reviewed-by: Christoph Hellwig +Signed-off-by: Martin K. Petersen +Cc: Todd Poynor +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/scsi/sg.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/scsi/sg.c ++++ b/drivers/scsi/sg.c +@@ -2098,6 +2098,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_reques + req_schp->sglist_len = 0; + sfp->save_scat_len = 0; + srp->res_used = 0; ++ /* Called without mutex lock to avoid deadlock */ ++ sfp->res_in_use = 0; + } + + static Sg_request * diff --git a/queue-3.18/series b/queue-3.18/series index 9b048b33317..56f17f606cd 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -14,3 +14,10 @@ mm-cma-fix-cma-aligned-offset-calculation.patch mm-cma-constify-and-use-correct-signness-in-mm-cma.c.patch mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch x86-io-add-memory-clobber-to-insb-insw-insl-outsb-outsw-outsl.patch +arm64-flush-fp-simd-state-correctly-after-execve.patch +arm64-fpsimd-prevent-registers-leaking-across-exec.patch +x86-64-handle-pc-relative-relocations-on-per-cpu-data.patch +x86-tools-fix-gcc-7-warning-in-relocs.c.patch +clk-si5351-constify-clock-names-and-struct-regmap_config.patch +scsi-sg-protect-accesses-to-reserved-page-array.patch +scsi-sg-reset-res_in_use-after-unlinking-reserved-array.patch diff --git a/queue-3.18/x86-64-handle-pc-relative-relocations-on-per-cpu-data.patch b/queue-3.18/x86-64-handle-pc-relative-relocations-on-per-cpu-data.patch new file mode 100644 index 00000000000..f40aed53a0a --- /dev/null +++ b/queue-3.18/x86-64-handle-pc-relative-relocations-on-per-cpu-data.patch @@ -0,0 +1,132 @@ +From 6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba Mon Sep 17 00:00:00 2001 +From: Jan Beulich +Date: Tue, 4 Nov 2014 08:50:18 +0000 +Subject: x86-64: Handle PC-relative relocations on per-CPU data + +From: Jan Beulich + +commit 6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba upstream. + +This is in preparation of using RIP-relative addressing in many of the +per-CPU accesses. + +Signed-off-by: Jan Beulich +Link: http://lkml.kernel.org/r/5458A15A0200007800044A9A@mail.emea.novell.com +Signed-off-by: Thomas Gleixner +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/boot/compressed/misc.c | 14 +++++++++++++- + arch/x86/tools/relocs.c | 38 ++++++++++++++++++++++++++++---------- + 2 files changed, 41 insertions(+), 11 deletions(-) + +--- a/arch/x86/boot/compressed/misc.c ++++ b/arch/x86/boot/compressed/misc.c +@@ -260,7 +260,7 @@ static void handle_relocations(void *out + + /* + * Process relocations: 32 bit relocations first then 64 bit after. +- * Two sets of binary relocations are added to the end of the kernel ++ * Three sets of binary relocations are added to the end of the kernel + * before compression. Each relocation table entry is the kernel + * address of the location which needs to be updated stored as a + * 32-bit value which is sign extended to 64 bits. +@@ -270,6 +270,8 @@ static void handle_relocations(void *out + * kernel bits... + * 0 - zero terminator for 64 bit relocations + * 64 bit relocation repeated ++ * 0 - zero terminator for inverse 32 bit relocations ++ * 32 bit inverse relocation repeated + * 0 - zero terminator for 32 bit relocations + * 32 bit relocation repeated + * +@@ -286,6 +288,16 @@ static void handle_relocations(void *out + *(uint32_t *)ptr += delta; + } + #ifdef CONFIG_X86_64 ++ while (*--reloc) { ++ long extended = *reloc; ++ extended += map; ++ ++ ptr = (unsigned long)extended; ++ if (ptr < min_addr || ptr > max_addr) ++ error("inverse 32-bit relocation outside of kernel!\n"); ++ ++ *(int32_t *)ptr -= delta; ++ } + for (reloc--; *reloc; reloc--) { + long extended = *reloc; + extended += map; +--- a/arch/x86/tools/relocs.c ++++ b/arch/x86/tools/relocs.c +@@ -20,7 +20,10 @@ struct relocs { + + static struct relocs relocs16; + static struct relocs relocs32; ++#if ELF_BITS == 64 ++static struct relocs relocs32neg; + static struct relocs relocs64; ++#endif + + struct section { + Elf_Shdr shdr; +@@ -762,11 +765,16 @@ static int do_reloc64(struct section *se + + switch (r_type) { + case R_X86_64_NONE: ++ /* NONE can be ignored. */ ++ break; ++ + case R_X86_64_PC32: + /* +- * NONE can be ignored and PC relative relocations don't +- * need to be adjusted. ++ * PC relative relocations don't need to be adjusted unless ++ * referencing a percpu symbol. + */ ++ if (is_percpu_sym(sym, symname)) ++ add_reloc(&relocs32neg, offset); + break; + + case R_X86_64_32: +@@ -986,7 +994,10 @@ static void emit_relocs(int as_text, int + /* Order the relocations for more efficient processing */ + sort_relocs(&relocs16); + sort_relocs(&relocs32); ++#if ELF_BITS == 64 ++ sort_relocs(&relocs32neg); + sort_relocs(&relocs64); ++#endif + + /* Print the relocations */ + if (as_text) { +@@ -1007,14 +1018,21 @@ static void emit_relocs(int as_text, int + for (i = 0; i < relocs32.count; i++) + write_reloc(relocs32.offset[i], stdout); + } else { +- if (ELF_BITS == 64) { +- /* Print a stop */ +- write_reloc(0, stdout); +- +- /* Now print each relocation */ +- for (i = 0; i < relocs64.count; i++) +- write_reloc(relocs64.offset[i], stdout); +- } ++#if ELF_BITS == 64 ++ /* Print a stop */ ++ write_reloc(0, stdout); ++ ++ /* Now print each relocation */ ++ for (i = 0; i < relocs64.count; i++) ++ write_reloc(relocs64.offset[i], stdout); ++ ++ /* Print a stop */ ++ write_reloc(0, stdout); ++ ++ /* Now print each inverse 32-bit relocation */ ++ for (i = 0; i < relocs32neg.count; i++) ++ write_reloc(relocs32neg.offset[i], stdout); ++#endif + + /* Print a stop */ + write_reloc(0, stdout); diff --git a/queue-3.18/x86-tools-fix-gcc-7-warning-in-relocs.c.patch b/queue-3.18/x86-tools-fix-gcc-7-warning-in-relocs.c.patch new file mode 100644 index 00000000000..310ff805550 --- /dev/null +++ b/queue-3.18/x86-tools-fix-gcc-7-warning-in-relocs.c.patch @@ -0,0 +1,54 @@ +From 7ebb916782949621ff6819acf373a06902df7679 Mon Sep 17 00:00:00 2001 +From: Markus Trippelsdorf +Date: Thu, 15 Dec 2016 13:45:13 +0100 +Subject: x86/tools: Fix gcc-7 warning in relocs.c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Markus Trippelsdorf + +commit 7ebb916782949621ff6819acf373a06902df7679 upstream. + +gcc-7 warns: + +In file included from arch/x86/tools/relocs_64.c:17:0: +arch/x86/tools/relocs.c: In function ‘process_64’: +arch/x86/tools/relocs.c:953:2: warning: argument 1 null where non-null expected [-Wnonnull] + qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from arch/x86/tools/relocs.h:6:0, + from arch/x86/tools/relocs_64.c:1: +/usr/include/stdlib.h:741:13: note: in a call to function ‘qsort’ declared here + extern void qsort + +This happens because relocs16 is not used for ELF_BITS == 64, +so there is no point in trying to sort it. + +Make the sort_relocs(&relocs16) call 32bit only. + +Signed-off-by: Markus Trippelsdorf +Link: http://lkml.kernel.org/r/20161215124513.GA289@x4 +Signed-off-by: Thomas Gleixner +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/tools/relocs.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/arch/x86/tools/relocs.c ++++ b/arch/x86/tools/relocs.c +@@ -992,11 +992,12 @@ static void emit_relocs(int as_text, int + die("Segment relocations found but --realmode not specified\n"); + + /* Order the relocations for more efficient processing */ +- sort_relocs(&relocs16); + sort_relocs(&relocs32); + #if ELF_BITS == 64 + sort_relocs(&relocs32neg); + sort_relocs(&relocs64); ++#else ++ sort_relocs(&relocs16); + #endif + + /* Print the relocations */