mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Wang" <00107082@163.com>
To: "Geert Uytterhoeven" <geert@linux-m68k.org>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, kees@kernel.org,
	 linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] gpio: Fix a potential abuse of seq_printf() format string
Date: Wed, 20 Nov 2024 19:41:43 +0800 (CST)	[thread overview]
Message-ID: <238c054f.ad0a.1934960d5fe.Coremail.00107082@163.com> (raw)
In-Reply-To: <CAMuHMdWEuWrfj3p0pX7FX6AgOKryFUnCEBRhPkhvnSEkMwThpQ@mail.gmail.com>


At 2024-11-20 19:04:39, "Geert Uytterhoeven" <geert@linux-m68k.org> wrote:
>Hi David,
>
>On Wed, Nov 20, 2024 at 10:15 AM David Wang <00107082@163.com> wrote:
>> Using device name as format string of seq_printf() is prone to
>> "Format string attack", opens possibility for exploitation.
>> Seq_puts() is safer and more efficient.
>>
>> Signed-off-by: David Wang <00107082@163.com>
>
>Thanks for your patch!
>
>> --- a/drivers/gpio/gpio-aspeed-sgpio.c
>> +++ b/drivers/gpio/gpio-aspeed-sgpio.c
>> @@ -420,7 +420,7 @@ static void aspeed_sgpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
>>         int offset;
>>
>>         irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset);
>> -       seq_printf(p, dev_name(gpio->dev));
>> +       seq_puts(p, dev_name(gpio->dev));
>
>If we want to add the missing space here, the code has to be changed
>to use seq_printf(..., " %s", ...) again.

It's kind of strange to add leading alignment spaces in a function named xxx_print_chip(); 

>
>However, it might be simpler to move this to the core. I.e. add an
>unconditional seq_putc(p, ' ') to show_interrupts()[1], and drop the
>spaces from all callbacks and from the fallbacks in show_interrupts().

I would vote for this approach,   if we want to fix  those misbehaving alignments.
It's cleaner.


>
>[1] https://elixir.bootlin.com/linux/v6.12/source/kernel/irq/proc.c#L503
>
>Gr{oetje,eeting}s,
>
>                        Geert
>
>-- 
>Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
>In personal conversations with technical people, I call myself a hacker. But
>when I'm talking to journalists I just say "programmer" or something like that.
>                                -- Linus Torvalds


Thanks~
David

      reply	other threads:[~2024-11-20 11:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20  9:14 David Wang
2024-11-20  9:17 ` [PATCH 2/3] irqchip: " David Wang
2024-12-03 11:22   ` Thomas Gleixner
2024-12-03 12:00     ` David Wang
2024-11-20  9:18 ` [PATCH 3/3] pinctrl: " David Wang
2024-11-20 11:04 ` [PATCH 1/3] gpio: " Geert Uytterhoeven
2024-11-20 11:41   ` David Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=238c054f.ad0a.1934960d5fe.Coremail.00107082@163.com \
    --to=00107082@163.com \
    --cc=brgl@bgdev.pl \
    --cc=geert@linux-m68k.org \
    --cc=kees@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®