Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2909805iog; Mon, 27 Jun 2022 05:34:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vj9KY5LbJ4CMc696/sHST3DHpDxM17MwLz1UlyUIrJ7DItpAN+pCdTgKZa5mHIkY8Ni6Cf X-Received: by 2002:aa7:c542:0:b0:435:75e:8a7b with SMTP id s2-20020aa7c542000000b00435075e8a7bmr16231652edr.108.1656333271541; Mon, 27 Jun 2022 05:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333271; cv=none; d=google.com; s=arc-20160816; b=PawOeGrUmAfO69wnfRAg39GCv8+sCZicFGkF5efK9bcHP6mWVouS4CYUtblY1rQPCm ObLJJhijP0G19ePI7u+Vi6lkAI+9yFHelw2AwwTUi28rq+/UJVrbuVN03/8riIb7f8DC rcT2jC/L6sQGaz8F4E1QIAlRaDmaIrBG/2CkdDaE7s6i41f4vnF2nGPI41oA9C4yJSdf cv8mujmpvfYWC4pppQ0n9WNRjy/H/LZwzQc8+wNS/34wOK8uaiUf/PLCjQk0mQhNFKzC x12EDxyogZOccbGP/eaK6Q7IN4fDiRSN4kEXQqJXnU4aKjQ1dGiykEqWu071xAcaF2Pw f+JQ== 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=arBezHiasWuQoSi5yPCEHFcPTnfqvwZd6j8KRcIUTlg=; b=t10i8W4hR/VQpeuIUYKB+X9VbHyEJcR+dVIoZzT6FK3MM2qIYwRTgq0/7ywPY8gj2u HC7Jp3DCsAO+llads3is9MrzEUTzOEbsBnPHNOKJs4DjcC0iCkKPzQ1PTGzZ419TcH4e lqAsChpw9QoQ6WR0gnn/i1f1jjHbd0Z/2jB2UCKmVUfNzdNfCuCATOLeeMtj+6nd12SN npoLMWr14PAspCAcLQOErAUUF3ijSgHFl9BIV5g6OFVwpkjtYRurkcMecfc1W1YmcK5D 5/HSpRZAyQeDfjRQrU9wsofqgM35FxK8xF2mV6IW1aBzoUEOxyLfvDc1drFJg+pumUGM QGLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tqCyvx+z; 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 w3-20020a056402268300b0042e30989df3si15004571edd.147.2022.06.27.05.34.06; Mon, 27 Jun 2022 05:34:31 -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=tqCyvx+z; 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 S239598AbiF0MAV (ORCPT + 99 others); Mon, 27 Jun 2022 08:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238891AbiF0Lwr (ORCPT ); Mon, 27 Jun 2022 07:52:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC8DDF06; Mon, 27 Jun 2022 04:46:20 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DE7B461187; Mon, 27 Jun 2022 11:46:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC150C3411D; Mon, 27 Jun 2022 11:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656330379; bh=OwvYnA7/5qDWKQi4sdQeQUk53ntcR+7QQfQTeKfoTB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqCyvx+zDGL79oGGty5h1P+klZmdDjGlur0TtU3rnAaklnj0FxgKyh6uFz+CnyWIh mDXgbLxui2vvskxhy3o/a1KOgqBQVmIhZ683zbEYU4LOeFTNdsEwNzcrFfOLVAkS3Q MotRNzYOG2Z/behMEaJCbKE7ip5xLB4dyuEGYF4M= 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.18 138/181] iio: trigger: sysfs: fix use-after-free on remove Date: Mon, 27 Jun 2022 13:21:51 +0200 Message-Id: <20220627111948.689074422@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@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 @@ -191,6 +191,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);