Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1213778pxb; Fri, 10 Sep 2021 00:16:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyjrL86vidXnkO2eADeR7MF9dCfCkopE99WkM2nI8gA55IphPTXWKOcCoZtRjnpS/Y+M+4 X-Received: by 2002:a92:c14a:: with SMTP id b10mr5223717ilh.176.1631258175096; Fri, 10 Sep 2021 00:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631258175; cv=none; d=google.com; s=arc-20160816; b=sKMU+yNfcZgniFxgt/0XX7fFsyzgfKx2SUn/OjCl6mKjtRGN6is4S7Jtploz40ohzG UpL352Q0w3a2u6OAEGLsMjNcuisj861PBwyHcQQZOPPmKPqbJAgsLBTpwHMYFyj7MmIO hesVE1CVciV+xQ7cTMg2T6fscLvzHFZLo7FV+ZEnBuJpJrow8Zw7A1Rla9dxilTlMp2j IpPU0Vwr9ua63J439G6h9KyEi0mPaWCI5dBmDtL3z4Ctsehot2f0PJcegio8Co/1ElED o80LrGwmEy4h9S2x/PSoRDnDQ1WDmlIvaTXFHc/al+oDfLRgKT90RoURS9jLhiRo14Aw fbZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fGjDaCbJTWaUAWKF9sorZo0zO4TYTl0qsZufcWe1rRE=; b=q5qP+HkJ2az3wm+OgywdmxLin+4HmX6FzyTJkxajQaHgUUTtHrbBgHXc3ozfhq+hF1 DTP6q8qaSz4ZjUOCV4dNP12G+G+/rwyxZ0qFhcEoIAvyOoZJtb8rwciAWmWlFnJAOf8F n0pJcPfoYAcTP+whHj+7QIdldncEqmANcUdlftFeWgOou5479wk3KqH6tvvoDEXAmg1c 7jDovcfWRvPCdkgY1xx0lY0M8CS9TJIp2YxAup7rWzwZzSJzqC64RXCsduWvLmJSZgTE So4rxRVDsGgBu77Crg3K9gxmSobBJIsrUhJVA+6xcr/jUyDU19nsjR/y25nKpSvFMIuM afMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q4h89+wz; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si5148069iov.104.2021.09.10.00.16.03; Fri, 10 Sep 2021 00:16:15 -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=@linuxfoundation.org header.s=korg header.b=q4h89+wz; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231397AbhIJHQg (ORCPT + 99 others); Fri, 10 Sep 2021 03:16:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbhIJHQf (ORCPT ); Fri, 10 Sep 2021 03:16:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91624611BD; Fri, 10 Sep 2021 07:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631258125; bh=4L0BAh+DvGxazIMEC9AKtHADz64tMS4ZKALwhM1qvwE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q4h89+wzGw1TquKhEONUO+vjD9M/ubpOmYuU6807islJsX/RVc/TtaDrcxaFQP4le 2GjeGCwb7uHbX1+33HEk3f9V4vfEcgB3qugUdTY92Fo75ou1NObbV+aLYzxDrMPVX7 /WRI4NRo9tyESIgYOACbzJSmeZXYriK8jx0NpGKA= Date: Fri, 10 Sep 2021 09:15:00 +0200 From: Greg KH To: Li Li Cc: Li Li , "open list:ANDROID DRIVERS" , Android Kernel Team , LKML , "Joel Fernandes (Google)" , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Martijn Coenen , Hridya Valsaraju , Suren Baghdasaryan , Christian Brauner , Todd Kjos Subject: Re: [PATCH v2 1/1] binder: fix freeze race Message-ID: References: <20210910035316.2873554-1-dualli@chromium.org> <20210910035316.2873554-2-dualli@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 11:17:42PM -0700, Li Li wrote: > On Thu, Sep 9, 2021 at 10:38 PM Greg KH wrote: > > > > On Thu, Sep 09, 2021 at 08:53:16PM -0700, Li Li wrote: > > > struct binder_frozen_status_info { > > > __u32 pid; > > > + > > > + /* process received sync transactions since last frozen > > > + * bit 0: received sync transaction after being frozen > > > + * bit 1: new pending sync transaction during freezing > > > + */ > > > __u32 sync_recv; > > > > You just changed a user/kernel api here, did you just break existing > > userspace applications? If not, how did that not happen? > > > > That's a good question. This design does keep backward compatibility. > > The existing userspace applications call ioctl(BINDER_GET_FROZEN_INFO) > to check if there's sync or async binder transactions sent to a frozen > process. > > If the existing userspace app runs on a new kernel, a sync binder call > still sets bit 1 of sync_recv (as it's a bool variable) so the ioctl > will return the expected value (TRUE). The app just doesn't check bit > 1 intentionally so it doesn't have the ability to tell if there's a > race - this behavior is aligned with what happens on an old kernel as > the old kernel doesn't have bit 1 set at all. > > The bit 1 of sync_recv enables new userspace app the ability to tell > 1) there's a sync binder transaction happened when being frozen - same > as before; and 2) if that sync binder transaction happens exactly when > there's a race - a new information for rollback decision. Ah, can you add that to the changelog text to make it more obvious? thanks, greg k-h