Skip to content

Commit acfeb6d

Browse files
zq-david-wanggregkh
authored andcommitted
Fix a potential abuse of seq_printf() format string in drivers
Using device name as format string of seq_printf() is proned to "Format string attack", opens possibility for exploitation. Seq_puts() is safer and more efficient. Signed-off-by: David Wang <00107082@163.com> Reviewed-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20241120053055.225195-1-00107082@163.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e7240bd commit acfeb6d

22 files changed

+22
-22
lines changed

drivers/gpio/gpio-aspeed-sgpio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static void aspeed_sgpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
420420
int offset;
421421

422422
irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset);
423-
seq_printf(p, dev_name(gpio->dev));
423+
seq_puts(p, dev_name(gpio->dev));
424424
}
425425

426426
static const struct irq_chip aspeed_sgpio_irq_chip = {

drivers/gpio/gpio-aspeed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ static void aspeed_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
11021102
if (rc)
11031103
return;
11041104

1105-
seq_printf(p, dev_name(gpio->dev));
1105+
seq_puts(p, dev_name(gpio->dev));
11061106
}
11071107

11081108
static const struct irq_chip aspeed_gpio_irq_chip = {

drivers/gpio/gpio-ep93xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static void ep93xx_irq_print_chip(struct irq_data *data, struct seq_file *p)
249249
{
250250
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
251251

252-
seq_printf(p, dev_name(gc->parent));
252+
seq_puts(p, dev_name(gc->parent));
253253
}
254254

255255
static const struct irq_chip gpio_eic_irq_chip = {

drivers/gpio/gpio-hlwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void hlwd_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
210210
struct hlwd_gpio *hlwd =
211211
gpiochip_get_data(irq_data_get_irq_chip_data(data));
212212

213-
seq_printf(p, dev_name(hlwd->dev));
213+
seq_puts(p, dev_name(hlwd->dev));
214214
}
215215

216216
static const struct irq_chip hlwd_gpio_irq_chip = {

drivers/gpio/gpio-mlxbf2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd,
331331
struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
332332
struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc);
333333

334-
seq_printf(p, dev_name(gs->dev));
334+
seq_puts(p, dev_name(gs->dev));
335335
}
336336

337337
static const struct irq_chip mlxbf2_gpio_irq_chip = {

drivers/gpio/gpio-omap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
715715
{
716716
struct gpio_bank *bank = omap_irq_data_get_bank(d);
717717

718-
seq_printf(p, dev_name(bank->dev));
718+
seq_puts(p, dev_name(bank->dev));
719719
}
720720

721721
static const struct irq_chip omap_gpio_irq_chip = {

drivers/gpio/gpio-pca953x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ static void pca953x_irq_print_chip(struct irq_data *data, struct seq_file *p)
815815
{
816816
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
817817

818-
seq_printf(p, dev_name(gc->parent));
818+
seq_puts(p, dev_name(gc->parent));
819819
}
820820

821821
static const struct irq_chip pca953x_irq_chip = {

drivers/gpio/gpio-pl061.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static void pl061_irq_print_chip(struct irq_data *data, struct seq_file *p)
291291
{
292292
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
293293

294-
seq_printf(p, dev_name(gc->parent));
294+
seq_puts(p, dev_name(gc->parent));
295295
}
296296

297297
static const struct irq_chip pl061_irq_chip = {

drivers/gpio/gpio-tegra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static void tegra_gpio_irq_print_chip(struct irq_data *d, struct seq_file *s)
600600
{
601601
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
602602

603-
seq_printf(s, dev_name(chip->parent));
603+
seq_puts(s, dev_name(chip->parent));
604604
}
605605

606606
static const struct irq_chip tegra_gpio_irq_chip = {

drivers/gpio/gpio-tegra186.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void tegra186_irq_print_chip(struct irq_data *data, struct seq_file *p)
610610
{
611611
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
612612

613-
seq_printf(p, dev_name(gc->parent));
613+
seq_puts(p, dev_name(gc->parent));
614614
}
615615

616616
static const struct irq_chip tegra186_gpio_irq_chip = {

0 commit comments

Comments
 (0)