Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2897601iog; Mon, 27 Jun 2022 05:19:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uro7evmbpwNFoEQpeD6ltGXCBT6xIWcc0Wr4vUgzKzfjoQtj3NVjVsKuLF6OO0DfraGhNs X-Received: by 2002:a17:902:c401:b0:16a:1873:5ca3 with SMTP id k1-20020a170902c40100b0016a18735ca3mr14151588plk.157.1656332367978; Mon, 27 Jun 2022 05:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332367; cv=none; d=google.com; s=arc-20160816; b=MK+NvLP7bWmnAKqcKVtU9pO8vsvfu9pLWRWknGZWIdp4RZ7EsHUnliHzC+VrCAYNna 7a3WBiQHQvgfJzeiniAXhllYqse7S2utBpAMP/4OXqTyM+RjrM8+n/kGh02L3muoyUgr xQ97RGGXlGfpDMvjT1t4WArIJeblgyQ0cJyJwZg6N2E1DroouW2raH8XmF3BDVS58/XW JhPXdwMGL1fcX/tVvWqHzuZtxUmk1FgVotiwNnV+5t3+QqpWqMSSYnWemq1CYmBf3mmj 3+5JhbVrqCks5mEH+oVGyReha1NFgqTGyfWoCnBBkbZ4dxFLFLEQMMDXDfHVzRrPU8ys OzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AF/JFlWcyn9BXBGIyhKjgwO4nl8NENv5pS/qR2SdDDM=; b=lEDOjIS4Ox9PKc2JI0kRZryZR96ptjk6OtD9npE9qxO+3mHo7qktF9oUV5gO6kdRtY tbihhzqC3Hz9OuTuStdoEfzs/LT8FnuRBcslhwv097+13E0+aPZvTf9OI+h+BWsII48a jYKSIyOH5+Wr88KkIxRWQsHHUbEFtUvtrCgsvRAFqU4fTp3shYkrV1A4dwSYBJ39N+G2 tD6s4R4PEtjCMJCpqBZ4yLJHXEg9Er/hk+q0y/B2NBurwfwk03Y7XQodg7xw/VcQfICA m5g3VsIjRH37kEYk7ZvHEceP3ul73jBWMo4j2FTAYVWFIb5YChTMwDUY2vW2rxWrOPtl /zFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H1oWgVbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a63f253000000b0040c9e0a1ef5si13726303pgk.516.2022.06.27.05.19.16; Mon, 27 Jun 2022 05:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H1oWgVbs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235055AbiF0L1m (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235004AbiF0L0l (ORCPT ); Mon, 27 Jun 2022 07:26:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC6365A5; Mon, 27 Jun 2022 04:26:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0D71FB8111B; Mon, 27 Jun 2022 11:26:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B25C3411D; Mon, 27 Jun 2022 11:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329187; bh=d4ivODzHRCoUbS18FraA4uE1V6HELuJGshoYN4G+sEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H1oWgVbsO7H5DlOfd4JYSiCmHNwWaBr56BxjBhNNrOPdks7ASb2ImZSyC6vvKk4sf 0MNyuwQ8kb6fVavCND5wf+XWvFGA3UuLcIxhFMcxeo+IdQ7bNyWixtHvgpoTezLIXg xYqALz8evgHg5LVZ7N+u/Fcbsnz6gqCXDtyfNYoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Whitchurch , Lars-Peter Clausen , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 078/102] iio: trigger: sysfs: fix use-after-free on remove Date: Mon, 27 Jun 2022 13:21:29 +0200 Message-Id: <20220627111935.782809086@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Whitchurch commit 78601726d4a59a291acc5a52da1d3a0a6831e4e8 upstream. Ensure that the irq_work has completed before the trigger is freed. ================================================================== BUG: KASAN: use-after-free in irq_work_run_list Read of size 8 at addr 0000000064702248 by task python3/25 Call Trace: irq_work_run_list irq_work_tick update_process_times tick_sched_handle tick_sched_timer __hrtimer_run_queues hrtimer_interrupt Allocated by task 25: kmem_cache_alloc_trace iio_sysfs_trig_add dev_attr_store sysfs_kf_write kernfs_fop_write_iter new_sync_write vfs_write ksys_write sys_write Freed by task 25: kfree iio_sysfs_trig_remove dev_attr_store sysfs_kf_write kernfs_fop_write_iter new_sync_write vfs_write ksys_write sys_write ================================================================== Fixes: f38bc926d022 ("staging:iio:sysfs-trigger: Use irq_work to properly active trigger") Signed-off-by: Vincent Whitchurch Reviewed-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20220519091925.1053897-1-vincent.whitchurch@axis.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/trigger/iio-trig-sysfs.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/iio/trigger/iio-trig-sysfs.c +++ b/drivers/iio/trigger/iio-trig-sysfs.c @@ -196,6 +196,7 @@ static int iio_sysfs_trigger_remove(int } iio_trigger_unregister(t->trig); + irq_work_sync(&t->work); iio_trigger_free(t->trig); list_del(&t->l);