This is the start of the stable review cycle for the 6.1.61 release.
There are 86 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Thu, 02 Nov 2023 16:59:03 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.61-rc1…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.1.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 6.1.61-rc1
John Sperbeck <jsperbeck(a)google.com>
objtool/x86: add missing embedded_insn check
Baokun Li <libaokun1(a)huawei.com>
ext4: avoid overlapping preallocations due to overflow
Baokun Li <libaokun1(a)huawei.com>
ext4: fix BUG in ext4_mb_new_inode_pa() due to overflow
Baokun Li <libaokun1(a)huawei.com>
ext4: add two helper functions extent_logical_end() and pa_logical_end()
David Lazar <dlazar(a)gmail.com>
platform/x86: Add s2idle quirk for more Lenovo laptops
Alessandro Carminati <alessandro.carminati(a)gmail.com>
clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name
Al Viro <viro(a)zeniv.linux.org.uk>
sparc32: fix a braino in fault handling in csum_and_copy_..._user()
Peter Zijlstra <peterz(a)infradead.org>
perf/core: Fix potential NULL deref
Tony Luck <tony.luck(a)intel.com>
x86/cpu: Add model number for Intel Arrow Lake mobile processor
Thomas Gleixner <tglx(a)linutronix.de>
x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility
Peng Fan <peng.fan(a)nxp.com>
nvmem: imx: correct nregs for i.MX6UL
Peng Fan <peng.fan(a)nxp.com>
nvmem: imx: correct nregs for i.MX6SLL
Peng Fan <peng.fan(a)nxp.com>
nvmem: imx: correct nregs for i.MX6ULL
Ekansh Gupta <quic_ekangupt(a)quicinc.com>
misc: fastrpc: Unmap only if buffer is unmapped from DSP
Ekansh Gupta <quic_ekangupt(a)quicinc.com>
misc: fastrpc: Clean buffers on remote invocation failures
Ekansh Gupta <quic_ekangupt(a)quicinc.com>
misc: fastrpc: Free DMA handles for RPC calls with no arguments
Ekansh Gupta <quic_ekangupt(a)quicinc.com>
misc: fastrpc: Reset metadata buffer to avoid incorrect free
Yujie Liu <yujie.liu(a)intel.com>
tracing/kprobes: Fix the description of variable length arguments
Jian Zhang <zhangjian.3032(a)bytedance.com>
i2c: aspeed: Fix i2c bus hang in slave read
Alain Volmat <alain.volmat(a)foss.st.com>
i2c: stm32f7: Fix PEC handling in case of SMBUS transfers
Herve Codina <herve.codina(a)bootlin.com>
i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node()
Herve Codina <herve.codina(a)bootlin.com>
i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node()
Herve Codina <herve.codina(a)bootlin.com>
i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node()
Robert Hancock <robert.hancock(a)calian.com>
iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale
Robert Hancock <robert.hancock(a)calian.com>
iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds
Marek Szyprowski <m.szyprowski(a)samsung.com>
iio: exynos-adc: request second interupt only when touchscreen mode is used
Linus Walleij <linus.walleij(a)linaro.org>
iio: afe: rescale: Accept only offset channels
Jens Axboe <axboe(a)kernel.dk>
io_uring/fdinfo: lock SQ thread while retrieving thread cpu/pid
Haibo Li <haibo.li(a)mediatek.com>
kasan: print the original fault addr when access invalid shadow
Khazhismel Kumykov <khazhy(a)chromium.org>
blk-throttle: check for overflow in calculate_bytes_allowed
Damien Le Moal <dlemoal(a)kernel.org>
scsi: sd: Introduce manage_shutdown device flag
Michal Schmidt <mschmidt(a)redhat.com>
iavf: in iavf_down, disable queues when removing the driver
Sui Jingfeng <suijingfeng(a)loongson.cn>
drm/logicvc: Kconfig: select REGMAP and REGMAP_MMIO
Ivan Vecera <ivecera(a)redhat.com>
i40e: Fix wrong check for I40E_TXR_FLAGS_WB_ON_ITR
Pablo Neira Ayuso <pablo(a)netfilter.org>
gtp: fix fragmentation needed check with gso
Pablo Neira Ayuso <pablo(a)netfilter.org>
gtp: uapi: fix GTPA_MAX
Fred Chen <fred.chenchen03(a)gmail.com>
tcp: fix wrong RTO timeout when received SACK reneging
Douglas Anderson <dianders(a)chromium.org>
r8152: Release firmware if we have an error in probe
Douglas Anderson <dianders(a)chromium.org>
r8152: Cancel hw_phy_work if we have an error in probe
Douglas Anderson <dianders(a)chromium.org>
r8152: Run the unload routine if we have errors during probe
Douglas Anderson <dianders(a)chromium.org>
r8152: Increase USB control msg timeout to 5000ms as per spec
Shigeru Yoshida <syoshida(a)redhat.com>
net: usb: smsc95xx: Fix uninit-value access in smsc95xx_read_reg
Christophe JAILLET <christophe.jaillet(a)wanadoo.fr>
net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
Dell Jin <dell.jin.code(a)outlook.com>
net: ethernet: adi: adin1110: Fix uninitialized variable
Sasha Neftin <sasha.neftin(a)intel.com>
igc: Fix ambiguity in the ethtool advertising
Eric Dumazet <edumazet(a)google.com>
neighbour: fix various data-races
Mateusz Palczewski <mateusz.palczewski(a)intel.com>
igb: Fix potential memory leak in igb_add_ethtool_nfc_entry
Kunwu Chan <chentao(a)kylinos.cn>
treewide: Spelling fix in comment
Ivan Vecera <ivecera(a)redhat.com>
i40e: Fix I40E_FLAG_VF_VLAN_PRUNING value
Michal Schmidt <mschmidt(a)redhat.com>
iavf: initialize waitqueues before starting watchdog_task
Mirsad Goran Todorovac <mirsad.todorovac(a)alu.unizg.hr>
r8169: fix the KCSAN reported data race in rtl_rx while reading desc->opts1
Mirsad Goran Todorovac <mirsad.todorovac(a)alu.unizg.hr>
r8169: fix the KCSAN reported data-race in rtl_tx while reading TxDescArray[entry].opts1
Mirsad Goran Todorovac <mirsad.todorovac(a)alu.unizg.hr>
r8169: fix the KCSAN reported data-race in rtl_tx() while reading tp->cur_tx
Tony Lindgren <tony(a)atomide.com>
clk: ti: Fix missing omap5 mcbsp functional clock and aliases
Tony Lindgren <tony(a)atomide.com>
clk: ti: Fix missing omap4 mcbsp functional clock and aliases
Hao Ge <gehao(a)kylinos.cn>
firmware/imx-dsp: Fix use_after_free in imx_dsp_setup_channels()
Randy Dunlap <rdunlap(a)infradead.org>
ARM: OMAP: timer32K: fix all kernel-doc warnings
Lukasz Majczak <lma(a)semihalf.com>
drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper()
Mario Limonciello <mario.limonciello(a)amd.com>
drm/amd: Disable ASPM for VI w/ all Intel systems
Umesh Nerlige Ramappa <umesh.nerlige.ramappa(a)intel.com>
drm/i915/pmu: Check if pmu is closed before stopping event
Al Viro <viro(a)zeniv.linux.org.uk>
nfsd: lock_rename() needs both directories to live on the same fs
Liam R. Howlett <Liam.Howlett(a)oracle.com>
maple_tree: add GFP_KERNEL to allocations in mas_expected_entries()
Rik van Riel <riel(a)surriel.com>
hugetlbfs: extend hugetlb_vma_lock to private VMAs
Gregory Price <gourry.memverge(a)gmail.com>
mm/migrate: fix do_pages_move for compat pointers
Kemeng Shi <shikemeng(a)huaweicloud.com>
mm/page_alloc: correct start page when guard page debug is enabled
Rik van Riel <riel(a)surriel.com>
hugetlbfs: clear resv_map pointer if mmap fails
Sebastian Ott <sebott(a)redhat.com>
mm: fix vm_brk_flags() to not bail out while holding lock
Christopher Obbard <chris.obbard(a)collabora.com>
arm64: dts: rockchip: Fix i2s0 pin conflict on ROCK Pi 4 boards
Christopher Obbard <chris.obbard(a)collabora.com>
arm64: dts: rockchip: Add i2s0-2ch-bus-bclk-off pins to RK3399
Eric Auger <eric.auger(a)redhat.com>
vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE
Alexandru Matei <alexandru.matei(a)uipath.com>
vsock/virtio: initialize the_virtio_vsock before using VQs
Xuan Zhuo <xuanzhuo(a)linux.alibaba.com>
virtio_pci: fix the common cfg map size
zhenwei pi <pizhenwei(a)bytedance.com>
virtio-crypto: handle config changed by work queue
Maximilian Heyne <mheyne(a)amazon.de>
virtio-mmio: fix memory leak of vm_dev
Gavin Shan <gshan(a)redhat.com>
virtio_balloon: Fix endless deflation and inflation on arm64
Rodríguez Barbarin, José Javier <JoseJavier.Rodriguez(a)duagon.com>
mcb-lpc: Reallocate memory region to avoid memory overlapping
Rodríguez Barbarin, José Javier <JoseJavier.Rodriguez(a)duagon.com>
mcb: Return actual parsed size when reading chameleon table
Krzysztof Kozlowski <krzysztof.kozlowski(a)linaro.org>
pinctrl: qcom: lpass-lpi: fix concurrent register updates
Johan Hovold <johan+linaro(a)kernel.org>
ASoC: codecs: wcd938x: fix runtime PM imbalance on remove
Johan Hovold <johan+linaro(a)kernel.org>
ASoC: codecs: wcd938x: fix regulator leaks on probe errors
Krzysztof Kozlowski <krzysztof.kozlowski(a)linaro.org>
ASoC: codecs: wcd938x: Simplify with dev_err_probe
Uwe Kleine-König <u.kleine-koenig(a)pengutronix.de>
ASoC: codecs: wcd938x: Convert to platform remove callback returning void
Ulf Hansson <ulf.hansson(a)linaro.org>
mmc: core: Fix error propagation for some ioctl commands
Christian Loehle <CLoehle(a)hyperstone.com>
mmc: block: ioctl: do write error check for spi
Ulf Hansson <ulf.hansson(a)linaro.org>
mmc: core: Align to common busy polling behaviour for mmc ioctls
Roman Kagan <rkagan(a)amazon.de>
KVM: x86/pmu: Truncate counter value to allowed width on write
-------------
Diffstat:
Makefile | 4 +-
arch/arm/boot/dts/omap4-l4-abe.dtsi | 6 ++
arch/arm/boot/dts/omap4-l4.dtsi | 2 +
arch/arm/boot/dts/omap5-l4-abe.dtsi | 6 ++
arch/arm/mach-omap1/timer32k.c | 14 ++---
arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 1 +
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 +++
arch/sparc/lib/checksum_32.S | 2 +-
arch/x86/include/asm/i8259.h | 2 +
arch/x86/include/asm/intel-family.h | 2 +
arch/x86/kernel/acpi/boot.c | 3 +
arch/x86/kernel/i8259.c | 38 ++++++++---
arch/x86/kvm/pmu.h | 6 ++
arch/x86/kvm/svm/pmu.c | 2 +-
arch/x86/kvm/vmx/pmu_intel.c | 4 +-
block/blk-throttle.c | 6 ++
drivers/ata/libata-scsi.c | 5 +-
drivers/clk/clk.c | 21 ++++---
drivers/clk/ti/clk-44xx.c | 5 ++
drivers/clk/ti/clk-54xx.c | 4 ++
drivers/crypto/virtio/virtio_crypto_common.h | 3 +
drivers/crypto/virtio/virtio_crypto_core.c | 14 ++++-
drivers/firewire/sbp2.c | 1 +
drivers/firmware/imx/imx-dsp.c | 2 +-
drivers/gpu/drm/amd/amdgpu/vi.c | 2 +-
drivers/gpu/drm/display/drm_dp_mst_topology.c | 6 +-
drivers/gpu/drm/i915/i915_pmu.c | 9 +++
drivers/gpu/drm/logicvc/Kconfig | 2 +
drivers/i2c/busses/i2c-aspeed.c | 3 +-
drivers/i2c/busses/i2c-stm32f7.c | 9 ++-
drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +-
drivers/i2c/muxes/i2c-mux-gpmux.c | 2 +-
drivers/i2c/muxes/i2c-mux-pinctrl.c | 2 +-
drivers/iio/adc/exynos_adc.c | 24 ++++---
drivers/iio/adc/xilinx-xadc-core.c | 39 +++++-------
drivers/iio/adc/xilinx-xadc.h | 2 +
drivers/iio/afe/iio-rescale.c | 19 ++++--
drivers/mcb/mcb-lpc.c | 35 +++++++++--
drivers/mcb/mcb-parse.c | 15 +++--
drivers/misc/fastrpc.c | 34 +++++-----
drivers/mmc/core/block.c | 38 ++++++++---
drivers/mmc/core/mmc_ops.c | 1 +
drivers/net/ethernet/adi/adin1110.c | 2 +-
drivers/net/ethernet/intel/i40e/i40e.h | 2 +-
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +-
drivers/net/ethernet/intel/iavf/iavf_main.c | 7 ++-
drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 +-
drivers/net/ethernet/intel/igc/igc_ethtool.c | 35 ++++++++---
drivers/net/ethernet/realtek/r8169_main.c | 6 +-
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c | 2 +-
drivers/net/gtp.c | 5 +-
drivers/net/ieee802154/adf7242.c | 5 +-
drivers/net/usb/r8152.c | 11 +++-
drivers/net/usb/smsc95xx.c | 4 +-
drivers/nvmem/imx-ocotp.c | 6 +-
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c | 17 +++--
drivers/platform/x86/thinkpad_acpi.c | 73 ++++++++++++++++++++++
drivers/scsi/sd.c | 39 +++++++++++-
drivers/vhost/vhost.c | 4 +-
drivers/virtio/virtio_balloon.c | 6 +-
drivers/virtio/virtio_mmio.c | 19 ++++--
drivers/virtio/virtio_pci_modern_dev.c | 2 +-
fs/ext4/mballoc.c | 51 +++++++--------
fs/ext4/mballoc.h | 14 +++++
fs/nfsd/vfs.c | 12 ++--
include/linux/hugetlb.h | 6 ++
include/linux/kasan.h | 6 +-
include/scsi/scsi_device.h | 20 +++++-
include/uapi/linux/gtp.h | 2 +-
io_uring/fdinfo.c | 18 ++++--
kernel/events/core.c | 3 +-
kernel/trace/trace_kprobe.c | 4 +-
lib/maple_tree.c | 2 +-
lib/test_maple_tree.c | 35 +++++++----
mm/hugetlb.c | 48 +++++++++++---
mm/kasan/report.c | 4 +-
mm/migrate.c | 14 ++++-
mm/mmap.c | 6 +-
mm/page_alloc.c | 2 +-
net/core/neighbour.c | 67 ++++++++++----------
net/ipv4/tcp_input.c | 9 +--
net/vmw_vsock/virtio_transport.c | 18 +++++-
sound/soc/codecs/wcd938x.c | 51 ++++++++-------
tools/include/linux/rwsem.h | 40 ++++++++++++
tools/objtool/check.c | 2 +-
85 files changed, 789 insertions(+), 305 deletions(-)
On Sun, 29 Oct 2023 at 02:16, Steven Rostedt <rostedt(a)goodmis.org> wrote:
>
> From: "Steven Rostedt (Google)" <rostedt(a)goodmis.org>
>
> The eventfs_inode (ei) is protected by SRCU, but the ei->dentry is not. It
> is protected by the eventfs_mutex. Anytime the eventfs_mutex is released,
> and access to the ei->dentry needs to be done, it should first check if
> ei->is_freed is set under the eventfs_mutex. If it is, then the ei->dentry
> is invalid and must not be used. The ei->dentry must only be accessed
> under the eventfs_mutex and after checking if ei->is_freed is set.
>
> When the ei is being freed, it will (under the eventfs_mutex) set is_freed
> and at the same time move the dentry to a free list to be cleared after
> the eventfs_mutex is released. This means that any access to the
> ei->dentry must check first if ei->is_freed is set, because if it is, then
> the dentry is on its way to be freed.
>
> Also add comments to describe this better.
>
> Link: https://lore.kernel.org/all/CA+G9fYt6pY+tMZEOg=SoEywQOe19fGP3uR15SGowkdK+_X…
> Link: https://lore.kernel.org/all/CA+G9fYuDP3hVQ3t7FfrBAjd_WFVSurMgCepTxunSJf=MTe…
>
> Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_inode")
> Reported-by: Linux Kernel Functional Testing <lkft(a)linaro.org>
> Reported-by: Naresh Kamboju <naresh.kamboju(a)linaro.org>
> Reported-by: Beau Belgrave <beaub(a)linux.microsoft.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt(a)goodmis.org>
Following build errors have been noticed.
fs/tracefs/event_inode.c:348:1: error: return type defaults to 'int'
[-Werror=implicit-int]
348 | create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
| ^~~~~~~~~~~~~~~~~
In file included from include/uapi/linux/posix_types.h:5,
from include/uapi/linux/types.h:14,
from include/linux/types.h:6,
from include/linux/kasan-checks.h:5,
from include/asm-generic/rwonce.h:26,
from ./arch/x86/include/generated/asm/rwonce.h:1,
from include/linux/compiler.h:251,
from include/linux/build_bug.h:5,
from include/linux/bits.h:21,
from include/linux/bitops.h:6,
from include/linux/radix-tree.h:11,
from include/linux/idr.h:15,
from include/linux/fsnotify_backend.h:13,
from include/linux/fsnotify.h:15,
from fs/tracefs/event_inode.c:17:
fs/tracefs/event_inode.c: In function 'create_dir_dentry':
include/linux/stddef.h:8:14: error: returning 'void *' from a function
with return type 'int' makes integer from pointer without a cast
[-Werror=int-conversion]
8 | #define NULL ((void *)0)
| ^
fs/tracefs/event_inode.c:357:24: note: in expansion of macro 'NULL'
357 | return NULL;
| ^~~~
fs/tracefs/event_inode.c:366:24: error: returning 'struct dentry *'
from a function with return type 'int' makes integer from pointer
without a cast [-Werror=int-conversion]
366 | return dentry;
| ^~~~~~
fs/tracefs/event_inode.c:394:24: error: returning 'struct dentry *'
from a function with return type 'int' makes integer from pointer
without a cast [-Werror=int-conversion]
394 | return dentry;
| ^~~~~~
fs/tracefs/event_inode.c:416:34: error: returning 'struct dentry *'
from a function with return type 'int' makes integer from pointer
without a cast [-Werror=int-conversion]
416 | return invalidate ? NULL : dentry;
| ~~~~~~~~~~~~~~~~~~^~~~~~~~
fs/tracefs/event_inode.c: In function 'dcache_dir_open_wrapper':
fs/tracefs/event_inode.c:609:49: error: passing argument 2 of
'create_dir_dentry' from incompatible pointer type
[-Werror=incompatible-pointer-types]
609 | d = create_dir_dentry(ei_child, parent, false);
| ^~~~~~
| |
| struct dentry *
fs/tracefs/event_inode.c:348:68: note: expected 'struct eventfs_inode
*' but argument is of type 'struct dentry *'
348 | create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
| ~~~~~~~~~~~~~~~~~~~~~~^~
fs/tracefs/event_inode.c:609:21: error: too few arguments to function
'create_dir_dentry'
609 | d = create_dir_dentry(ei_child, parent, false);
| ^~~~~~~~~~~~~~~~~
fs/tracefs/event_inode.c:348:1: note: declared here
348 | create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
| ^~~~~~~~~~~~~~~~~
fs/tracefs/event_inode.c:625:19: error: assignment to 'struct dentry
*' from 'int' makes pointer from integer without a cast
[-Werror=int-conversion]
625 | d = create_dir_dentry(ei, ei_child, parent, false);
| ^
fs/tracefs/event_inode.c:626:46: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
626 | parent, name, mode,
cdata, fops, false);
| ^
fs/tracefs/event_inode.c:626:52: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
626 | parent, name, mode,
cdata, fops, false);
| ^
fs/tracefs/event_inode.c:626:58: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
626 | parent, name, mode,
cdata, fops, false);
| ^
fs/tracefs/event_inode.c:626:65: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
626 | parent, name, mode,
cdata, fops, false);
| ^
fs/tracefs/event_inode.c:626:71: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
626 | parent, name, mode,
cdata, fops, false);
| ^
fs/tracefs/event_inode.c:626:71: error: statement with no effect
[-Werror=unused-value]
fs/tracefs/event_inode.c:626:78: error: expected ';' before ')' token
626 | parent, name, mode,
cdata, fops, false);
|
^
|
;
fs/tracefs/event_inode.c:626:78: error: expected statement before ')' token
fs/tracefs/event_inode.c: In function 'eventfs_remove_dir':
fs/tracefs/event_inode.c:921:1: error: invalid use of void expression
921 | + call_srcu(&eventfs_srcu, &ei->rcu, free_rcu_ei);
| ^
cc1: all warnings being treated as errors
Links:
- https://storage.tuxsuite.com/public/linaro/naresh/builds/2XQUK9V1Fm5uX0Gdoa…
> ---
>
> Changes since v1: https://lore.kernel.org/all/20231028163749.0d3429a1@rorschach.local.home/
>
> - Add comment about ei->is_freed is a union along with ei->rcu and
> ei->del_list so that others can find where ei->is_freed is set and
> not get confused about why ei->dentry is being removed but ei->is_freed
> isn't mentioned.
>
> - And fixed change log to remove the double "Reported-by".
>
> fs/tracefs/event_inode.c | 65 +++++++++++++++++++++++++++++++++-------
> fs/tracefs/internal.h | 3 +-
> 2 files changed, 56 insertions(+), 12 deletions(-)
>
> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> index 4d2da7480e5f..45bddce7c747 100644
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c
> @@ -24,7 +24,20 @@
> #include <linux/delay.h>
> #include "internal.h"
>
> +/*
> + * eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
> + * to the ei->dentry must be done under this mutex and after checking
> + * if ei->is_freed is not set. The ei->dentry is released under the
> + * mutex at the same time ei->is_freed is set. If ei->is_freed is set
> + * then the ei->dentry is invalid.
> + */
> static DEFINE_MUTEX(eventfs_mutex);
> +
> +/*
> + * The eventfs_inode (ei) itself is protected by SRCU. It is released from
> + * its parent's list and will have is_freed set (under eventfs_mutex).
> + * After the SRCU grace period is over, the ei may be freed.
> + */
> DEFINE_STATIC_SRCU(eventfs_srcu);
>
> static struct dentry *eventfs_root_lookup(struct inode *dir,
> @@ -234,6 +247,10 @@ create_file_dentry(struct eventfs_inode *ei, struct dentry **e_dentry,
> bool invalidate = false;
>
> mutex_lock(&eventfs_mutex);
> + if (ei->is_freed) {
> + mutex_unlock(&eventfs_mutex);
> + return NULL;
> + }
> /* If the e_dentry already has a dentry, use it */
> if (*e_dentry) {
> /* lookup does not need to up the ref count */
> @@ -307,6 +324,8 @@ static void eventfs_post_create_dir(struct eventfs_inode *ei)
> struct eventfs_inode *ei_child;
> struct tracefs_inode *ti;
>
> + lockdep_assert_held(&eventfs_mutex);
> +
> /* srcu lock already held */
> /* fill parent-child relation */
> list_for_each_entry_srcu(ei_child, &ei->children, list,
> @@ -320,6 +339,7 @@ static void eventfs_post_create_dir(struct eventfs_inode *ei)
>
> /**
> * create_dir_dentry - Create a directory dentry for the eventfs_inode
> + * @pei: The eventfs_inode parent of ei.
> * @ei: The eventfs_inode to create the directory for
> * @parent: The dentry of the parent of this directory
> * @lookup: True if this is called by the lookup code
> @@ -327,12 +347,17 @@ static void eventfs_post_create_dir(struct eventfs_inode *ei)
> * This creates and attaches a directory dentry to the eventfs_inode @ei.
> */
> static struct dentry *
> -create_dir_dentry(struct eventfs_inode *ei, struct dentry *parent, bool lookup)
> +create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
> + struct dentry *parent, bool lookup)
> {
> bool invalidate = false;
> struct dentry *dentry = NULL;
>
> mutex_lock(&eventfs_mutex);
> + if (pei->is_freed || ei->is_freed) {
> + mutex_unlock(&eventfs_mutex);
> + return NULL;
> + }
> if (ei->dentry) {
> /* If the dentry already has a dentry, use it */
> dentry = ei->dentry;
> @@ -435,7 +460,7 @@ static struct dentry *eventfs_root_lookup(struct inode *dir,
> */
> mutex_lock(&eventfs_mutex);
> ei = READ_ONCE(ti->private);
> - if (ei)
> + if (ei && !ei->is_freed)
> ei_dentry = READ_ONCE(ei->dentry);
> mutex_unlock(&eventfs_mutex);
>
> @@ -449,7 +474,7 @@ static struct dentry *eventfs_root_lookup(struct inode *dir,
> if (strcmp(ei_child->name, name) != 0)
> continue;
> ret = simple_lookup(dir, dentry, flags);
> - create_dir_dentry(ei_child, ei_dentry, true);
> + create_dir_dentry(ei, ei_child, ei_dentry, true);
> created = true;
> break;
> }
> @@ -583,7 +608,7 @@ static int dcache_dir_open_wrapper(struct inode *inode, struct file *file)
>
> list_for_each_entry_srcu(ei_child, &ei->children, list,
> srcu_read_lock_held(&eventfs_srcu)) {
> - d = create_dir_dentry(ei_child, parent, false);
> + d = create_dir_dentry(ei, ei_child, parent, false);
> if (d) {
> ret = add_dentries(&dentries, d, cnt);
> if (ret < 0)
> @@ -637,6 +662,13 @@ static int dcache_readdir_wrapper(struct file *file, struct dir_context *ctx)
> return ret;
> }
>
> +static void free_ei(struct eventfs_inode *ei)
> +{
> + kfree_const(ei->name);
> + kfree(ei->d_children);
> + kfree(ei);
> +}
> +
> /**
> * eventfs_create_dir - Create the eventfs_inode for this directory
> * @name: The name of the directory to create.
> @@ -700,12 +732,20 @@ struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode
> ei->nr_entries = size;
> ei->data = data;
> INIT_LIST_HEAD(&ei->children);
> + INIT_LIST_HEAD(&ei->list);
>
> mutex_lock(&eventfs_mutex);
> - list_add_tail(&ei->list, &parent->children);
> - ei->d_parent = parent->dentry;
> + if (!parent->is_freed) {
> + list_add_tail(&ei->list, &parent->children);
> + ei->d_parent = parent->dentry;
> + }
> mutex_unlock(&eventfs_mutex);
>
> + /* Was the parent freed? */
> + if (list_empty(&ei->list)) {
> + free_ei(ei);
> + ei = NULL;
> + }
> return ei;
> }
>
> @@ -787,13 +827,11 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
> return ERR_PTR(-ENOMEM);
> }
>
> -static void free_ei(struct rcu_head *head)
> +static void free_rcu_ei(struct rcu_head *head)
> {
> struct eventfs_inode *ei = container_of(head, struct eventfs_inode, rcu);
>
> - kfree_const(ei->name);
> - kfree(ei->d_children);
> - kfree(ei);
> + free_ei(ei);
> }
>
> /**
> @@ -880,7 +918,12 @@ void eventfs_remove_dir(struct eventfs_inode *ei)
> for (i = 0; i < ei->nr_entries; i++)
> unhook_dentry(&ei->d_children[i], &dentry_list);
> unhook_dentry(&ei->dentry, &dentry_list);
> - call_srcu(&eventfs_srcu, &ei->rcu, free_ei);
> + /*
> + * Note, ei->is_freed is a union along with ei->rcu
> + * and ei->del_list. When the ei is added to either
> + * of those lists, it automatically sets ei->is_freed.
> + */
> + call_srcu(&eventfs_srcu, &ei->rcu, free_rcu_ei);
> }
> mutex_unlock(&eventfs_mutex);
>
> diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h
> index 64fde9490f52..21a1fa682b74 100644
> --- a/fs/tracefs/internal.h
> +++ b/fs/tracefs/internal.h
> @@ -30,7 +30,7 @@ struct eventfs_inode {
> const struct eventfs_entry *entries;
> const char *name;
> struct list_head children;
> - struct dentry *dentry;
> + struct dentry *dentry; /* Check is_freed to access */
> struct dentry *d_parent;
> struct dentry **d_children;
> void *data;
> @@ -39,6 +39,7 @@ struct eventfs_inode {
> * @del_list: list of eventfs_inode to delete
> * @rcu: eventfs_inode to delete in RCU
> * @is_freed: node is freed if one of the above is set
> + * Note if is_freed is set, then dentry is corrupted.
> */
> union {
> struct list_head del_list;
> --
> 2.42.0
>