From patchwork Wed Aug 14 16:59:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 171325 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1120867ily; Wed, 14 Aug 2019 10:27:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIZctVpnSpy/agrLjr3BxUTcY9jT026tynS3vACDsSLwxggQtsAlqvkDJ+I+lbEtZRCUs4 X-Received: by 2002:a17:902:bd09:: with SMTP id p9mr487028pls.96.1565803671574; Wed, 14 Aug 2019 10:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803671; cv=none; d=google.com; s=arc-20160816; b=RMui+/U7qrbc9lYooe1OM0VolhkTrIaAoikKsyrCHoa9hwpJ5wWYesTa5X61d2n4dD 8AquKoRevxiah0Tec/r06N4aie2nXZ2Ec78iW2NUfrujm5pulRtoPblEkO96DTtj1z7r xZrbVjXQho6n4WEPvwPYWBKH0OUq80v7vU0jcEFXrBtdeGm2cOpVMY7T7sai9whn7WGa ssW1426PZa5TAtMZnA7w1Wh9vtxnCvWej69ryFOHqrBn0hxxbcqqIjYfAnFl3uxapf/s EfUS7BeovR1woQZLtzRYE5hY7bVvN+jYincuYW2Nm/ge7q9cDWuJt+K+dy/7pCavPTzr oF5Q== 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=K802Mi5T/qQTeqBMoyqBGfnb4ajVAWdN/RtBR26xYk8=; b=a5/FDxzuSW1Kl3yPm2NUThjuqWUZZbE08SLzzyMHb3YiF90ypm86YICxLEq+WTSGYJ DyOTM6CraPzRanTzPNe9eCvEMMkgfcKEFk9zF9hu02mDVmWFnVAelRhJhi/Yz/lr9gm4 ITnYvWGWJDD+fps483QZElQCig0Oncrfr985z9LaM2o0+nMLWe6JhTR/4Pjf3H5QuluP V5By7/AjLIuHVwfaATrMVDigwPiZrKwm88Hra+oEGMNQ+AQey/w1iqKGc5hAi55TPB1u C7K8Ggm2BSKoyh5G4Ea8WM0es2OlOfUd2jONmiuE53C87n40OzVZpuobbyrjuwSXnK4G LLdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VHDxhv+g; 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 x20si233478pjn.49.2019.08.14.10.27.51; Wed, 14 Aug 2019 10:27:51 -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=VHDxhv+g; 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 S1729016AbfHNR1u (ORCPT + 28 others); Wed, 14 Aug 2019 13:27:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728864AbfHNRDM (ORCPT ); Wed, 14 Aug 2019 13:03:12 -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 5A9582084D; Wed, 14 Aug 2019 17:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802191; bh=kkUe3JrHtt33qgnokR/O4h/ujXrDTTyDNjLo5bGc2XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VHDxhv+gaTJWeD0fdHAO4t2e4F7N5nFEdZZpcLhsgIz+P6SqcfVwPjINh4RcY187s 4+jv7oZE7fc2uYqQf2HssUbBAG4MoDuqH4DP7cSokLJilSdSbYzUL8BAFFVdJidhiO 94bR62hZoj4OWTFVrX7BaAWGoUa2/BzTui/o56wE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Wolfram Sang , Jonathan Cameron Subject: [PATCH 5.2 005/144] iio: adc: gyroadc: fix uninitialized return code Date: Wed, 14 Aug 2019 18:59:21 +0200 Message-Id: <20190814165759.707144215@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 90c6260c1905a68fb596844087f2223bd4657fee upstream. gcc-9 complains about a blatant uninitialized variable use that all earlier compiler versions missed: drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] Return -EINVAL instead here and a few lines above it where we accidentally return 0 on failure. Cc: stable@vger.kernel.org Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver") Signed-off-by: Arnd Bergmann Reviewed-by: Wolfram Sang Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/rcar-gyroadc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -382,7 +382,7 @@ static int rcar_gyroadc_parse_subdevs(st dev_err(dev, "Only %i channels supported with %pOFn, but reg = <%i>.\n", num_channels, child, reg); - return ret; + return -EINVAL; } } @@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(st dev_err(dev, "Channel %i uses different ADC mode than the rest.\n", reg); - return ret; + return -EINVAL; } /* Channel is valid, grab the regulator. */ From patchwork Wed Aug 14 16:59:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 171319 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1093457ily; Wed, 14 Aug 2019 10:04:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn6/reFAdqjqzNcJIgTroN88IEV5thPKtzhB/03yyH+XwDNNXDbUZWuvHGRSVhHk69te59 X-Received: by 2002:a62:6044:: with SMTP id u65mr932604pfb.15.1565802276802; Wed, 14 Aug 2019 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802276; cv=none; d=google.com; s=arc-20160816; b=k8OzMYFRF0rSiVJ+A8L3lhXXqn/ys2mmzJAW8WqFD/7QYmnhdlClV8VNSAdVu/G6i9 BRO2/7jLKvTj1OX+6IRiPre4pSxdKcdP/sgI8YvCGtDRh0XMv3kx9qVzwDHHcUHQC1wd Potvgd3SYRhPBV1DoWTvWmkul2IFW2DrEqj74lWc0XQ1SZfxLyc2osJdnTiV1u4b1ivY pGXn9R92dEGNg/8pZOEnuNsDh/PrBqRJ7KWVZe2mQXapwHGJcTooobp3Ck8SEyQRyorD dEsIBn1cqBXzYslI7dXG0OeeEuc1FxtXY2mqJ/YSf2GsI5k9NPDU6kSZV2tLiGHaCI3y 60mQ== 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=3PhqaL17vcWnaYp5UOzIWh9z+Gcla+haqOD2SOgs5kE=; b=UCzNiCUYsYIlXyYr+yceAoJQ6bOn+l/YmV/3gI1xYjN51+V8Z5hyg0WZ+nM8uCiBwz sgY6a91NyJ1iDh2zCbKk1XC23egqZ5kDNFunA5HE1dhD2PzK3uqQEeSmpzmGBUMPz2dl UHh0kod9vX48m9iEWMkSK6y8tnlgNcXoEcOnoeOcm62y/AMp90L3kTUNo0+82DiCC/sX 97dHL5Sx/huHIG7GEf1WfyXv8UV5tD5Gy2W4j33yIW7zrRHoML/XwZPtDznuozOEhVfT eQaOW915nZdsttNpshNWAp2H0gsUu8xLWglghD4FAysFR52yUTaITFwmd0LewBMX+8+L yjGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TJB7rlit; 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 l71si171054pgd.314.2019.08.14.10.04.36; Wed, 14 Aug 2019 10:04:36 -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=TJB7rlit; 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 S1729260AbfHNREf (ORCPT + 28 others); Wed, 14 Aug 2019 13:04:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729235AbfHNREc (ORCPT ); Wed, 14 Aug 2019 13:04:32 -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 20101216F4; Wed, 14 Aug 2019 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802271; bh=EmXnNYRrjXkAFuyAfp9FKE1t/lNadDL0hVpRJKH24Cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJB7rlitwAj3iPCfF79wjRWHPFUjCH6NzmUL4Y9YWWPZ0H6nP+UyVB9YmRW5MhLa1 x7+k3p8xkMpgFWMy6FY26K5qoIlm656koesgzUxEwmOaKDUgibJX9elktKUJG72PF6 lgqbdlsG3SZqPe07hcHmTnM+lgDUP4wThQFFygtA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaibhav Rustagi , Peter Zijlstra , Thomas Gleixner , Nick Desaulniers Subject: [PATCH 5.2 035/144] x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS Date: Wed, 14 Aug 2019 18:59:51 +0200 Message-Id: <20190814165801.293530827@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Desaulniers commit b059f801a937d164e03b33c1848bb3dca67c0b04 upstream. KBUILD_CFLAGS is very carefully built up in the top level Makefile, particularly when cross compiling or using different build tools. Resetting KBUILD_CFLAGS via := assignment is an antipattern. The comment above the reset mentions that -pg is problematic. Other Makefiles use `CFLAGS_REMOVE_file.o = $(CC_FLAGS_FTRACE)` when CONFIG_FUNCTION_TRACER is set. Prefer that pattern to wiping out all of the important KBUILD_CFLAGS then manually having to re-add them. Seems also that __stack_chk_fail references are generated when using CONFIG_STACKPROTECTOR or CONFIG_STACKPROTECTOR_STRONG. Fixes: 8fc5b4d4121c ("purgatory: core purgatory functionality") Reported-by: Vaibhav Rustagi Suggested-by: Peter Zijlstra Suggested-by: Thomas Gleixner Signed-off-by: Nick Desaulniers Signed-off-by: Thomas Gleixner Tested-by: Vaibhav Rustagi Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20190807221539.94583-2-ndesaulniers@google.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/purgatory/Makefile | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -20,11 +20,34 @@ KCOV_INSTRUMENT := n # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not -# sure how to relocate those. Like kexec-tools, use custom flags. +# sure how to relocate those. +ifdef CONFIG_FUNCTION_TRACER +CFLAGS_REMOVE_sha256.o += $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_purgatory.o += $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_string.o += $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_kexec-purgatory.o += $(CC_FLAGS_FTRACE) +endif -KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -Os -mcmodel=large -KBUILD_CFLAGS += -m$(BITS) -KBUILD_CFLAGS += $(call cc-option,-fno-PIE) +ifdef CONFIG_STACKPROTECTOR +CFLAGS_REMOVE_sha256.o += -fstack-protector +CFLAGS_REMOVE_purgatory.o += -fstack-protector +CFLAGS_REMOVE_string.o += -fstack-protector +CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector +endif + +ifdef CONFIG_STACKPROTECTOR_STRONG +CFLAGS_REMOVE_sha256.o += -fstack-protector-strong +CFLAGS_REMOVE_purgatory.o += -fstack-protector-strong +CFLAGS_REMOVE_string.o += -fstack-protector-strong +CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector-strong +endif + +ifdef CONFIG_RETPOLINE +CFLAGS_REMOVE_sha256.o += $(RETPOLINE_CFLAGS) +CFLAGS_REMOVE_purgatory.o += $(RETPOLINE_CFLAGS) +CFLAGS_REMOVE_string.o += $(RETPOLINE_CFLAGS) +CFLAGS_REMOVE_kexec-purgatory.o += $(RETPOLINE_CFLAGS) +endif $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(call if_changed,ld) From patchwork Wed Aug 14 16:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 171316 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1092021ily; Wed, 14 Aug 2019 10:03:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqytBt+Hce+4OTRjX9Ic4okZtUr8/po1gOBZ8u/R16Jf8AdnTVEd+STkv6VYImbXK8B0d/pW X-Received: by 2002:a65:5342:: with SMTP id w2mr139908pgr.261.1565802218015; Wed, 14 Aug 2019 10:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802218; cv=none; d=google.com; s=arc-20160816; b=lffm+AkWkk+vEO4ui8jHYr8S3nQVtsF5zLAs/7tiTtwj8q9JfH0hM9z7n2qCX/TuGf FeuzVsGcg8CTnefm8cC5ybG0VlXTcxvnITc/KiRq/nfXGlB4fTsVjntPycMr0CcpD0RJ n3D8e7TyInyBC/XK/4Sy7G5KAInnWyNgZasSbUMI+mRdzR/zDveHh4swqS7Yx4R9AeI6 GGZbLu+FFd5WfcWQ7u9tf5X6rj/7i4HMG1lTjyeVJLVnZtqHZ5vc/A5rJbDehBS9ueHt ceMtm8aRf079lASz8x+tfdyInZMvKp0xX7AnGLAplU/rYwIJ/QCy0bnftq456k4VmMqZ NwZQ== 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=pk70SxobBEISonZP2U+QbgVQMarjKdRj68nNd9E97ow=; b=wz7eck3NuSTYOyN6nHgcsrmLCTcE1dvWj27crNGiNkg1pyoe8jAYxlIT+SQWhDjTbt lGD0ygRSFv1DBvSnYZ7r/otKonB+5jyaz9FLNeW/G/r8iIv5OZXeg62oS3r+6PoPGykl Lq8VIHMPBTua3kNpTz3pqM+0ybsiSSNiBwgPIXn4rBh1Zm6EOj/1i/21RcURM91T2863 MWdhVsfVwwjdTlGDmYjyHA9ro1a8RS8cz2vCuX3CEHVDy6+ZWsAHCaIMkczlnPmDvIXi m9T+6gebhF3qSLXbGkD6IOIG1NwfUw5MslwWxKPBfn47ds3NXBKvSgdpMLRypReNzJg/ OtdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CwHXdv5h; 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 34si261073plz.18.2019.08.14.10.03.37; Wed, 14 Aug 2019 10:03:38 -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=CwHXdv5h; 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 S1728982AbfHNRDh (ORCPT + 28 others); Wed, 14 Aug 2019 13:03:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:52242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728964AbfHNRDf (ORCPT ); Wed, 14 Aug 2019 13:03:35 -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 7C88D2084D; Wed, 14 Aug 2019 17:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802215; bh=UtMMtdD9yZxdECn3sH/nwTMhh/liM+yk8raGUiC1nIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CwHXdv5hRFfnMjH9KVteysX1CEEG05yjlYzIfjuh7UViPlec1Y81vo6jRxsuvqtqR XuFPbvyQc8idvv8++qXPGcntR6YdYs/dOywvYSMEZOgcPmoeGWgLyWtNPEPMy4c6NK l0Zn7xH2xvH1VrCAHwBNDH8sxJTk1ns9JFxyGMuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Kosina , Tomoki Sekiyama , Oliver Neukum , andreyknvl@google.com, Alan Stern , syzkaller-bugs@googlegroups.com, dtor@chromium.org, syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com, Suzuki K Poulose Subject: [PATCH 5.2 039/144] usb: yurex: Fix use-after-free in yurex_delete Date: Wed, 14 Aug 2019 18:59:55 +0200 Message-Id: <20190814165801.457895746@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose commit fc05481b2fcabaaeccf63e32ac1baab54e5b6963 upstream. syzbot reported the following crash [0]: BUG: KASAN: use-after-free in usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928 Read of size 8 at addr ffff8881b18599c8 by task syz-executor.4/16007 CPU: 0 PID: 16007 Comm: syz-executor.4 Not tainted 5.3.0-rc2+ #23 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xca/0x13e lib/dump_stack.c:113 print_address_description+0x6a/0x32c mm/kasan/report.c:351 __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482 kasan_report+0xe/0x12 mm/kasan/common.c:612 usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928 yurex_delete+0x138/0x330 drivers/usb/misc/yurex.c:100 kref_put include/linux/kref.h:65 [inline] yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392 __fput+0x2d7/0x840 fs/file_table.c:280 task_work_run+0x13f/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath arch/x86/entry/common.c:274 [inline] do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x413511 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007ffc424ea2e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413511 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006 RBP: 0000000000000001 R08: 0000000029a2fc22 R09: 0000000029a2fc26 R10: 00007ffc424ea3c0 R11: 0000000000000293 R12: 000000000075c9a0 R13: 000000000075c9a0 R14: 0000000000761938 R15: ffffffffffffffff Allocated by task 2776: save_stack+0x1b/0x80 mm/kasan/common.c:69 set_track mm/kasan/common.c:77 [inline] __kasan_kmalloc mm/kasan/common.c:487 [inline] __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:460 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:748 [inline] usb_alloc_dev+0x51/0xf95 drivers/usb/core/usb.c:583 hub_port_connect drivers/usb/core/hub.c:5004 [inline] hub_port_connect_change drivers/usb/core/hub.c:5213 [inline] port_event drivers/usb/core/hub.c:5359 [inline] hub_event+0x15c0/0x3640 drivers/usb/core/hub.c:5441 process_one_work+0x92b/0x1530 kernel/workqueue.c:2269 worker_thread+0x96/0xe20 kernel/workqueue.c:2415 kthread+0x318/0x420 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Freed by task 16007: save_stack+0x1b/0x80 mm/kasan/common.c:69 set_track mm/kasan/common.c:77 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:449 slab_free_hook mm/slub.c:1423 [inline] slab_free_freelist_hook mm/slub.c:1470 [inline] slab_free mm/slub.c:3012 [inline] kfree+0xe4/0x2f0 mm/slub.c:3953 device_release+0x71/0x200 drivers/base/core.c:1064 kobject_cleanup lib/kobject.c:693 [inline] kobject_release lib/kobject.c:722 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x171/0x280 lib/kobject.c:739 put_device+0x1b/0x30 drivers/base/core.c:2213 usb_put_dev+0x1f/0x30 drivers/usb/core/usb.c:725 yurex_delete+0x40/0x330 drivers/usb/misc/yurex.c:95 kref_put include/linux/kref.h:65 [inline] yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392 __fput+0x2d7/0x840 fs/file_table.c:280 task_work_run+0x13f/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath arch/x86/entry/common.c:274 [inline] do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8881b1859980 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 72 bytes inside of 2048-byte region [ffff8881b1859980, ffff8881b185a180) The buggy address belongs to the page: page:ffffea0006c61600 refcount:1 mapcount:0 mapping:ffff8881da00c000 index:0x0 compound_mapcount: 0 flags: 0x200000000010200(slab|head) raw: 0200000000010200 0000000000000000 0000000100000001 ffff8881da00c000 raw: 0000000000000000 00000000000f000f 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881b1859880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881b1859900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ffff8881b1859980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881b1859a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881b1859a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== A quick look at the yurex_delete() shows that we drop the reference to the usb_device before releasing any buffers associated with the device. Delay the reference drop until we have finished the cleanup. [0] https://lore.kernel.org/lkml/0000000000003f86d8058f0bd671@google.com/ Fixes: 6bc235a2e24a5e ("USB: add driver for Meywa-Denki & Kayac YUREX") Cc: Jiri Kosina Cc: Tomoki Sekiyama Cc: Oliver Neukum Cc: andreyknvl@google.com Cc: gregkh@linuxfoundation.org Cc: Alan Stern Cc: syzkaller-bugs@googlegroups.com Cc: dtor@chromium.org Reported-by: syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com Signed-off-by: Suzuki K Poulose Cc: stable Link: https://lore.kernel.org/r/20190805111528.6758-1-suzuki.poulose@arm.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/yurex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -92,7 +92,6 @@ static void yurex_delete(struct kref *kr dev_dbg(&dev->interface->dev, "%s\n", __func__); - usb_put_dev(dev->udev); if (dev->cntl_urb) { usb_kill_urb(dev->cntl_urb); kfree(dev->cntl_req); @@ -108,6 +107,7 @@ static void yurex_delete(struct kref *kr dev->int_buffer, dev->urb->transfer_dma); usb_free_urb(dev->urb); } + usb_put_dev(dev->udev); kfree(dev); }