Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2087770yba; Fri, 19 Apr 2019 11:53:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmYNaBNoSknni85CVGM2v7WNiMh6cN6uxLSs4oG/XU1Q3vuP/ewjocN3EioYjjqA0nwx7d X-Received: by 2002:a62:e215:: with SMTP id a21mr5677682pfi.30.1555700032538; Fri, 19 Apr 2019 11:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555700032; cv=none; d=google.com; s=arc-20160816; b=PpJOHOKECar6xVYwD2BKDpGeKhB6W+R8eO5+8PxuaJKXAzBkwfwMYmeEQzeQpAHT5h xnZsxYmH1WnQMYl4boX1tSXEnr23as9VDTPdoqQQU3/yNMztSmyqUM7Mk1HfyvXIQ7yf meAZwG2HckrqXlFE/hve+ahnnp4487cKq/wH3VOhDclCjSHgaRALcQ6D756PPs99v5+8 zebI+UQJvnX045sFX6iw4zujgTvJhlUiAWuKgUyRuye7Jbm4EXdUSLQP7fo76PWbbAxT fMMdMcpWaYU5FG0b4HDgP0vgPzuM8YOrz0baPWjvoVKLJ0Kb1yrFmMQRgekHPjyrjbRD R4xA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CX8mWHi5JP8YBeb+oMpVfgjuWx7XmRHb9Tyvaknfgqo=; b=RA8Ek3RXu4KVIIcO0NQXnsHkV8VsK0lv6oPmc+ngfumHAV8oVBcW1/eKaEV/Kx1nbs jefUwlnmnUHLL1tYclWTffvidEswOVrwp27YKip2wikjJxN7LxBkao8z97we8+7B34Z8 2fjdjSJKsqQ2HCLnZ+B0h7hyuUwI8Bpeb9DinhIRL/C/k9kSR7VxrrOwcP3e8nK8liKC 22vIP/4+AIP+mpGie5qp6MvLBwqstsUslGSjfz3pKX9H6rCjjKvngcciq/c50KseVxz5 yDmeBuyeQnlp/+LRS99Z5rD+LGvMg02eR81jiHN3nvjrGl/ew5qS71rF7RrujqDLblwV jYsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t1+cB6Ml; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h36si1544136plb.50.2019.04.19.11.53.37; Fri, 19 Apr 2019 11:53:52 -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=@gmail.com header.s=20161025 header.b=t1+cB6Ml; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbfDSSwd (ORCPT + 99 others); Fri, 19 Apr 2019 14:52:33 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38672 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfDSSwd (ORCPT ); Fri, 19 Apr 2019 14:52:33 -0400 Received: by mail-pl1-f194.google.com with SMTP id f36so2967979plb.5; Fri, 19 Apr 2019 11:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=CX8mWHi5JP8YBeb+oMpVfgjuWx7XmRHb9Tyvaknfgqo=; b=t1+cB6MlGgLB+qRRLIOaQLFwiYSR1AngcrSiTahDGi9q5trmEhQ9T/PBBscfj0L1YY Qifs630A39yD5Zj+JTgGWr7dZOkNJLKNLFAdcMVFhygelnYrGdL0U5K1tXDqO6W4lSfi SOSEiq71dtVqDK21K6aTLvKgEbvoEknuP0QuQBqvxyAtbzlC2btOmVaba9dLMqYf3TJK 2ozzuiwacMXhhhxOYzRpEhvPHnz0KCrmamMVy3FPMUkOTSW9rzvz+FjtGuZS8av5mYbA 6xxeJYaMcSrJDNc7J8JJ2GULmJdsw8HslfmPX8IU7dTbfCaKCkz5ZINkPm7vNhS/sq24 kS+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=CX8mWHi5JP8YBeb+oMpVfgjuWx7XmRHb9Tyvaknfgqo=; b=gGwX+ehqw8ggaNyHQidZH8IhfOSk7NuGgZYru1thC5iugzccM76jRX6sdDv82MX0uy jFBOQMSPCQ6tUn/vs2DSvnLRdK9nekWBO51UhwpMw9ZclB2ouhseSWl+J0BUUXsM0EYf e7WyjMrruPtSMwcv3h2agH8aRQCDA+sSUWFJtQlsvADjFf93sCwuJwivkXlvpUd5HfLw YaDb5Og0xhn/HyfJ2HHlmVzCOrpELRZc5KQdZKUA770OswnrpWLKrjf1jHRc5ygFV33a CVqFJ8mOBTvqGO7xypka9soRJ68yNusD23+C8BWSuJYhHPem9b4GKpMvHxl6v/XM3Kk/ MNVA== X-Gm-Message-State: APjAAAVj7z6e0iMIYPl38Oa7+bzpA1t3p8UlklU6hfF5f7ADzDjRDW0x +oT2yVXCq32yrLKakvJ122eDpWJd7Rs= X-Received: by 2002:a17:902:2825:: with SMTP id e34mr2285618plb.264.1555659129002; Fri, 19 Apr 2019 00:32:09 -0700 (PDT) Received: from localhost ([61.199.190.18]) by smtp.gmail.com with ESMTPSA id s187sm4248660pgb.13.2019.04.19.00.32.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Apr 2019 00:32:08 -0700 (PDT) Date: Fri, 19 Apr 2019 07:11:52 +0000 From: "dmitry.torokhov@gmail.com" To: Mukesh Ojha Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Gaurav Kohli , Peter Hutterer , Martin Kepplinger , "Paul E. McKenney" Subject: Re: [PATCH v2] Input: uinput: Avoid Object-Already-Free with a global lock Message-ID: <20190419071152.x5ghvbybjhv76uxt@penguin> References: <1554883176-24318-1-git-send-email-mojha@codeaurora.org> <7299a6db-38b7-75c7-633a-00d2257eba45@codeaurora.org> <20190418014321.dptin7tpxpldhsns@penguin> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mukesh, On Fri, Apr 19, 2019 at 12:17:44PM +0530, Mukesh Ojha wrote: > For some reason my last mail did not get delivered,? sending it again. > > > On 4/18/2019 11:55 AM, Mukesh Ojha wrote: > > > > > > On 4/18/2019 7:13 AM, dmitry.torokhov@gmail.com wrote: > > > Hi Mukesh, > > > > > > On Mon, Apr 15, 2019 at 03:35:51PM +0530, Mukesh Ojha wrote: > > > > Hi Dmitry, > > > > > > > > Can you please have a look at this patch ? as this seems to reproducing > > > > quite frequently > > > > > > > > Thanks, > > > > Mukesh > > > > > > > > On 4/10/2019 1:29 PM, Mukesh Ojha wrote: > > > > > uinput_destroy_device() gets called from two places. In one place, > > > > > uinput_ioctl_handler() where it is protected under a lock > > > > > udev->mutex but there is no protection on udev device from freeing > > > > > inside uinput_release(). > > > uinput_release() should be called when last file handle to the uinput > > > instance is being dropped, so there should be no other users and thus we > > > can't be racing with anyone. > > > > Lets say an example where i am creating input device quite frequently > > > > [?? 97.836603] input: syz0 as /devices/virtual/input/input262 > > [?? 97.845589] input: syz0 as /devices/virtual/input/input261 > > [?? 97.849415] input: syz0 as /devices/virtual/input/input263 > > [?? 97.856479] input: syz0 as /devices/virtual/input/input264 > > [?? 97.936128] input: syz0 as /devices/virtual/input/input265 > > > > e.g input265 > > > > while input265 gets created [1] and handlers are getting registered on > > that device*fput* gets called on > > that device as user space got to know that input265 is created and its > > reference is still 1(rare but possible). Are you saying that there are 2 threads sharing the same file descriptor, one issuing the registration ioctl while the other closing the same fd? Thanks. -- Dmitry