[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <adb55c38-fb5e-4d1b-9bf7-d29d827172b4@huawei.com>
Date: Sat, 14 Sep 2024 16:04:23 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: <kees@...nel.org>, <andy@...nel.org>, <Julia.Lawall@...ia.fr>,
<nicolas.palix@...g.fr>
CC: <linux-hardening@...r.kernel.org>, <cocci@...ia.fr>,
<lihongbo22@...wei.com>, "zhangjianhua (E)" <chris.zjh@...wei.com>
Subject: Re: [PATCH -next v3 00/10] coccinelle: Add some rules for
string_chioces helpers.
Hi,
Gently ping for this.
Thanks,
Hongbo
On 2024/9/11 9:09, Hongbo Li wrote:
> We found that many of the detection rules for helpers in
> string_choices.h are missing. This series of patches is
> intended to complete these rules. We have verified in the
> latest kernel tree that these rules can detect many places
> where the string choices helper can be used as a replacement.
>
> Here are some of the examples:
>
> ```
> drivers/gpio/gpio-mvebu.c:917:6-18: opportunity for str_lo_hi(in_pol & msk)
> drivers/pinctrl/nomadik/pinctrl-nomadik.c:1109:16-19: opportunity for str_high_low(val)
> drivers/pinctrl/nomadik/pinctrl-nomadik.c:1116:13-16: opportunity for str_high_low(val
> drivers/gpio/gpio-wcove.c:396:6-16: opportunity for str_hi_lo(ctli & 0x1)
> drivers/pci/hotplug/pnv_php.c:367:10-41: opportunity for str_on_off(state == OPAL_PCI_SLOT_POWER_ON)
> drivers/mtd/nand/raw/brcmnand/brcmnand.c:1844:40-63: opportunity for str_read_write(edu_cmd == EDU_CMD_READ)
> drivers/mtd/nand/raw/brcmnand/brcmnand.c:1437:33-35: opportunity for str_on_off(wp)
> drivers/mtd/nand/raw/brcmnand/brcmnand.c:1467:9-11: opportunity for str_on_off(wp)
> drivers/greybus/svc.c:76:9-37: opportunity for str_enabled_disabled(gb_svc_watchdog_enabled ( svc ))
> drivers/thermal/thermal_sysfs.c:59:29-36: opportunity for str_enabled_disabled(enabled)
> drivers/dma-buf/st-dma-fence.c:508:10-35: opportunity for str_yes_no(dma_fence_is_signaled ( f2 ))
> drivers/mmc/host/omap_hsmmc.c:1644:7-43: opportunity for str_enabled_disabled(host -> flags & HSMMC_SDIO_IRQ_ENABLED)
> drivers/input/mouse/elan_i2c_core.c:202:2-4: opportunity for str_on_off(on)
> drivers/macintosh/via-pmu.c:626:10-28: opportunity for str_enabled_disabled(option_server_mode)
> drivers/usb/mtu3/mtu3_debugfs.c:482:5-39: opportunity for str_on_off(regulator_is_enabled ( otg_sx -> vbus ))
> drivers/net/wireless/intel/iwlwifi/mvm/tt.c:355:4-10: opportunity for str_enable_disable(enable)
> drivers/nfc/pn544/i2c.c:215:7-20: opportunity for str_low_high(polarity == 0)
> drivers/media/tuners/tda18250.c:110:3-12: opportunity for str_true_false(triggered)
> drivers/mtd/tests/torturetest.c:191:30-35: opportunity for str_enabled_disabled(check)
> drivers/bus/intel-ixp4xx-eb.c:225:5-8: opportunity for str_enabled_disabled(val)
> drivers/net/ethernet/huawei/hinic/hinic_port.c:1133:3-9: opportunity for str_enable_disable(enable)
> drivers/net/ethernet/huawei/hinic/hinic_port.c:1245:3-9: opportunity for str_enable_disable(pfc_en)
> drivers/media/pci/cx23885/cimax2.c:227:4-8: opportunity for str_read_write(read)
> drivers/media/usb/em28xx/em28xx-video.c:941:4-9: opportunity for str_enabled_disabled(flags)
> ```
>
> Changes since v2: https://patchwork.kernel.org/project/linux-hardening/cover/20240904091451.3328272-1-lihongbo22@huawei.com/
> - Remove unnecessary outer parentheses for new rules as suggested by julia, thanks.
> - Remove unnecessary outer parentheses for old rules.
>
>
> Changes since v1: https://patchwork.kernel.org/project/linux-hardening/cover/20240829112455.232263-1-lihongbo22@huawei.com/
> - Add more rules for helpers in string_choices.h.
>
> Thanks,
> Hongbo.
>
> Hongbo Li (10):
> coccinelle: Add rules to find str_true_false() replacements
> coccinelle: Add rules to find str_false_true() replacements
> coccinelle: Add rules to find str_hi{gh}_lo{w}() replacements
> coccinelle: Add rules to find str_lo{w}_hi{gh}() replacements
> coccinelle: Add rules to find str_enable{d}_disable{d}() replacements
> coccinelle: Add rules to find str_read_write() replacements
> coccinelle: Add rules to find str_write_read() replacements
> coccinelle: Add rules to find str_on_off() replacements
> coccinelle: Add rules to find str_yes_no() replacements
> coccinelle: Remove unnecessary parentheses for only one possible
> change.
>
> scripts/coccinelle/api/string_choices.cocci | 240 +++++++++++++++++++-
> 1 file changed, 232 insertions(+), 8 deletions(-)
>
Powered by blists - more mailing lists