Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1308071ybt; Thu, 25 Jun 2020 02:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdsvngGzLnDJNsxQ0rVIQLHEJLX2SjKpT1yZ+J3Qw1EDhrXbThucTSI1YcXFOfQ2qUCzZv X-Received: by 2002:a17:906:f117:: with SMTP id gv23mr2875959ejb.528.1593079146413; Thu, 25 Jun 2020 02:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593079146; cv=none; d=google.com; s=arc-20160816; b=QVu6vHw5x2Xhpi1fu0LdXoo/3kMU7jN4ObwzDkH12yK49iqxtXm4SR/UnOt8SUpX0p SqyiCxnw+8zp47rLaLozkqJLakvsFz4ZEiEjDBNhIjp/CdIQ9XONUop3UTKqokJ/02w5 dA4KGte9Xl5U+unXGCrSJNtNDBaxJ9966KGJOm/1Tu6NSy8G9b6zR0QoJwQVQMtJjA5P odIDgpzi4Kasx61oDh0CsbqNmw9j3jI8BqRux74hi7DrRYG2B+n++NQZj1wBBMOir3x1 bgrQlx+AuSGDGNmwrI1EWgqOACU+WWYETqyFOPyJ1+Ib0AkxIj5sdHa22sx7wYQ3Wwgs ZhOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nkHtLK8Qn/URDh6hoRXRpKeBEGLYTiIfhxiyKIBGw6E=; b=CNyJ4wgo3UctqACXhMI7AbPWCeq6Pek10dXoXnY91oF3NvnzmHLxjR2DP1C47wJ7S5 yNuPqpwZoflRwYimaPNnkQrNz1c7f9V4FdZ64aPk3VXesnnYUayXRQes2wJRNUI0jnnb 0ipj42zRRchfA0k8ErDovRnlUQI/NZ+7euth5NF9B+qtKPvr8JmrohXU84WcX19SVFzl b9D7CCU9hxcLRaYFe0fuabfNjwW2w+xsDjMpCywPMbPqW5Oxi4tyJ23Zblu1GIdGRxpO Ow12m0fpVwyuDxiN6X6UcOkyIBKo9w8uI4U2o0Y5xAYmQmGG9QwSC7MzQ6BdhtJP+7hX oQ5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=obZB5gx6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id bi8si16734564edb.602.2020.06.25.02.58.43; Thu, 25 Jun 2020 02:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=obZB5gx6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2403836AbgFYJYD (ORCPT + 99 others); Thu, 25 Jun 2020 05:24:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390836AbgFYJYD (ORCPT ); Thu, 25 Jun 2020 05:24:03 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38F4C061573; Thu, 25 Jun 2020 02:24:02 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id ev7so2264309pjb.2; Thu, 25 Jun 2020 02:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nkHtLK8Qn/URDh6hoRXRpKeBEGLYTiIfhxiyKIBGw6E=; b=obZB5gx69vABUSmu58Zx5DBvcInMdzcqZiUUNh/ka8ysbFJz8u+08RyuRLN3a90Fkp 6K6T4nVzf6iYuR3DbeCxmw9JEDuQUC9JatV7Mo6sTdGZxeA2y3cW07dKJEIECuuO+qfO janUxNM5qrfxi9Z61Tf0VzGjEdFVyUWa5fST774ndNbSDiJkJMSWe6D/VBtzAJlc2GYL vu7UZrWjd8s5FtPQiKxXw4NeiNYRBuBGGtImUOuc+rOcwtO4jmWuEnrQ7sQpzp8Nw9ho kxhcClkbaUIriqr00v8NrvSPbJ/5KLpBqKrjdaCQlBjZDoRmuOWqJDbMehbcnuWqWg7B wZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nkHtLK8Qn/URDh6hoRXRpKeBEGLYTiIfhxiyKIBGw6E=; b=iltZHCNTsLdD2jSJ35W2tRnAPMgLhBxiQOJ9grzBUGk+yWsnuNM52/gDQjyEmJJWzH InbzrNfeC7r4WSW8nM1dFQf8saVeK2SZHSc4U5kanRglh2RR/lqYbkQBEvh6RXc5zGZt OYlw8E070k3Ze9HH4lsCHIilrTwBKU/wJASRmPtkRHPG5EL/93rM7Z/oSbeKy+0iZDAr AaUwd9XzQktHinSxI5dZ17kqrHQEplTYdkrrSGrTPJD2I7sT3jyoxbL6Kb0EZ389yMtg CLFQGj2wp2BSEDMMan2M8jbjrV2/tjlJxTTAnOUWPTbGersUQ32mJhumxdnx4k06ugGP qlMQ== X-Gm-Message-State: AOAM5334xZr7ROCzRMPjV7qyyy8R+ca5u99DHM0mbamnX2VIiVZXVVtw cSpS9pND8R8oZEybSn5zkitRL86V6lIJ1gShSdIhlBiB X-Received: by 2002:a17:90a:220f:: with SMTP id c15mr2358463pje.129.1593077042444; Thu, 25 Jun 2020 02:24:02 -0700 (PDT) MIME-Version: 1.0 References: <20200623040107.22270-1-warthog618@gmail.com> <20200623040107.22270-11-warthog618@gmail.com> <20200624155714.GB8622@sol> <20200624225803.GA3600@sol> <20200625091307.GA16386@sol> In-Reply-To: <20200625091307.GA16386@sol> From: Andy Shevchenko Date: Thu, 25 Jun 2020 12:23:49 +0300 Message-ID: Subject: Re: [PATCH 10/22] gpiolib: cdev: fix minor race in GET_LINEINFO_WATCH To: Kent Gibson Cc: Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski , Linus Walleij Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 12:13 PM Kent Gibson wrote: > On Thu, Jun 25, 2020 at 11:44:21AM +0300, Andy Shevchenko wrote: > > On Thu, Jun 25, 2020 at 1:58 AM Kent Gibson wrote: > > > On Wed, Jun 24, 2020 at 11:57:14PM +0800, Kent Gibson wrote: ... > > > Perhaps you are referring to the case where the copy_to_user fails? > > > > Yes. > > > > > To be honest I considered that to be so unlikely that I ignored it. > > > Is there a relevant failure mode that I'm missing? > > > > The traditional question for such cases is "what can possibly go wrong?" > > I wouldn't underestimate the probability of failure. > > > > The worst case is the watch is enabled and the userspace gets an > EFAULT so it thinks it failed. If userspace retries then they get > EBUSY, so userspace accounting gets muddled. > > We can clear the watch bit if the copy_to_user fails - before > returning the EFAULT. Would that be satisfactory? Perhaps. I didn't check that scenario. > Back to the failure, is it possible for the copy_to_user fail here, > given that the corresponding copy_from_user has succeeded? Of course. The general rule is if on SMP system you have not strongly serialized sequence of calls (means no preemption, no interrupts, etc) anything can happen in between. > If so, can that be manually triggered for test purposes? Unfortunately not an expert in mm, no idea, sorry. -- With Best Regards, Andy Shevchenko