#! /bin/bash # (c) 2015, Quentin Casasnovas obj=$1 file ${obj} | grep -q ELF || (echo "${obj} is not and ELF file." 1>&2 ; exit 0) # Bail out early if there isn't an __ex_table section in this object file. objdump -hj __ex_table ${obj} 2> /dev/null > /dev/null [ $? -ne 0 ] && exit 0 white_list=.text,.fixup suspicious_relocs=$(objdump -rj __ex_table ${obj} | tail -n +6 | grep -v $(eval echo -e{${white_list}}) | awk '{print $3}') # No suspicious relocs in __ex_table, jobs a good'un [ -z "${suspicious_relocs}" ] && exit 0 # After this point, something is seriously wrong since we just found out we # have some relocations in __ex_table which point to sections which aren't # white listed. If you're adding a new section in the Linux kernel, and # you're expecting this section to contain code which can fault (i.e. the # __ex_table relocation to your new section is expected), simply add your # new section to the white_list variable above. If not, you're probably # doing something wrong and the rest of this code is just trying to print # you more information about it. function find_section_offset_from_symbol() { eval $(objdump -t ${obj} | grep ${1} | sed 's/\([0-9a-f]\+\) .\{7\} \([^ \t]\+\).*/section="\2"; section_offset="0x\1" /') # addr2line takes addresses in hexadecimal... section_offset=$(printf "0x%016x" $(( ${section_offset} + $2 )) ) } function find_symbol_and_offset_from_reloc() { # Extract symbol and offset from the objdump output eval $(echo $reloc | sed 's/\([^+]\+\)+\?\(0x[0-9a-f]\+\)\?/symbol="\1"; symbol_offset="\2"/') # When the relocation points to the begining of a symbol or section, it # won't print the offset since it is zero. if [ -z "${symbol_offset}" ]; then symbol_offset=0x0 fi } function find_alt_replacement_target() { # The target of the .altinstr_replacement is the relocation just before # the .altinstr_replacement one. eval $(objdump -rj .altinstructions ${obj} | grep -B1 "${section}+${section_offset}" | head -n1 | awk '{print $3}' | sed 's/\([^+]\+\)+\(0x[0-9a-f]\+\)/alt_target_section="\1"; alt_target_offset="\2"/') } function handle_alt_replacement_reloc() { # This will define alt_target_section and alt_target_section_offset find_alt_replacement_target ${section} ${section_offset} echo "Error: found a reference to .altinstr_replacement in __ex_table:" addr2line -fip -j ${alt_target_section} -e ${obj} ${alt_target_offset} | awk '{print "\t" $0}' error=true } function is_executable_section() { objdump -hwj ${section} ${obj} | grep -q CODE return $? } function handle_suspicious_generic_reloc() { if is_executable_section ${section}; then # We've got a relocation to a non white listed _executable_ # section, print a warning so the developper adds the section to # the white list or fix his code. We try to pretty-print the file # and line number where that relocation was added. echo "Warning: found a reference to section \"${section}\" in __ex_table:" addr2line -fip -j ${section} -e ${obj} ${section_offset} | awk '{print "\t" $0}' else # Something is definitively wrong here since we've got a relocation # to a non-executable section, there's no way this would ever be # running in the kernel. echo "Error: found a reference to non-executable section \"${section}\" in __ex_table at offset ${section_offset}" error=true fi } function handle_suspicious_reloc() { case "${section}" in ".altinstr_replacement") handle_alt_replacement_reloc ${section} ${section_offset} ;; *) handle_suspicious_generic_reloc ${section} ${section_offset} ;; esac } function diagnose() { for reloc in ${suspicious_relocs}; do # Let's find out where the target of the relocation in __ex_table # is, this will define ${symbol} and ${symbol_offset} find_symbol_and_offset_from_reloc ${reloc} # When there's a global symbol at the place of the relocation, # objdump will use it instead of giving us a section+offset, so # let's find out which section is this symbol in and the total # offset withing that section. find_section_offset_from_symbol ${symbol} ${symbol_offset} # In this case objdump was presenting us with a reloc to a symbol # rather than a section. Now that we've got the actual section, # we can skip it if it's in the white_list. if [ -z "$( echo $section | grep -v $(eval echo -e{${white_list}}))" ]; then continue; fi # Will either print a warning if the relocation happens to be in a # section we do not know but has executable bit set, or error out. handle_suspicious_reloc done } function check_debug_info() { objdump -hj .debug_info ${obj} 2> /dev/null > /dev/null || echo -e "${obj} does not contain debug information, the addr2line output will be limited.\n" \ "Recompile ${obj} with CONFIG_DEBUG_INFO to get a more useful output." } check_debug_info diagnose if [ "${error}" ]; then exit 1 fi exit 0 e (patch) tree98fe974ee4e20121253de7f61fc8d01bdb3821c1 /sound parent2c5d9555d6d937966d79d4c6529a5f7b9206e405 (diff)
drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj()
I've seen this trigger twice now, where the i915_gem_object_to_ggtt() call in intel_unpin_fb_obj() returns NULL, resulting in an oops immediately afterwards as the (inlined) call to i915_vma_unpin_fence() tries to dereference it. It seems to be some race condition where the object is going away at shutdown time, since both times happened when shutting down the X server. The call chains were different: - VT ioctl(KDSETMODE, KD_TEXT): intel_cleanup_plane_fb+0x5b/0xa0 [i915] drm_atomic_helper_cleanup_planes+0x6f/0x90 [drm_kms_helper] intel_atomic_commit_tail+0x749/0xfe0 [i915] intel_atomic_commit+0x3cb/0x4f0 [i915] drm_atomic_commit+0x4b/0x50 [drm] restore_fbdev_mode+0x14c/0x2a0 [drm_kms_helper] drm_fb_helper_restore_fbdev_mode_unlocked+0x34/0x80 [drm_kms_helper] drm_fb_helper_set_par+0x2d/0x60 [drm_kms_helper] intel_fbdev_set_par+0x18/0x70 [i915] fb_set_var+0x236/0x460 fbcon_blank+0x30f/0x350 do_unblank_screen+0xd2/0x1a0 vt_ioctl+0x507/0x12a0 tty_ioctl+0x355/0xc30 do_vfs_ioctl+0xa3/0x5e0 SyS_ioctl+0x79/0x90 entry_SYSCALL_64_fastpath+0x13/0x94 - i915 unpin_work workqueue: intel_unpin_work_fn+0x58/0x140 [i915] process_one_work+0x1f1/0x480 worker_thread+0x48/0x4d0 kthread+0x101/0x140 and this patch purely papers over the issue by adding a NULL pointer check and a WARN_ON_ONCE() to avoid the oops that would then generally make the machine unresponsive. Other callers of i915_gem_object_to_ggtt() seem to also check for the returned pointer being NULL and warn about it, so this clearly has happened before in other places. [ Reported it originally to the i915 developers on Jan 8, applying the ugly workaround on my own now after triggering the problem for the second time with no feedback. This is likely to be the same bug reported as https://bugs.freedesktop.org/show_bug.cgi?id=98829 https://bugs.freedesktop.org/show_bug.cgi?id=99134 which has a patch for the underlying problem, but it hasn't gotten to me, so I'm applying the workaround. ] Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Imre Deak <imre.deak@intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'sound')