2018-10-05 23:36:25

by Kees Cook

[permalink] [raw]
Subject: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

As done treewide earlier, this catches several more open-coded
allocation size calculations that were added to the kernel during the
merge window. This performs the following mechanical transformations
using Coccinelle:

kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)

Signed-off-by: Kees Cook <[email protected]>
---
drivers/bluetooth/hci_qca.c | 2 +-
drivers/crypto/inside-secure/safexcel.c | 8 +++++---
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +-
drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c | 4 ++--
drivers/hwmon/npcm750-pwm-fan.c | 2 +-
drivers/md/dm-integrity.c | 3 ++-
drivers/net/wireless/mediatek/mt76/usb.c | 10 +++++-----
drivers/pci/controller/pcie-cadence.c | 4 ++--
drivers/tty/serial/qcom_geni_serial.c | 4 ++--
net/sched/sch_cake.c | 2 +-
10 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index e182f6019f68..2fee65886d50 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1322,7 +1322,7 @@ static int qca_init_regulators(struct qca_power *qca,
{
int i;

- qca->vreg_bulk = devm_kzalloc(qca->dev, num_vregs *
+ qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs,
sizeof(struct regulator_bulk_data),
GFP_KERNEL);
if (!qca->vreg_bulk)
diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
index 7e71043457a6..86c699c14f84 100644
--- a/drivers/crypto/inside-secure/safexcel.c
+++ b/drivers/crypto/inside-secure/safexcel.c
@@ -1044,7 +1044,8 @@ static int safexcel_probe(struct platform_device *pdev)

safexcel_configure(priv);

- priv->ring = devm_kzalloc(dev, priv->config.rings * sizeof(*priv->ring),
+ priv->ring = devm_kcalloc(dev, priv->config.rings,
+ sizeof(*priv->ring),
GFP_KERNEL);
if (!priv->ring) {
ret = -ENOMEM;
@@ -1063,8 +1064,9 @@ static int safexcel_probe(struct platform_device *pdev)
if (ret)
goto err_reg_clk;

- priv->ring[i].rdr_req = devm_kzalloc(dev,
- sizeof(priv->ring[i].rdr_req) * EIP197_DEFAULT_RING_SIZE,
+ priv->ring[i].rdr_req = devm_kcalloc(dev,
+ EIP197_DEFAULT_RING_SIZE,
+ sizeof(priv->ring[i].rdr_req),
GFP_KERNEL);
if (!priv->ring[i].rdr_req) {
ret = -ENOMEM;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 0b976dfd04df..92ecb9bf982c 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -600,7 +600,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
}

mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]);
- mtk_crtc->planes = devm_kzalloc(dev, mtk_crtc->layer_nr *
+ mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr,
sizeof(struct drm_plane),
GFP_KERNEL);

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
index 790d39f816dc..b557687b1964 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
@@ -153,8 +153,8 @@ int msm_dss_parse_clock(struct platform_device *pdev,
return 0;
}

- mp->clk_config = devm_kzalloc(&pdev->dev,
- sizeof(struct dss_clk) * num_clk,
+ mp->clk_config = devm_kcalloc(&pdev->dev,
+ num_clk, sizeof(struct dss_clk),
GFP_KERNEL);
if (!mp->clk_config)
return -ENOMEM;
diff --git a/drivers/hwmon/npcm750-pwm-fan.c b/drivers/hwmon/npcm750-pwm-fan.c
index 8474d601aa63..b998f9fbed41 100644
--- a/drivers/hwmon/npcm750-pwm-fan.c
+++ b/drivers/hwmon/npcm750-pwm-fan.c
@@ -908,7 +908,7 @@ static int npcm7xx_en_pwm_fan(struct device *dev,
if (fan_cnt < 1)
return -EINVAL;

- fan_ch = devm_kzalloc(dev, sizeof(*fan_ch) * fan_cnt, GFP_KERNEL);
+ fan_ch = devm_kcalloc(dev, fan_cnt, sizeof(*fan_ch), GFP_KERNEL);
if (!fan_ch)
return -ENOMEM;

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 89ccb64342de..e1fa6baf4e8e 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3462,7 +3462,8 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -ENOMEM;
goto bad;
}
- ic->recalc_tags = kvmalloc((RECALC_SECTORS >> ic->sb->log2_sectors_per_block) * ic->tag_size, GFP_KERNEL);
+ ic->recalc_tags = kvmalloc_array(RECALC_SECTORS >> ic->sb->log2_sectors_per_block,
+ ic->tag_size, GFP_KERNEL);
if (!ic->recalc_tags) {
ti->error = "Cannot allocate tags for recalculating";
r = -ENOMEM;
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 7780b07543bb..79e59f2379a2 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -258,7 +258,7 @@ int mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf,
if (!buf->urb)
return -ENOMEM;

- buf->urb->sg = devm_kzalloc(dev->dev, nsgs * sizeof(*buf->urb->sg),
+ buf->urb->sg = devm_kcalloc(dev->dev, nsgs, sizeof(*buf->urb->sg),
gfp);
if (!buf->urb->sg)
return -ENOMEM;
@@ -464,8 +464,8 @@ static int mt76u_alloc_rx(struct mt76_dev *dev)
int i, err, nsgs;

spin_lock_init(&q->lock);
- q->entry = devm_kzalloc(dev->dev,
- MT_NUM_RX_ENTRIES * sizeof(*q->entry),
+ q->entry = devm_kcalloc(dev->dev,
+ MT_NUM_RX_ENTRIES, sizeof(*q->entry),
GFP_KERNEL);
if (!q->entry)
return -ENOMEM;
@@ -717,8 +717,8 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
INIT_LIST_HEAD(&q->swq);
q->hw_idx = q2hwq(i);

- q->entry = devm_kzalloc(dev->dev,
- MT_NUM_TX_ENTRIES * sizeof(*q->entry),
+ q->entry = devm_kcalloc(dev->dev,
+ MT_NUM_TX_ENTRIES, sizeof(*q->entry),
GFP_KERNEL);
if (!q->entry)
return -ENOMEM;
diff --git a/drivers/pci/controller/pcie-cadence.c b/drivers/pci/controller/pcie-cadence.c
index 86f1b002c846..975bcdd6b5c0 100644
--- a/drivers/pci/controller/pcie-cadence.c
+++ b/drivers/pci/controller/pcie-cadence.c
@@ -180,11 +180,11 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
return 0;
}

- phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
+ phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;

- link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
+ link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
if (!link)
return -ENOMEM;

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 29ec34387246..1515074e18fb 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -868,8 +868,8 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport)
geni_se_init(&port->se, port->rx_wm, port->rx_rfr);
geni_se_select_mode(&port->se, port->xfer_mode);
if (!uart_console(uport)) {
- port->rx_fifo = devm_kzalloc(uport->dev,
- port->rx_fifo_depth * sizeof(u32), GFP_KERNEL);
+ port->rx_fifo = devm_kcalloc(uport->dev,
+ port->rx_fifo_depth, sizeof(u32), GFP_KERNEL);
if (!port->rx_fifo)
return -ENOMEM;
}
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index c07c30b916d5..793016d722ec 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2644,7 +2644,7 @@ static int cake_init(struct Qdisc *sch, struct nlattr *opt,
for (i = 1; i <= CAKE_QUEUES; i++)
quantum_div[i] = 65535 / i;

- q->tins = kvzalloc(CAKE_MAX_TINS * sizeof(struct cake_tin_data),
+ q->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data),
GFP_KERNEL);
if (!q->tins)
goto nomem;
--
2.17.1


--
Kees Cook
Pixel Security


2018-10-05 23:52:02

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote:
> As done treewide earlier, this catches several more open-coded
> allocation size calculations that were added to the kernel during the
> merge window. This performs the following mechanical transformations
> using Coccinelle:
>
> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
>
> Signed-off-by: Kees Cook <[email protected]>

Has this had any testing in linux-next?

And when was "earlier"?

thanks,

greg k-h

2018-10-06 00:06:12

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Fri, Oct 5, 2018 at 4:51 PM, Greg KH <[email protected]> wrote:
> On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote:
>> As done treewide earlier, this catches several more open-coded
>> allocation size calculations that were added to the kernel during the
>> merge window. This performs the following mechanical transformations
>> using Coccinelle:
>>
>> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
>> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
>> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
>>
>> Signed-off-by: Kees Cook <[email protected]>
>
> Has this had any testing in linux-next?

No; they're mechanical transformations (though I did build test them).
If you want I could add this to linux-next for a week?

> And when was "earlier"?

v4.18, when all of these were originally eliminated:

026f05079b00 treewide: Use array_size() in f2fs_kzalloc()
c86065938aab treewide: Use array_size() in f2fs_kmalloc()
76e43e37a407 treewide: Use array_size() in sock_kmalloc()
84ca176bf54a treewide: Use array_size() in kvzalloc_node()
fd7becedb1f0 treewide: Use array_size() in vzalloc_node()
fad953ce0b22 treewide: Use array_size() in vzalloc()
42bc47b35320 treewide: Use array_size() in vmalloc()
a86854d0c599 treewide: devm_kzalloc() -> devm_kcalloc()
3c4211ba8ad8 treewide: devm_kmalloc() -> devm_kmalloc_array()
778e1cdd81bb treewide: kvzalloc() -> kvcalloc()
344476e16acb treewide: kvmalloc() -> kvmalloc_array()
590b5b7d8671 treewide: kzalloc_node() -> kcalloc_node()
6396bb221514 treewide: kzalloc() -> kcalloc()
6da2ec56059c treewide: kmalloc() -> kmalloc_array()

The new patch is catching new open-coded multiplications introduced in v4.19.

-Kees

--
Kees Cook
Pixel Security

2018-10-06 00:23:59

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Fri, Oct 05, 2018 at 05:04:16PM -0700, Kees Cook wrote:
> On Fri, Oct 5, 2018 at 4:51 PM, Greg KH <[email protected]> wrote:
> > On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote:
> >> As done treewide earlier, this catches several more open-coded
> >> allocation size calculations that were added to the kernel during the
> >> merge window. This performs the following mechanical transformations
> >> using Coccinelle:
> >>
> >> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
> >> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
> >> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
> >>
> >> Signed-off-by: Kees Cook <[email protected]>
> >
> > Has this had any testing in linux-next?
>
> No; they're mechanical transformations (though I did build test them).
> If you want I could add this to linux-next for a week?

That would be good, thanks.

> > And when was "earlier"?
>
> v4.18, when all of these were originally eliminated:
>
> 026f05079b00 treewide: Use array_size() in f2fs_kzalloc()
> c86065938aab treewide: Use array_size() in f2fs_kmalloc()
> 76e43e37a407 treewide: Use array_size() in sock_kmalloc()
> 84ca176bf54a treewide: Use array_size() in kvzalloc_node()
> fd7becedb1f0 treewide: Use array_size() in vzalloc_node()
> fad953ce0b22 treewide: Use array_size() in vzalloc()
> 42bc47b35320 treewide: Use array_size() in vmalloc()
> a86854d0c599 treewide: devm_kzalloc() -> devm_kcalloc()
> 3c4211ba8ad8 treewide: devm_kmalloc() -> devm_kmalloc_array()
> 778e1cdd81bb treewide: kvzalloc() -> kvcalloc()
> 344476e16acb treewide: kvmalloc() -> kvmalloc_array()
> 590b5b7d8671 treewide: kzalloc_node() -> kcalloc_node()
> 6396bb221514 treewide: kzalloc() -> kcalloc()
> 6da2ec56059c treewide: kmalloc() -> kmalloc_array()
>
> The new patch is catching new open-coded multiplications introduced in v4.19.

As this is getting smaller, why not just break it up and do it through
all of the different subsystems instead of one large patch?

And do we have a way to add a rule to 0-day to catch these so that they
get a warning when they are added again?

thanks,

greg k-h

2018-10-06 03:19:22

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Fri, Oct 05, 2018 at 05:22:35PM -0700, Greg KH wrote:
> On Fri, Oct 05, 2018 at 05:04:16PM -0700, Kees Cook wrote:
> > On Fri, Oct 5, 2018 at 4:51 PM, Greg KH <[email protected]> wrote:
> > > On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote:
> > >> As done treewide earlier, this catches several more open-coded
> > >> allocation size calculations that were added to the kernel during the
> > >> merge window. This performs the following mechanical transformations
> > >> using Coccinelle:
> > >>
> > >> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
> > >> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
> > >> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
> > >>
> > >> Signed-off-by: Kees Cook <[email protected]>
> > >
> > > Has this had any testing in linux-next?
> >
> > No; they're mechanical transformations (though I did build test them).
> > If you want I could add this to linux-next for a week?
>
> That would be good, thanks.
>
> > > And when was "earlier"?
> >
> > v4.18, when all of these were originally eliminated:
> >
> > 026f05079b00 treewide: Use array_size() in f2fs_kzalloc()
> > c86065938aab treewide: Use array_size() in f2fs_kmalloc()
> > 76e43e37a407 treewide: Use array_size() in sock_kmalloc()
> > 84ca176bf54a treewide: Use array_size() in kvzalloc_node()
> > fd7becedb1f0 treewide: Use array_size() in vzalloc_node()
> > fad953ce0b22 treewide: Use array_size() in vzalloc()
> > 42bc47b35320 treewide: Use array_size() in vmalloc()
> > a86854d0c599 treewide: devm_kzalloc() -> devm_kcalloc()
> > 3c4211ba8ad8 treewide: devm_kmalloc() -> devm_kmalloc_array()
> > 778e1cdd81bb treewide: kvzalloc() -> kvcalloc()
> > 344476e16acb treewide: kvmalloc() -> kvmalloc_array()
> > 590b5b7d8671 treewide: kzalloc_node() -> kcalloc_node()
> > 6396bb221514 treewide: kzalloc() -> kcalloc()
> > 6da2ec56059c treewide: kmalloc() -> kmalloc_array()
> >
> > The new patch is catching new open-coded multiplications introduced in v4.19.
>
> As this is getting smaller, why not just break it up and do it through
> all of the different subsystems instead of one large patch?
>
> And do we have a way to add a rule to 0-day to catch these so that they
> get a warning when they are added again?

They could just be added to scripts/coccinelle and 0-day will report them?

For example, 0-day ran scripts/coccinelle/api/platform_no_drv_owner.cocci on
a recently submitted patch and reported it here:
https://lore.kernel.org/lkml/201808301856.vMNJerSs%[email protected]/

But I'm not sure if 0-day runs make coccicheck on specific semantic patches,
or runs all of them (CC'd Fengguang).

thanks,

- Joel


2018-10-06 08:51:20

by Fengguang Wu

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Fri, Oct 05, 2018 at 08:14:34PM -0700, Joel Fernandes wrote:
>On Fri, Oct 05, 2018 at 05:22:35PM -0700, Greg KH wrote:
>> On Fri, Oct 05, 2018 at 05:04:16PM -0700, Kees Cook wrote:
>> > On Fri, Oct 5, 2018 at 4:51 PM, Greg KH <[email protected]> wrote:
>> > > On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote:
>> > >> As done treewide earlier, this catches several more open-coded
>> > >> allocation size calculations that were added to the kernel during the
>> > >> merge window. This performs the following mechanical transformations
>> > >> using Coccinelle:
>> > >>
>> > >> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
>> > >> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
>> > >> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
>> > >>
>> > >> Signed-off-by: Kees Cook <[email protected]>
>> > >
>> > > Has this had any testing in linux-next?
>> >
>> > No; they're mechanical transformations (though I did build test them).
>> > If you want I could add this to linux-next for a week?
>>
>> That would be good, thanks.
>>
>> > > And when was "earlier"?
>> >
>> > v4.18, when all of these were originally eliminated:
>> >
>> > 026f05079b00 treewide: Use array_size() in f2fs_kzalloc()
>> > c86065938aab treewide: Use array_size() in f2fs_kmalloc()
>> > 76e43e37a407 treewide: Use array_size() in sock_kmalloc()
>> > 84ca176bf54a treewide: Use array_size() in kvzalloc_node()
>> > fd7becedb1f0 treewide: Use array_size() in vzalloc_node()
>> > fad953ce0b22 treewide: Use array_size() in vzalloc()
>> > 42bc47b35320 treewide: Use array_size() in vmalloc()
>> > a86854d0c599 treewide: devm_kzalloc() -> devm_kcalloc()
>> > 3c4211ba8ad8 treewide: devm_kmalloc() -> devm_kmalloc_array()
>> > 778e1cdd81bb treewide: kvzalloc() -> kvcalloc()
>> > 344476e16acb treewide: kvmalloc() -> kvmalloc_array()
>> > 590b5b7d8671 treewide: kzalloc_node() -> kcalloc_node()
>> > 6396bb221514 treewide: kzalloc() -> kcalloc()
>> > 6da2ec56059c treewide: kmalloc() -> kmalloc_array()
>> >
>> > The new patch is catching new open-coded multiplications introduced in v4.19.
>>
>> As this is getting smaller, why not just break it up and do it through
>> all of the different subsystems instead of one large patch?
>>
>> And do we have a way to add a rule to 0-day to catch these so that they
>> get a warning when they are added again?
>
>They could just be added to scripts/coccinelle and 0-day will report them?
>
>For example, 0-day ran scripts/coccinelle/api/platform_no_drv_owner.cocci on
>a recently submitted patch and reported it here:
>https://lore.kernel.org/lkml/201808301856.vMNJerSs%[email protected]/
>
>But I'm not sure if 0-day runs make coccicheck on specific semantic patches,
>or runs all of them (CC'd Fengguang).

0-day runs all coccinelle scripts. However only auto report out
warnings that are known to have low false positives.

So if you add new coccinelle scripts that emit accurate enough
warnings, it'd be good to inform the LKP team to add the new
warnings to our auto-report-out white list.

Thanks,
Fengguang

2018-10-06 15:51:49

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Sat, Oct 6, 2018 at 1:49 AM, Fengguang Wu <[email protected]> wrote:
> On Fri, Oct 05, 2018 at 08:14:34PM -0700, Joel Fernandes wrote:
>>
>> On Fri, Oct 05, 2018 at 05:22:35PM -0700, Greg KH wrote:
>>> And do we have a way to add a rule to 0-day to catch these so that they
>>> get a warning when they are added again?
>>
>>
>> They could just be added to scripts/coccinelle and 0-day will report them?
>>
>> For example, 0-day ran scripts/coccinelle/api/platform_no_drv_owner.cocci
>> on
>> a recently submitted patch and reported it here:
>>
>> https://lore.kernel.org/lkml/201808301856.vMNJerSs%[email protected]/
>>
>> But I'm not sure if 0-day runs make coccicheck on specific semantic
>> patches,
>> or runs all of them (CC'd Fengguang).
>
> 0-day runs all coccinelle scripts. However only auto report out
> warnings that are known to have low false positives.
>
> So if you add new coccinelle scripts that emit accurate enough
> warnings, it'd be good to inform the LKP team to add the new
> warnings to our auto-report-out white list.

It runs with MODE=report by default, yes? I'd need to expand the cases
to cover that (it is patch-only currently) so that would be a roughly
10,000 line Coccinelle script. :)

-Kees

--
Kees Cook
Pixel Security

2018-10-07 01:29:37

by Fengguang Wu

[permalink] [raw]
Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications

On Sat, Oct 06, 2018 at 08:51:16AM -0700, Kees Cook wrote:
>On Sat, Oct 6, 2018 at 1:49 AM, Fengguang Wu <[email protected]> wrote:
>> On Fri, Oct 05, 2018 at 08:14:34PM -0700, Joel Fernandes wrote:
>>>
>>> On Fri, Oct 05, 2018 at 05:22:35PM -0700, Greg KH wrote:
>>>> And do we have a way to add a rule to 0-day to catch these so that they
>>>> get a warning when they are added again?
>>>
>>>
>>> They could just be added to scripts/coccinelle and 0-day will report them?
>>>
>>> For example, 0-day ran scripts/coccinelle/api/platform_no_drv_owner.cocci
>>> on
>>> a recently submitted patch and reported it here:
>>>
>>> https://lore.kernel.org/lkml/201808301856.vMNJerSs%[email protected]/
>>>
>>> But I'm not sure if 0-day runs make coccicheck on specific semantic
>>> patches,
>>> or runs all of them (CC'd Fengguang).
>>
>> 0-day runs all coccinelle scripts. However only auto report out
>> warnings that are known to have low false positives.
>>
>> So if you add new coccinelle scripts that emit accurate enough
>> warnings, it'd be good to inform the LKP team to add the new
>> warnings to our auto-report-out white list.
>
>It runs with MODE=report by default, yes? I'd need to expand the cases
>to cover that (it is patch-only currently) so that would be a roughly
>10,000 line Coccinelle script. :)

It first runs with "-D report", then with "-D patch" to create
possible patches.

Thanks,
Fengguang