Fix a potential abuse of seq_printf() format string in drivers
Subsystems (14)
PATCH 1/1 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.
--- drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-)
drivers/gpio/gpio-aspeed-sgpio.c +1 -1
@@ -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)); }static const struct irq_chip aspeed_sgpio_irq_chip = {
drivers/gpio/gpio-aspeed.c +1 -1
@@ -1102,7 +1102,7 @@ static void aspeed_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)if (rc)return ; -seq_printf (p,dev_name (gpio->dev)); +seq_puts (p,dev_name (gpio->dev)); }static const struct irq_chip aspeed_gpio_irq_chip = {
drivers/gpio/gpio-ep93xx.c +1 -1
@@ -249,7 +249,7 @@ static void ep93xx_irq_print_chip(struct irq_data *data, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data); -seq_printf (p,dev_name (gc->parent)); +seq_puts (p,dev_name (gc->parent)); }static const struct irq_chip gpio_eic_irq_chip = {
drivers/gpio/gpio-hlwd.c +1 -1
@@ -210,7 +210,7 @@ static void hlwd_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)struct hlwd_gpio *hlwd =gpiochip_get_data (irq_data_get_irq_chip_data (data)); -seq_printf (p,dev_name (hlwd->dev)); +seq_puts (p,dev_name (hlwd->dev)); }static const struct irq_chip hlwd_gpio_irq_chip = {
drivers/gpio/gpio-mlxbf2.c +1 -1
@@ -331,7 +331,7 @@ static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd,struct gpio_chip *gc =irq_data_get_irq_chip_data (irqd);struct mlxbf2_gpio_context *gs =gpiochip_get_data (gc); -seq_printf (p,dev_name (gs->dev)); +seq_puts (p,dev_name (gs->dev)); }static const struct irq_chip mlxbf2_gpio_irq_chip = {
drivers/gpio/gpio-omap.c +1 -1
@@ -715,7 +715,7 @@ static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) {struct gpio_bank *bank =omap_irq_data_get_bank (d); -seq_printf (p,dev_name (bank->dev)); +seq_puts (p,dev_name (bank->dev)); }static const struct irq_chip omap_gpio_irq_chip = {
drivers/gpio/gpio-pca953x.c +1 -1
@@ -815,7 +815,7 @@ static void pca953x_irq_print_chip(struct irq_data *data, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data); -seq_printf (p,dev_name (gc->parent)); +seq_puts (p,dev_name (gc->parent)); }static const struct irq_chip pca953x_irq_chip = {
drivers/gpio/gpio-pl061.c +1 -1
@@ -291,7 +291,7 @@ static void pl061_irq_print_chip(struct irq_data *data, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data); -seq_printf (p,dev_name (gc->parent)); +seq_puts (p,dev_name (gc->parent)); }static const struct irq_chip pl061_irq_chip = {
drivers/gpio/gpio-tegra.c +1 -1
@@ -600,7 +600,7 @@ static void tegra_gpio_irq_print_chip(struct irq_data *d, struct seq_file *s) {struct gpio_chip *chip =irq_data_get_irq_chip_data (d); -seq_printf (s,dev_name (chip->parent)); +seq_puts (s,dev_name (chip->parent)); }static const struct irq_chip tegra_gpio_irq_chip = {
drivers/gpio/gpio-tegra186.c +1 -1
@@ -610,7 +610,7 @@ static void tegra186_irq_print_chip(struct irq_data *data, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data); -seq_printf (p,dev_name (gc->parent)); +seq_puts (p,dev_name (gc->parent)); }static const struct irq_chip tegra186_gpio_irq_chip = {
drivers/gpio/gpio-tqmx86.c +1 -1
@@ -275,7 +275,7 @@ static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -seq_printf (p, gc->label); +seq_puts (p, gc->label); }static const struct irq_chip tqmx86_gpio_irq_chip = {
drivers/gpio/gpio-visconti.c +1 -1
@@ -142,7 +142,7 @@ static void visconti_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct visconti_gpio *priv =gpiochip_get_data (gc); -seq_printf (p,dev_name (priv->dev)); +seq_puts (p,dev_name (priv->dev)); }static const struct irq_chip visconti_gpio_irq_chip = {
drivers/gpio/gpio-xgs-iproc.c +1 -1
@@ -198,7 +198,7 @@ static void iproc_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct iproc_gpio_chip *chip =to_iproc_gpio (gc); -seq_printf (p,dev_name (chip->dev)); +seq_puts (p,dev_name (chip->dev)); }static const struct irq_chip iproc_gpio_irq_chip = {
drivers/irqchip/irq-gic.c +1 -1
@@ -400,7 +400,7 @@ static void gic_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gic_chip_data *gic =irq_data_get_irq_chip_data (d);if (gic->domain->pm_dev) -seq_printf (p, gic->domain->pm_dev->of_node->name); +seq_puts (p, gic->domain->pm_dev->of_node->name);else seq_printf (p,"GIC-%d" , (int )(gic - &gic_data[0 ])); }
drivers/irqchip/irq-mvebu-pic.c +1 -1
@@ -71,7 +71,7 @@ static void mvebu_pic_print_chip(struct irq_data *d, struct seq_file *p) {struct mvebu_pic *pic =irq_data_get_irq_chip_data (d); -seq_printf (p,dev_name (&pic->pdev->dev)); +seq_puts (p,dev_name (&pic->pdev->dev)); }static const struct irq_chip mvebu_pic_chip = {
drivers/irqchip/irq-versatile-fpga.c +1 -1
@@ -69,7 +69,7 @@ static void fpga_irq_print_chip(struct irq_data *d, struct seq_file *p) {struct fpga_irq_data *f =irq_data_get_irq_chip_data (d); -seq_printf (p,irq_domain_get_of_node (f->domain)->name); +seq_puts (p,irq_domain_get_of_node (f->domain)->name); }static const struct irq_chip fpga_chip = {
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +1 -1
@@ -309,7 +309,7 @@ static void iproc_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct iproc_gpio *chip =gpiochip_get_data (gc); -seq_printf (p,dev_name (chip->dev)); +seq_puts (p,dev_name (chip->dev)); }static const struct irq_chip iproc_gpio_irq_chip = {
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +1 -1
@@ -734,7 +734,7 @@ static void armada_37xx_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *chip =irq_data_get_irq_chip_data (d);struct armada_37xx_pinctrl *info =gpiochip_get_data (chip); -seq_printf (p, info->data->name); +seq_puts (p, info->data->name); }static const struct irq_chip armada_37xx_irqchip = {
drivers/pinctrl/pinctrl-mcp23s08.c +1 -1
@@ -569,7 +569,7 @@ static void mcp23s08_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct mcp23s08 *mcp =gpiochip_get_data (gc); -seq_printf (p,dev_name (mcp->dev)); +seq_puts (p,dev_name (mcp->dev)); }static const struct irq_chip mcp23s08_irq_chip = {
drivers/pinctrl/pinctrl-stmfx.c +1 -1
@@ -599,7 +599,7 @@ static void stmfx_pinctrl_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gpio_chip =irq_data_get_irq_chip_data (d);struct stmfx_pinctrl *pctl =gpiochip_get_data (gpio_chip); -seq_printf (p,dev_name (pctl->dev)); +seq_puts (p,dev_name (pctl->dev)); }static const struct irq_chip stmfx_pinctrl_irq_chip = {
drivers/pinctrl/pinctrl-sx150x.c +1 -1
@@ -584,7 +584,7 @@ static void sx150x_irq_print_chip(struct irq_data *d, struct seq_file *p)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct sx150x_pinctrl *pctl =gpiochip_get_data (gc); -seq_printf (p, pctl->client->name); +seq_puts (p, pctl->client->name); }static const struct irq_chip sx150x_irq_chip = {
drivers/pinctrl/renesas/pinctrl-rzg2l.c +1 -1
@@ -2290,7 +2290,7 @@ static void rzg2l_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data); -seq_printf (p,dev_name (gc->parent)); +seq_puts (p,dev_name (gc->parent)); }static int rzg2l_gpio_irq_set_wake (struct irq_data *data,unsigned int on)
Signature · 1 line
2.39.2
Quoted 5 lines · David Wang
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 <[email protected]>
Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Quoted 14 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-
Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Then send to each subsystem maintainer and CC kees on each.
I'm just the pinctrl maintainer. The rest can be found with scripts/get_maintainer.pl.
Yours,
Linus Walleij
Quoted 34 lines · Linus Walleij
Quoted 5 lines · David Wang
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 <[email protected]>Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Quoted 14 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
Quoted 8 lines
Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Then send to each subsystem maintainer and CC kees on each.
I'm just the pinctrl maintainer. The rest can be found with
scripts/get_maintainer.pl.
Thanks for the review, I will send a patchset later.
Quoted 3 lines
Yours,
Linus Walleij
Thanks
David
Kees Cook
Reviewed-byQuoted 10 lines · Linus Walleij
Quoted 5 lines · David Wang
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 <[email protected]>Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Agreed, this may lead to kernel memory content exposures. seq_puts() looks right.
To defend against this, it might be interesting to detect single-argument seq_printf() usage and aim it at seq_puts() automatically...
Quoted 24 lines
Quoted 15 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
Quoted 8 lines
Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Then send to each subsystem maintainer and CC kees on each.
I'm just the pinctrl maintainer. The rest can be found with
scripts/get_maintainer.pl.
Oof. That's a lot of work for a mechanical change like this. Perhaps Greg KH can take it directly to the drivers tree instead?
-Kees
Signature · 1 line
Kees Cook
Quoted 9 lines · Kees Cook
Quoted 8 lines · Linus Walleij
Quoted 5 lines · David Wang
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 <[email protected]>
Quoted 7 lines
Quoted 2 lines
Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Agreed, this may lead to kernel memory content exposures.
seq_puts()looks right.Reviewed-by Kees Cook <[email protected]>
Wait, userspace "shouldn't" be controlling a device name, but odds are there are some paths/subsystems that do this, ugh.
Quoted 3 lines
To defend against this, it might be interesting to detect single-argument
seq_printf()usage and aim it atseq_puts()automatically...
Yeah, that would be good to squash this type of issue.
Quoted 26 lines
Quoted 26 lines
Quoted 14 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Quoted 8 lines
Quoted 5 lines
Then send to each subsystem maintainer and CC kees on each.
I'm just the pinctrl maintainer. The rest can be found with
scripts/get_maintainer.pl.Oof. That's a lot of work for a mechanical change like this. Perhaps Greg KH can take it directly to the drivers tree instead?
I can take it all, as-is, right now, if you want me to. Just let me know.
thanks,
greg k-h
Quoted 56 lines · Greg Kroah-Hartman
Quoted 9 lines · Kees Cook
Quoted 8 lines · Linus Walleij
Quoted 5 lines · David Wang
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 <[email protected]>Quoted 7 lines
Quoted 2 lines
Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Agreed, this may lead to kernel memory content exposures.
seq_puts()looks right.Reviewed-by Kees Cook <[email protected]>Wait, userspace "shouldn't" be controlling a device name, but odds are there are some paths/subsystems that do this, ugh.
Quoted 3 lines
To defend against this, it might be interesting to detect single-argument
seq_printf()usage and aim it atseq_puts()automatically...Yeah, that would be good to squash this type of issue.
Quoted 29 lines
Quoted 29 lines
Quoted 14 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Then send to each subsystem maintainer and CC kees on each.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I'm just the pinctrl maintainer. The rest can be found with
scripts/get_maintainer.pl.Oof. That's a lot of work for a mechanical change like this. Perhaps Greg KH can take it directly to the drivers tree instead?
I can take it all, as-is, right now, if you want me to. Just let me know.
Yes, please do. I will send a patch for making seq_printf more defensive separately.
Thanks!
-Kees
Signature · 1 line
Kees Cook
Quoted 62 lines · Kees Cook
Quoted 59 lines · Greg Kroah-Hartman
Quoted 9 lines · Kees Cook
Quoted 8 lines · Linus Walleij
Quoted 5 lines · David Wang
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 <[email protected]>Quoted 7 lines
Quoted 2 lines
Okay better get Kees' eye on this, he looks after string vulnerabilities. (But I think you're right.)
Agreed, this may lead to kernel memory content exposures.
seq_puts()looks right.Reviewed-by Kees Cook <[email protected]>Wait, userspace "shouldn't" be controlling a device name, but odds are there are some paths/subsystems that do this, ugh.
Quoted 3 lines
To defend against this, it might be interesting to detect single-argument
seq_printf()usage and aim it atseq_puts()automatically...Yeah, that would be good to squash this type of issue.
Quoted 32 lines
Quoted 31 lines
Quoted 14 lines
drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-Can you split this in three patches per-subsystem? One for gpio, one for irqchip and one for pinctrl?
Then send to each subsystem maintainer and CC kees on each.
I'm just the pinctrl maintainer. The rest can be found with
scripts/get_maintainer.pl.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Oof. That's a lot of work for a mechanical change like this. Perhaps Greg KH can take it directly to the drivers tree instead?
I can take it all, as-is, right now, if you want me to. Just let me know.
Yes, please do. I will send a patch for making
seq_printfmore defensive separately.
Great, now queued up, let's make sure 0-day is ok with it...
greg k-h
Quoted 20 lines · David Wang
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 <[email protected]>--- drivers/gpio/gpio-aspeed-sgpio.c | 2 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-hlwd.c | 2 +- drivers/gpio/gpio-mlxbf2.c | 2 +- drivers/gpio/gpio-omap.c | 2 +- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pl061.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-tegra186.c | 2 +- drivers/gpio/gpio-tqmx86.c | 2 +- drivers/gpio/gpio-visconti.c | 2 +- drivers/gpio/gpio-xgs-iproc.c | 2 +- drivers/irqchip/irq-gic.c | 2 +-
Quoted 8 lines
drivers/irqchip/irq-mvebu-pic.c | 2 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- drivers/pinctrl/pinctrl-stmfx.c | 2 +- drivers/pinctrl/pinctrl-sx150x.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
Can you please split these patches per subsystem (gpio, irqchip, pinctrl) so that the respective maintainers can pick them up individually?
Thanks,
tglx