• Michael Holzheu's avatar
    s390/dis: Fix handling of format specifiers · 47508cbf
    Michael Holzheu authored
    commit 272fa59c upstream.
    
    The print_insn() function returns strings like "lghi %r1,0". To escape the
    '%' character in sprintf() a second '%' is used. For example "lghi %%r1,0"
    is converted into "lghi %r1,0".
    
    After print_insn() the output string is passed to printk(). Because format
    specifiers like "%r" or "%f" are ignored by printk() this works by chance
    most of the time. But for instructions with control registers like
    "lctl %c6,%c6,780" this fails because printk() interprets "%c" as
    character format specifier.
    
    Fix this problem and escape the '%' characters twice.
    
    For example "lctl %%%%c6,%%%%c6,780" is then converted by sprintf()
    into "lctl %%c6,%%c6,780" and by printk() into "lctl %c6,%c6,780".
    Signed-off-by: default avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
    Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
    [ luis: backported to 3.16:
      - drop condition with OPERAND_VR introduced only with commit
        3585cb02 ("s390/disassembler: add vector instructions") ]
    Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
    47508cbf
dis.c 58.4 KB