Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp655496iog; Thu, 30 Jun 2022 07:47:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vVeM3Nay1Ezw/Mis5Z8QS4T8EeZcBk9KN5IigEQ8innq9nX1hQzU/SDZem0Tnu47uLX72J X-Received: by 2002:a17:902:d718:b0:168:d9df:4f1c with SMTP id w24-20020a170902d71800b00168d9df4f1cmr15696845ply.41.1656600454267; Thu, 30 Jun 2022 07:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656600454; cv=none; d=google.com; s=arc-20160816; b=piXaKLI7oAC/RJ+XD9KVnpdD5W1A3tVwENVn8meO3CnLf2qC5rY2fhKXssB9wnqRUm 3TwnV3QOmM5Duoe7WhpWXdyG5nU3EigrKCYK902w+lmuD+C2AieWYGBTe8bQzKVOQVe3 1g2z/EoRKn83mryKv+KbmVBoe4v3j/W/pHuZg95hRselT1W84sLACUoItbAt0DYOBvtY rjzbJZoIFZ83aebcjuv3eL/KnyyVi7Od6jAI75fPe8Js4BxjDg6tWOiRINkIHqvD4XOc 4Qw98NXNLZNax+097e3R1z5RgEx/QKH7LA9+o6b0gA+FSQmvmXfl2tSGnLP+QHfYHDAi l/sg== 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=/MPhrVCkuKIExLRNajxwOz+/0dR2/+es0Pj3hPlfONc=; b=uw0+nAthg3y7VaqcVUJ8LRKQYMcZDO8YPVpmylQdBi0qdixBOKG4vIOsMYbQkQkK58 p5tdZ/s4XiA/IJOAiym0aadepHE7DZEoViRhcUXqW3kHTAJgOvy/ZtpjYmPbhBTCgDjv nhnFltTmiVQBINAANg0S4t49hUitZdEiXW+4uDzCLrQscyF4NViFqDV6DRg32b1DYo+Z DVlttUQhrqt52ac8L8dH7h0HLqwJoBoaPyADfL9OOwoh4hhA4azvKOo+JBhhTWCsUKaz O5UGgDnPEJCuRCyZ/LMeVZ2LVXPHc4BBKSUL9znNsdfx8cVi1bPN8iuCBFSuiv3nYE9R wbPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HcAclkdG; 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 cm26-20020a056a00339a00b0052801ed2306si4776177pfb.142.2022.06.30.07.47.22; Thu, 30 Jun 2022 07:47:34 -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=HcAclkdG; 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 S236145AbiF3OAP (ORCPT + 99 others); Thu, 30 Jun 2022 10:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236660AbiF3N7U (ORCPT ); Thu, 30 Jun 2022 09:59:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23F742EC2; Thu, 30 Jun 2022 06:52:10 -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 A072961FD8; Thu, 30 Jun 2022 13:51:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA6A5C34115; Thu, 30 Jun 2022 13:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597103; bh=3ngv5y1KHBc9HKxzKMSOQnbjIIRFR7CxefAVlV0JhG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HcAclkdGjdtGKWqbhw9mgeh1qm+pLhFyQQO/0/oevZa/dCeP1eTgWCeNR+fp/Rfmm ulIKPN4XxhMp251ap9V+1U3IfN4Z1vvNLnP07JKBZ4G+ipe3uAY2UxO5SqvipTh2mb Vyc7UnnlYIXpZxHub9XthQfErdTXfvUkeEuw5PiQ= 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 4.19 28/49] iio: trigger: sysfs: fix use-after-free on remove Date: Thu, 30 Jun 2022 15:46:41 +0200 Message-Id: <20220630133234.724968463@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133233.910803744@linuxfoundation.org> References: <20220630133233.910803744@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 @@ -198,6 +198,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);