Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp669194ybg; Mon, 1 Jun 2020 11:13:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG5Ft/rncSGGh6H1D0cDhmP3RaESV1nKXia8O5RX3XFji65um6Zu9HVDj98Qo+2j9HHam7 X-Received: by 2002:a05:6402:129a:: with SMTP id w26mr23549872edv.41.1591035229389; Mon, 01 Jun 2020 11:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591035229; cv=none; d=google.com; s=arc-20160816; b=Ez0PKPXmAHulYrDT4QdSr+ufAVRvkxE5e3qMRFE2F7mwZylJGFEIBQQ5hvstfN4taY JbY+wbQ7KmDIBpeJy3Bq0EV2oToiFhW50G89WbWetcOnONFVKm64CfVbmo2m+2ynOCgF VIXjnATArg2MkLWqNM0NACrUlHqHq2PEnNCeHtxD1kGcAw4dNqd4RaslH4Ss2qDlVA6N 93QRfjgUl1WjZhuC3JOIvKo+hTWmnqgPgaLLmRvkX2caxlVQjwdNRhz3YG8nTbOfLyDT jDWVDQctaeiCLCoX4fgBaQdWPnXhJ6Ex9xTSVDTwqLVv0dIM5qyfZhiwStDPGLcR0CwQ pH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fBypEOXl8CfAaM0cjCj5eWyjyoxXBQL2meFspHzO4ng=; b=wlwzi12wKmXZPdiGBMujogRoUZvJLUzGuWcqCZxT6rt3XaT2PKBNZncgGHCAlIbVCx bENN+/3Yto6Z8mT9n+OFbXH5KGoIsu+25z7QXzBnVFWssJO+9V4W+/kHw3QGDUy3HzOO cDdVzmxAfG/lFgXN5vgkCeQiDe+vtiIlwhe8YGp0Ak06CV51I+WemrXYbaSGwID0mhax seV9kuYgTHUqMDwpDsBCyBex+NdUsD7OtXFxZSWCrnsSF6q0G/UI3g/C9va5bvcgE6/K 0/parRBOP/2mSTDLR3hbv6GD2ft8rTBjm8smzAfAmKr8uvOjDfxwe1utXfCC/wC1WhMC 2qVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wvBbhTa0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si61973edq.265.2020.06.01.11.13.26; Mon, 01 Jun 2020 11:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wvBbhTa0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730757AbgFASIh (ORCPT + 99 others); Mon, 1 Jun 2020 14:08:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:54716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729123AbgFASId (ORCPT ); Mon, 1 Jun 2020 14:08:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32DED2068D; Mon, 1 Jun 2020 18:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034912; bh=9/zpqtvcvi/aDsfbxPRxBceob0fFvjcGLgPlCn/Du6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wvBbhTa09a2V8w/cAgE63CFw8OZP9cUrPMn698A48kt2Ylg8cleNStfbdv8uyyGSj Povifxa2Wpvp7EMpSSPQGm0FzBlzbBJy+mv8X4AHNT4opdofPahCg0CKK6nY6UfsQ4 9vqDNyNyxX5uB0JUQpC2fMRVe9TW2LBoR8M8p/sg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Green , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.4 069/142] Input: synaptics-rmi4 - really fix attn_data use-after-free Date: Mon, 1 Jun 2020 19:53:47 +0200 Message-Id: <20200601174044.968778830@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Evan Green [ Upstream commit d5a5e5b5fa7b86c05bf073acc0ba98fa280174ec ] Fix a use-after-free noticed by running with KASAN enabled. If rmi_irq_fn() is run twice in a row, then rmi_f11_attention() (among others) will end up reading from drvdata->attn_data.data, which was freed and left dangling in rmi_irq_fn(). Commit 55edde9fff1a ("Input: synaptics-rmi4 - prevent UAF reported by KASAN") correctly identified and analyzed this bug. However the attempted fix only NULLed out a local variable, missing the fact that drvdata->attn_data is a struct, not a pointer. NULL out the correct pointer in the driver data to prevent the attention functions from copying from it. Fixes: 55edde9fff1a ("Input: synaptics-rmi4 - prevent UAF reported by KASAN") Fixes: b908d3cd812a ("Input: synaptics-rmi4 - allow to add attention data") Signed-off-by: Evan Green Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200427145537.1.Ic8f898e0147beeee2c005ee7b20f1aebdef1e7eb@changeid Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/rmi4/rmi_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 190b9974526b..c18e1a25bca6 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -205,7 +205,7 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id) if (count) { kfree(attn_data.data); - attn_data.data = NULL; + drvdata->attn_data.data = NULL; } if (!kfifo_is_empty(&drvdata->attn_fifo)) -- 2.25.1