From 6668ed271eaefaa63e686bdfbedaeb7b8e492722 Mon Sep 17 00:00:00 2001 From: Kumar Kartikeya Dwivedi Date: Fri, 4 Sep 2026 10:43:19 +0200 Subject: selftests/bpf: Reject graph kptr use after RCU unlock Add a sleepable verifier test that loads a graph-node local kptr in an explicit RCU read-side critical section, then passes its node to bpf_rbtree_remove() after the section ends. Before the verifier fix, the stale NON_OWN_REF flag makes the node look like a live borrowed reference and the program is accepted. After the fix, the pointer is demoted without NON_OWN_REF and the graph kfunc argument is rejected. Also exercise a graph kptr loaded while a spin lock provides implicit RCU protection. The pointer must be invalidated when the lock is released, which guards the required ordering between non-owning-reference invalidation and RCU demotion. Update the existing fault-protected load test state description. The post-unlock pointer no longer carries NON_OWN_REF, but remains readable because the load is rewritten to use BPF_PROBE_MEM. Signed-off-by: Kumar Kartikeya Dwivedi Link: https://lore.kernel.org/r/20260904084325.52250-7-memxor@gmail.com Signed-off-by: Alexei Starovoitov --- sound/isa/adlib.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 sound/isa/adlib.c (limited to 'sound/isa/adlib.c') diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c new file mode 100644 index 000000000..03fb2bce9 --- /dev/null +++ b/sound/isa/adlib.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * AdLib FM card driver. + */ + +#include +#include +#include +#include +#include +#include + +#define CRD_NAME "AdLib FM" +#define DEV_NAME "adlib" + +MODULE_DESCRIPTION(CRD_NAME); +MODULE_AUTHOR("Rene Herman"); +MODULE_LICENSE("GPL"); + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; +static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; +static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); +module_param_hw_array(port, long, ioport, NULL, 0444); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); + +static int snd_adlib_match(struct device *dev, unsigned int n) +{ + if (!enable[n]) + return 0; + + if (port[n] == SNDRV_AUTO_PORT) { + dev_err(dev, "please specify port\n"); + return 0; + } + return 1; +} + +static int snd_adlib_probe(struct device *dev, unsigned int n) +{ + struct snd_card *card; + struct snd_opl3 *opl3; + int error; + + error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) { + dev_err(dev, "could not create card\n"); + return error; + } + + card->private_data = devm_request_region(dev, port[n], 4, CRD_NAME); + if (!card->private_data) { + dev_err(dev, "could not grab ports\n"); + return -EBUSY; + } + + strscpy(card->driver, DEV_NAME); + strscpy(card->shortname, CRD_NAME); + sprintf(card->longname, CRD_NAME " at %#lx", port[n]); + + error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); + if (error < 0) { + dev_err(dev, "could not create OPL\n"); + return error; + } + + error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); + if (error < 0) { + dev_err(dev, "could not create FM\n"); + return error; + } + + error = snd_card_register(card); + if (error < 0) { + dev_err(dev, "could not register card\n"); + return error; + } + + dev_set_drvdata(dev, card); + return 0; +} + +static struct isa_driver snd_adlib_driver = { + .match = snd_adlib_match, + .probe = snd_adlib_probe, + + .driver = { + .name = DEV_NAME + } +}; + +module_isa_driver(snd_adlib_driver, SNDRV_CARDS); -- cgit v1.3.1