ACK: [SRU Bionic] iomap: fix WARN_ON_ONCE() from unprivileged users

Stefan Bader stefan.bader at canonical.com
Thu Sep 15 07:52:12 UTC 2022


On 08.09.22 21:03, Thadeu Lima de Souza Cascardo wrote:
> From: Qian Cai <cai at lca.pw>
> 
> BugLink: https://bugs.launchpad.net/bugs/1989144
> 
> It is trivial to trigger a WARN_ON_ONCE(1) in iomap_dio_actor() by
> unprivileged users which would taint the kernel, or worse - panic if
> panic_on_warn or panic_on_taint is set. Hence, just convert it to
> pr_warn_ratelimited() to let users know their workloads are racing.
> Thank Dave Chinner for the initial analysis of the racing reproducers.
> 
> Signed-off-by: Qian Cai <cai at lca.pw>
> Reviewed-by: Christoph Hellwig <hch at lst.de>
> Reviewed-by: Darrick J. Wong <darrick.wong at oracle.com>
> Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com>
> (backported from commit a805c111650cdba6ee880f528abdd03c1af82089)
> [cascardo: code was moved from fs/iomap.c to fs/iomap/direct-io.c]
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at canonical.com>
Acked-by: Stefan Bader <stefan.bader at canonical.com>
> ---
>   fs/iomap.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/fs/iomap.c b/fs/iomap.c
> index b66b047ac1ac..8b022e8fa0a2 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -899,6 +899,16 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
>   				use_fua = true;
>   		}
>   		break;
> +	case IOMAP_DELALLOC:
> +		/*
> +		 * DIO is not serialised against mmap() access at all, and so
> +		 * if the page_mkwrite occurs between the writeback and the
> +		 * iomap_apply() call in the DIO path, then it will see the
> +		 * DELALLOC block that the page-mkwrite allocated.
> +		 */
> +		pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD4 Comm: %.20s\n",
> +				    dio->iocb->ki_filp, current->comm);
> +		return -EIO;
>   	default:
>   		WARN_ON_ONCE(1);
>   		return -EIO;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20220915/e755a1d5/attachment.sig>


More information about the kernel-team mailing list