Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp355821ybe; Wed, 4 Sep 2019 00:22:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUvZSymunoDC6d0S1/2kwwkq2iCUBw5xQFUNX0ujusLjsWI2YDzOfjst0iyn4ig7/knhOY X-Received: by 2002:a17:90a:2e86:: with SMTP id r6mr3451877pjd.67.1567581738349; Wed, 04 Sep 2019 00:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567581738; cv=none; d=google.com; s=arc-20160816; b=jThT+oB+MUZfYaxOcoqVjA2O1YfetvrQVWFgUVE9lyjhk0nEe1R7HHMQaVsC0QOdb/ UC4DeHJVpN9k0r+d4isAI3ynMKOhOAflkxVntCqi153nleO8hTaTetxEOQROhGFlNiQl IK/wz2Ezpq+aosvF+7WvKkfC72QQCREuPDLJOiIqDcpulJGk7DaragGyrJ4rfmxvKAeN d3uGHwm/bpLhOUTSgEwzJpJYPmGgWiqLJUZPeut4Ql44YIwv+9kZ0eJM88CIz8DXt2x0 0DxHy5L31Hcmo1LKenZmzo1squPngVtM1X9mHmdh8B9ISBqjvuBshENX2rQwVyIXPd// enmQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IKYtU1praOwe2d5uVwYquBcNtZDfJ71T+dPx5t1Jsv0=; b=cYM/bg4FULRPrJGS9BPG8SpWcwQRiT0OmF46C0XcZRQlgtuRotQq1xPtyETG0SexMd J2Nt2hhm/JbYKZaZ5e3U4NnTu4k6rANdjo3W4FFK1AbDwWdwCbfOnZ9eKFgeQ+uf8Y7N QaD0XHQFQrx9bXI+WGE6btOnvPtiG0ju4dsBW7nIFMFAlMNrioIOZ30uPIXmSZELA8gU 5RY5ywKXSDS9ETZHsbIlLZ8pP4ES/W0RxPzroDsJKOSphoxxujyWjRmL6fj4YwSEhyoe b8AhlTQOZP+itb00jfhyGKF1VS9hBjvlGWlvYNEWP5TAaD986oKP9PGnT9oW56m/k6RL FY8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w9wfwQhZ; 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 j63si16159158pgd.493.2019.09.04.00.22.02; Wed, 04 Sep 2019 00:22:18 -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=w9wfwQhZ; 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 S1729010AbfIDHTd (ORCPT + 99 others); Wed, 4 Sep 2019 03:19:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:36042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfIDHTd (ORCPT ); Wed, 4 Sep 2019 03:19:33 -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 634872339D; Wed, 4 Sep 2019 07:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567581571; bh=agWnI6rJaNdK4UMwnHBLhmqSgnDlx6mMyBHN9X1yZg0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=w9wfwQhZZgfWDk5hLe7xZr/Nozm/Tm6ZFe7ClleLnfdOCIAXfsvTuJ4a7SlzOGqGD YN+HZIrs+6145OnTEBQ8AipFGiZwEWRDXPxCySmjhyxobbjV8tXSDaiNHeZWUZF4B0 4khMHThIJpaBxaYCCjWpdX9f+wH3UPw3vrfmFY3E= Date: Wed, 4 Sep 2019 09:19:29 +0200 From: Greg Kroah-Hartman To: Hridya Valsaraju Cc: Christian Brauner , devel@driverdev.osuosl.org, kernel-team@android.com, Todd Kjos , linux-kernel@vger.kernel.org, Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Joel Fernandes , Martijn Coenen Subject: Re: [PATCH v3 2/2] binder: Validate the default binderfs device names. Message-ID: <20190904071929.GA19830@kroah.com> References: <20190808222727.132744-1-hridya@google.com> <20190808222727.132744-3-hridya@google.com> <20190809145508.GD16262@kroah.com> <20190809181439.qrs2k7l23ot4am4s@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 09, 2019 at 11:41:12AM -0700, Hridya Valsaraju wrote: > On Fri, Aug 9, 2019 at 11:14 AM Christian Brauner > wrote: > > > > On Fri, Aug 09, 2019 at 04:55:08PM +0200, Greg Kroah-Hartman wrote: > > > On Thu, Aug 08, 2019 at 03:27:26PM -0700, Hridya Valsaraju wrote: > > > > Length of a binderfs device name cannot exceed BINDERFS_MAX_NAME. > > > > This patch adds a check in binderfs_init() to ensure the same > > > > for the default binder devices that will be created in every > > > > binderfs instance. > > > > > > > > Co-developed-by: Christian Brauner > > > > Signed-off-by: Christian Brauner > > > > Signed-off-by: Hridya Valsaraju > > > > --- > > > > drivers/android/binderfs.c | 12 ++++++++++++ > > > > 1 file changed, 12 insertions(+) > > > > > > > > diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c > > > > index aee46dd1be91..55c5adb87585 100644 > > > > --- a/drivers/android/binderfs.c > > > > +++ b/drivers/android/binderfs.c > > > > @@ -570,6 +570,18 @@ static struct file_system_type binder_fs_type = { > > > > int __init init_binderfs(void) > > > > { > > > > int ret; > > > > + const char *name; > > > > + size_t len; > > > > + > > > > + /* Verify that the default binderfs device names are valid. */ > > > > > > And by "valid" you only mean "not bigger than BINDERFS_MAX_NAME, right? > > > > > > > + name = binder_devices_param; > > > > + for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) { > > > > + if (len > BINDERFS_MAX_NAME) > > > > + return -E2BIG; > > > > + name += len; > > > > + if (*name == ',') > > > > + name++; > > > > + } > > > > > > We already tokenize the binderfs device names in binder_init(), why not > > > check this there instead? Parsing the same string over and over isn't > > > the nicest. > > > > non-binderfs binder devices do not have their limit set to > > BINDERFS_NAME_MAX. That's why the check has likely been made specific to > > binderfs binder devices which do have that limit. > > > Thank you Greg and Christian, for taking another look. Yes, > non-binderfs binder devices not having this limitation is the reason > why the check was made specific to binderfs devices. Also, when > CONFIG_ANDROID_BINDERFS is set, patch 1/2 disabled the same string > being parsed in binder_init(). > > > > > But, in practice, 255 is the standard path-part limit that no-one really > > exceeds especially not for stuff such as device nodes which usually have > > rather standard naming schemes (e.g. binder, vndbinder, hwbinder, etc.). > > So yes, we can move that check before both the binderfs binder device > > and non-binderfs binder device parsing code and treat it as a generic > > check. > > Then we can also backport that check as you requested in the other mail. > > Unless Hridya or Todd have objections, of course. > > I do not have any objections to adding a generic check in binder_init() instead. Was this patchset going to be redone based on this? thanks, greg k-h