Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5638854imu; Mon, 26 Nov 2018 03:22:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/VA8V2Od7qHIy4kl/wx/bekSMpeW9asa2/hZTcY205oJMXNoVY8u2VRlJdQT4zntjNMDV0C X-Received: by 2002:a63:e950:: with SMTP id q16mr24265824pgj.138.1543231321490; Mon, 26 Nov 2018 03:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231321; cv=none; d=google.com; s=arc-20160816; b=didzBeDHlXU++QVARZej/IVv/UNimZhVpyXPOADElJQ7R199ZPazXExWVTlSeOy4XB nhIbwMZt2nY/weC7+kbqA7xMutTcliEcWujJ36D/U7gdq/7LJB7SimODVl1CMqe2XnTu jWoWMSps+jcs7FUDkir3pWjx8SRA2o9Gc/c7Gzs082lX7sfy2Z37Kji90gNmg7pMltzz cbGAZd9gpGRgfHBj9mgTOIjESLY6PfWznPO8k9sCh0Ljb5h7oJLVtDO6IVoG51pfWTHc 0jbvrZBnYikLUPq8DO6vCu8s3jDNUQBYlQi0/Dm+4JBNGnc8HeZ+iz2k3Ja8jp0W9PMa px4A== 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=yP+FoiO3T9mXAiWB1K+OC52DT/V7Ffax+kmagrbnXFs=; b=XY5lBLXf4rgQ+D+Gh1Hsox3u+0PjM6TyoJt8bl0bnex770PztUc114sJ6U99GUZ/XP CwXFSOzaL6IdFNj4UOkDZUPP1WlHn47JwR4RZAAfPdWW431rG7jzKKemh+Dwkzi51qmR N7zPDjU85IP/SdTUrcw2RMU2mLrjL1s+L74SauLLuUUdhYCA9IiMao9pGffO7XjJUata JIWjFZzpUt/TNfZYQpM0n2DTgtim5/vnkkPcOqqiBPP1tdTRk7np2ESii/Blei/4RhZu a/0E/of/fPf6zUhhbdbScRwXmD5DJ+QlJv2qvEicgQSi0DqRXhZmMhfw9sImjsq6qfrE 4SNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="eu/6vV3H"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si31404442plq.371.2018.11.26.03.21.40; Mon, 26 Nov 2018 03:22:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="eu/6vV3H"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729264AbeKZVwO (ORCPT + 99 others); Mon, 26 Nov 2018 16:52:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:33666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727234AbeKZVwO (ORCPT ); Mon, 26 Nov 2018 16:52:14 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 AFB5B20817; Mon, 26 Nov 2018 10:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229909; bh=lSslhPl8QmoCblV4X4PUcRtx+854mbkhB8IQqHhllbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eu/6vV3HeG673NJ4hb7rgj6GNLomxtuLfzSOaNJ9AT/A33tmajNomuflXTgdwThHe g+BcIb5ldd09uQP2eRazTBDZxQiCXnh6p8s/xHU0DvUxciffu3+E8SGF6rW9qO744G vpdOeL+n0ec8xo17JKbSJwIaiDDlGTNGeZSKHmoE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Thore , Dan Carpenter Subject: [PATCH 4.9 36/46] uio: Fix an Oops on load Date: Mon, 26 Nov 2018 11:51:25 +0100 Message-Id: <20181126105049.497330716@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105045.447291262@linuxfoundation.org> References: <20181126105045.447291262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream. I was trying to solve a double free but I introduced a more serious NULL dereference bug. The problem is that if there is an IRQ which triggers immediately, then we need "info->uio_dev" but it's not set yet. This patch puts the original initialization back to how it was and just sets info->uio_dev to NULL on the error path so it should solve both the Oops and the double free. Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore Signed-off-by: Dan Carpenter Cc: stable Tested-by: Mathias Thore Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -850,6 +850,8 @@ int __uio_register_device(struct module if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; + if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) { /* * Note that we deliberately don't use devm_request_irq @@ -861,11 +863,12 @@ int __uio_register_device(struct module */ ret = request_irq(info->irq, uio_interrupt, info->irq_flags, info->name, idev); - if (ret) + if (ret) { + info->uio_dev = NULL; goto err_request_irq; + } } - info->uio_dev = idev; return 0; err_request_irq: