Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3376488ybz; Mon, 27 Apr 2020 14:57:47 -0700 (PDT) X-Google-Smtp-Source: APiQypImtTUasDM0vlGO8HJQHx6VItkAmFnYCB/gvzCotivnf0VHpjtgk/XWKQomgLcMPLqdGpUt X-Received: by 2002:a50:ea87:: with SMTP id d7mr14278014edo.48.1588024667754; Mon, 27 Apr 2020 14:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588024667; cv=none; d=google.com; s=arc-20160816; b=r06jIJHESpWtZ9Ha4RtjDCuC4CL45qRIyguDoVntyQ6yCYguNTpqjvAwA1n0Wm/6Kh PBZ7Ff2HDRmPscmlJE+WrQ0B6xrKWrx0pKJgtYyaLYw47AqbxK2F8Kfl1DOrOTB2pt5o 74GSqDDKecegMYjcAID0WIJ/zjg4rkNyrN7bMcgkfS7mwkjblgYPorUVMD+pCc1PcHSN 0In6Ad6klf8WoX9mWFHzEFMD4z+vGn30qHf+sQa7qE5G6TRKJYDS/rqZVYpmkFBJYgie kEtliyNvh+xuBR1CWWRy0018aKkQlBwRuSIot11bit39ZLMzOv+inNF5Iqfmr5qSBJUb 3mgg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=QwWrKenZ8k5J4q1qBIr58HlyfL2ByZs2Ssa6TCedrSk=; b=u7jcwW/YiVamR7trvQbxY+mdtiw2ivRyHppeeYn+MMyymzYRDGdV/a79KQFs6yUz8v EP3KbW8Dx8XQ969y91aN9GqBZ99sGZID0uHUt98ZV9a7QpSIMyc81j7uDanIgM0UjV9x PQEmV1KZo/tv8uSubAXTTvarG9uPeqSuymcvx22Wv9KTX6Su+bhANL1t/1iXts0F5aVQ 4hEGsYu6HCAcHjp0O2qg7+vPH3QHhcM4a0JwOjWPeS51Xv8gy5Sm2O8F9lgDMkcm0qO6 NsvLGC0sUBdqTlhh8KlA//HoTyulOB+dMwnN0FoMGbWOPI18mk8xxPAQuKZA1D6vggRg G0cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LbaJb+ki; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si499132ejs.504.2020.04.27.14.57.24; Mon, 27 Apr 2020 14:57:47 -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=@chromium.org header.s=google header.b=LbaJb+ki; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726262AbgD0Vzx (ORCPT + 99 others); Mon, 27 Apr 2020 17:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgD0Vzx (ORCPT ); Mon, 27 Apr 2020 17:55:53 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F606C03C1A8 for ; Mon, 27 Apr 2020 14:55:53 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p8so9299049pgi.5 for ; Mon, 27 Apr 2020 14:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QwWrKenZ8k5J4q1qBIr58HlyfL2ByZs2Ssa6TCedrSk=; b=LbaJb+ki6pK6wQO0c2DyS9Atvm8JE6MKeoBDclHbQycrzujPTZPNaK6yfuGS3UUBu/ MInl24vMoRUBTYFpBgQQbK46u9WS6P1ReSzyapOuUjnUuuNUi6RCCGHwAfTpbIGsUaQD pZuvHsXY0pF9NwVYLOImYaZhrERGyHEWxmM18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QwWrKenZ8k5J4q1qBIr58HlyfL2ByZs2Ssa6TCedrSk=; b=jf8UuRm3FIFMiFX+Qlto5DtvBeuCALCBnT/EEnc+V99An1j6/0Fb/e8SQSzIKy6r7D wuZ9upfIuYZSJcWC7fwhgdRaYVVmTDaE71zpObw9mZOtZn48+4HCOgDCa+Vofi6CptIJ kM9TmNMZOhflIX91bNyLlrqlE7N4tpI1k6H0tWHEr2SAhF5vFVSgm/OcGhCGfuHlluNG hvIQ/+qhUENY3toX13uGDiIH4CC1mITbBRbinA6jbgwXifwYzHFOnbzESmzTETerPw/n pOgYtgvdBDquhd3uY5GetTAMK6M/0xT1VYoR7XAzKw2UCLgBPizdhScJYNAEh37Kfbyj KYxA== X-Gm-Message-State: AGi0Puaz+/CiNK5BEMajSy6Y1QWV7JSjcRezoBebmQ7Evh2mFwEybghi FJxaQ3aJj/PxHDTpHMbwj4keig== X-Received: by 2002:a62:c1c1:: with SMTP id i184mr27417512pfg.18.1588024552819; Mon, 27 Apr 2020 14:55:52 -0700 (PDT) Received: from evgreen-glaptop.cheshire.ch ([2601:646:c780:1404:1c5a:73fa:6d5a:5a3c]) by smtp.gmail.com with ESMTPSA id f99sm244273pjg.22.2020.04.27.14.55.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Apr 2020 14:55:52 -0700 (PDT) From: Evan Green To: Dmitry Torokhov Cc: Evan Green , stable@vger.kernel.org, Nick Desaulniers , Allison Randal , Andrew Duggan , Benjamin Tissoires , Enrico Weigelt , Thomas Gleixner , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: synaptics-rmi4 - Really fix attn_data use-after-free Date: Mon, 27 Apr 2020 14:55:48 -0700 Message-Id: <20200427145537.1.Ic8f898e0147beeee2c005ee7b20f1aebdef1e7eb@changeid> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Nick Desaulniers --- 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 190b9974526bb..c18e1a25bca6e 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.24.1