Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp349837img; Thu, 21 Mar 2019 22:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVPk6bi8fUI2/Ys5y/iUt37J3wO1KSS96fei6i09VghGl4lxNq2EQTzZYiIFCwbc5YcjDX X-Received: by 2002:a63:fc64:: with SMTP id r36mr7183819pgk.280.1553233029333; Thu, 21 Mar 2019 22:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553233029; cv=none; d=google.com; s=arc-20160816; b=lqAw33Pd0+OQPjEbUCr/7FKqnvqtzoLZIQ6ov9EgiujWR6ABmWnfBuT/D+4qLu+9nE Rryg3S9NVXdf3ssyotg3PUrvWYV4VI2gX0HQl75ELjEpDEc2s68ez0Ol8tvcbKI6R7qi vl/rumDmWk+q81RLbLA1nvPGh8sZaWUBLNMgUEBC5/H+RSBmicbFJxUW1aBg5tNo7bMu cu70TD6GE6xSPmCTFdLnhhpoIZ52+QX8oCPjuuVMahvvDOkwO+GhhDwQ66QC8viNeict yTSW8j0zUBgkTEuy5IfVrx8bnkvGR2v3NRyIfH1MCFV2zwC/EvEtVXXwS4oABvfV85tM +Olg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zIlsw9/6sv+qAjE2Jy7IDxkHmGY4ygi+XwFNoH83fFc=; b=VTj+OSUVlJVTZxY+mLeSHI8xJRce5bz8py+O9jwyCfRWdY7mTS+LEE9HQphsDBNsQa xvldvnq4FzwZH5nQMPm7kAYhYc4ISJ3RHvDwy12d+Lvk1DAY4iku7FWZO8DmVNmIECgw 3fhT7YBqHPV26L0FIg0tIHFQrTpWhmJ2a6oUQQwjBvsxDZ/c1EopW1aMZO7QB2kSnJ3f eh5B4oYlTwxirZTDv0fH0mXnaup2iwdUWK/CSTbTzCPG8cAiaPoIcvHyTQhutlpVZvn9 vB5KIzGq4LsWtu5RqRZul67ETNPSAk8GdNGPqM7lY/ZEGe2WcFZ+Bef8eH+NuwLz85Df Bytw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u7ihKpvy; 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 x15si6027302pgq.194.2019.03.21.22.36.54; Thu, 21 Mar 2019 22:37:09 -0700 (PDT) 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=u7ihKpvy; 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 S1727706AbfCVFgH (ORCPT + 99 others); Fri, 22 Mar 2019 01:36:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:45366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfCVFgH (ORCPT ); Fri, 22 Mar 2019 01:36:07 -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 60580218B0; Fri, 22 Mar 2019 05:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553232965; bh=mX++0dd0hjObisk5SEXrUW7udMc7ZLafaRpSFFqF/FE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u7ihKpvycdNKRXBe9HgslhWBlq4OmYVUF7bsXw9uARp3JPivf9LWNI3S48FLQy433 +L2pDe+dD1TaGFH9bGVt2njlzDm5FLFgqRDyXW/sIi0sTsGUg1ZRGJFxtBs6Q3WMZV 52tPfnPl6S0I3zSQgW3yZOlk53RRkzpDPKBJWGuA= Date: Fri, 22 Mar 2019 06:36:02 +0100 From: Greg KH To: fei.yang@intel.com Cc: balbi@kernel.org, andrzej.p@collabora.com, plr.vincent@gmail.com, jingx.shen@intel.com, john.stultz@linaro.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] usb: gadget: f_fs: don't free buffer prematurely Message-ID: <20190322053602.GA31708@kroah.com> References: <1553203874-130203-1-git-send-email-fei.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1553203874-130203-1-git-send-email-fei.yang@intel.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 02:31:14PM -0700, fei.yang@intel.com wrote: > From: Fei Yang > > The following kernel panic happens due to the io_data buffer gets deallocated > before the async io is completed. Add a check for the case where io_data buffer > should be deallocated by ffs_user_copy_worker. > > [ 41.663334] BUG: unable to handle kernel NULL pointer dereference at 0000000000000048 > [ 41.672099] #PF error: [normal kernel read fault] > [ 41.677356] PGD 20c974067 P4D 20c974067 PUD 20c973067 PMD 0 > [ 41.683687] Oops: 0000 [#1] PREEMPT SMP > [ 41.687976] CPU: 1 PID: 7 Comm: kworker/u8:0 Tainted: G U 5.0.0-quilt-2e5dc0ac-00790-gd8c79f2-dirty #2 > [ 41.705309] Workqueue: adb ffs_user_copy_worker > [ 41.705316] RIP: 0010:__vunmap+0x2a/0xc0 > [ 41.705318] Code: 0f 1f 44 00 00 48 85 ff 0f 84 87 00 00 00 55 f7 c7 ff 0f 00 00 48 89 e5 41 55 41 89 f5 41 54 53 48 89 fb 75 71 e8 56 d7 ff ff <4c> 8b 60 48 4d 85 e4 74 76 48 89 df e8 25 ff ff ff 45 85 ed 74 46 > [ 41.705320] RSP: 0018:ffffbc3a40053df0 EFLAGS: 00010286 > [ 41.705322] RAX: 0000000000000000 RBX: ffffbc3a406f1000 RCX: 0000000000000000 > [ 41.705323] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 00000000ffffffff > [ 41.705324] RBP: ffffbc3a40053e08 R08: 000000000001fb79 R09: 0000000000000037 > [ 41.705325] R10: ffffbc3a40053b68 R11: ffffbc3a40053cad R12: fffffffffffffff2 > [ 41.705326] R13: 0000000000000001 R14: 0000000000000000 R15: ffffffffffffffff > [ 41.705328] FS: 0000000000000000(0000) GS:ffff9e2977a80000(0000) knlGS:0000000000000000 > [ 41.705329] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 41.705330] CR2: 0000000000000048 CR3: 000000020c994000 CR4: 00000000003406e0 > [ 41.705331] Call Trace: > [ 41.705338] vfree+0x50/0xb0 > [ 41.705341] ffs_user_copy_worker+0xe9/0x1c0 > [ 41.705344] process_one_work+0x19f/0x3e0 > [ 41.705348] worker_thread+0x3f/0x3b0 > [ 41.829766] kthread+0x12b/0x150 > [ 41.833371] ? process_one_work+0x3e0/0x3e0 > [ 41.838045] ? kthread_create_worker_on_cpu+0x70/0x70 > [ 41.843695] ret_from_fork+0x3a/0x50 > [ 41.847689] Modules linked in: hci_uart bluetooth ecdh_generic rfkill_gpio dwc3_pci dwc3 snd_usb_audio mei_me tpm_crb snd_usbmidi_lib xhci_pci xhci_hcd mei tpm snd_hwdep cfg80211 snd_soc_skl snd_soc_skl_ipc snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core snd_hda_core videobuf2_dma_sg crlmodule > [ 41.876880] CR2: 0000000000000048 > [ 41.880584] ---[ end trace 2bc4addff0f2e673 ]--- > [ 41.891346] RIP: 0010:__vunmap+0x2a/0xc0 > [ 41.895734] Code: 0f 1f 44 00 00 48 85 ff 0f 84 87 00 00 00 55 f7 c7 ff 0f 00 00 48 89 e5 41 55 41 89 f5 41 54 53 48 89 fb 75 71 e8 56 d7 ff ff <4c> 8b 60 48 4d 85 e4 74 76 48 89 df e8 25 ff ff ff 45 85 ed 74 46 > [ 41.916740] RSP: 0018:ffffbc3a40053df0 EFLAGS: 00010286 > [ 41.922583] RAX: 0000000000000000 RBX: ffffbc3a406f1000 RCX: 0000000000000000 > [ 41.930563] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 00000000ffffffff > [ 41.938540] RBP: ffffbc3a40053e08 R08: 000000000001fb79 R09: 0000000000000037 > [ 41.946520] R10: ffffbc3a40053b68 R11: ffffbc3a40053cad R12: fffffffffffffff2 > [ 41.954502] R13: 0000000000000001 R14: 0000000000000000 R15: ffffffffffffffff > [ 41.962482] FS: 0000000000000000(0000) GS:ffff9e2977a80000(0000) knlGS:0000000000000000 > [ 41.971536] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 41.977960] CR2: 0000000000000048 CR3: 000000020c994000 CR4: 00000000003406e0 > [ 41.985930] Kernel panic - not syncing: Fatal exception > [ 41.991817] Kernel Offset: 0x16000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) > [ 42.009525] Rebooting in 10 seconds.. > [ 52.014376] ACPI MEMORY or I/O RESET_REG. > > Fixes: 772a7a724f6 ("usb: gadget: f_fs: Allow scatter-gather buffers") > Signed-off-by: Fei Yang > Reviewed-by: Manu Gautam > Tested-by: John Stultz > --- > v2: add tag: "Fixes: 772a7a724f6 ......", Reviewed-by and Tested-by. > v3: check data for NULL instead of "ret == -EIOCBQUEUED", which would be safer > and keep the original logic intact. If it "fixes" a problem in 5.0, we should add a: Cc: stable to it as well. thanks, greg k-h