From patchwork Wed Sep 27 18:32:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9974551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C143060375 for ; Wed, 27 Sep 2017 18:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB57C2912C for ; Wed, 27 Sep 2017 18:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0303292AA; Wed, 27 Sep 2017 18:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0FD2912C for ; Wed, 27 Sep 2017 18:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752008AbdI0Sc5 (ORCPT ); Wed, 27 Sep 2017 14:32:57 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36360 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbdI0Sc5 (ORCPT ); Wed, 27 Sep 2017 14:32:57 -0400 Received: by mail-pf0-f195.google.com with SMTP id f84so7449919pfj.3; Wed, 27 Sep 2017 11:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=MoV175GbS3r+/0JFBVaEe1tP+NYoF+iV231C+YnB1zc=; b=IgFF/qos1cmpdyO66KHHFqrg7QzU89m4HWD+tKVWo5gIhm1q2wm0tVnpuOYv+5JfUS m5+RoxR5N3yyiZ8U0GpMmDt/vw1XO4Qn0aLAvKHVNWV0Y8Stx2qUzDOGsgEw9x3Q7TbX 16aBHYPObQg5kBxBnFUX4wjH6Dc5mbNM0kyViEnfuzPDUlr/p1pRGr5lzr48IzSA4Pz8 Q/qPLb04G9mI0jiqPQ03O7tBiJmStSqSnMSA427RTKm3NipFqIM3Yrb/AhzL7y0BbtHK oNUfX810XG3mFdm5sc+rPBJi2savAAnLhT5c0M6auEokmoWSWf2e5z+8+UA1Wv9WPKJ6 WGQg== 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; bh=MoV175GbS3r+/0JFBVaEe1tP+NYoF+iV231C+YnB1zc=; b=kwd+17ppMf8uekZNQwjOQQH5+jBFrJxxosFQGOeqeVkKBMgychQA717Sw5PVQflTUj s4k6KMJjNn5qiyugxYDBRlqM6I7msDBRnXMHqunWMlFjU/80TTP6Jg4LzCsw182BlagN HWXG6j6WCUKnPc8DLRrhJ66bsnSAdBuVziPKWnQnxQ5stWmtQ+YL2gYr3Ytkg43AW3NT FqI8CfUpZmZfDC18J47ZmLL2xy5NfuO2SprtRrYyKnI8EbbIEzZRPSWkJZWseP8SqRTR xm9LCfZ+S6R0w4le+pei4qy6RMzNj+WkSkc5TsfNxNHI2auYOrW0SElJArwQVzaegjvY nAJw== X-Gm-Message-State: AHPjjUhMcZe9rNubT64353iC4Smq70gPYy8o+FUUCp1ve2RCw74xiMG1 IsR2newpXPFUJpOZZwWJ0dU= X-Google-Smtp-Source: AOwi7QBpB81YZCZ7CObHeGMN1cc8oT1FabPRt5njw/uhub64aSTducO19Ty9pOcdMNt7sXPgWPaDWg== X-Received: by 10.99.151.2 with SMTP id n2mr2131371pge.315.1506537176529; Wed, 27 Sep 2017 11:32:56 -0700 (PDT) Received: from localhost.localdomain ([103.16.68.147]) by smtp.gmail.com with ESMTPSA id c7sm22199506pfc.55.2017.09.27.11.32.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 11:32:54 -0700 (PDT) From: Arvind Yadav To: andreyknvl@google.com, mchehab@kernel.org, kcc@google.com, dvyukov@google.com, mchehab@s-opensource.com, javier@osg.samsung.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com Subject: [RFT v2] [media] siano: FIX use-after-free in worker_thread Date: Thu, 28 Sep 2017 00:02:42 +0530 Message-Id: <2b7b169ee0fb43b4447c8960cdfabcfe118d2a8b.1506536596.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Call flush_work() on failure and disconnect. Work initialize and schedule in smsusb_onresponse(). it should be freed in smsusb_stop_streaming(). Signed-off-by: Arvind Yadav --- This bug report by Andrey Konovalov "usb/media/smsusb: use-after-free in worker_thread". changes in v2 : call flush_work() in smsusb_stop_streaming(). drivers/media/usb/siano/smsusb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c index 8c1f926..8142ba4 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -192,6 +192,8 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev) for (i = 0; i < MAX_URBS; i++) { usb_kill_urb(&dev->surbs[i].urb); + flush_work(&dev->surbs[i].wq); + if (dev->surbs[i].cb) { smscore_putbuffer(dev->coredev, dev->surbs[i].cb); dev->surbs[i].cb = NULL;