Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp187576imj; Thu, 14 Feb 2019 18:15:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IaTPOxtCa6GwfQulO+pdZ/rQRPlbNpeUcxhV1HgOiV9edda4SkTQ1ZhW3gVXhIBQ/YLF8Ec X-Received: by 2002:a17:902:e48c:: with SMTP id cj12mr7331766plb.146.1550196931938; Thu, 14 Feb 2019 18:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550196931; cv=none; d=google.com; s=arc-20160816; b=dOmf0u8d9yXjvPvYybwM4m6awzPn935QMW7Fnn8DdL/39CRPuJ6cYgfRDDYdBmUxvP zrG3vshdigj9FNpZ/y2/6mZxmNRTUc0sxZAQIZHxPW4CjsQofNTcXfHUI7nMueWn5nCl 77u/XzXASxft1fI+UEYdvAvPKfKiuVQFkeSs76v5koXCN/01/GXwHRL3L3B1n1zykJ7O fqm9SUYKjp/SP73uwAtPiC0/IDI3nbbgUC09Co8hKkjybzQqFRwkzTkxBqC6YzUot+f1 kiwbLPLWHxMwfH0R557AB0Db8KzwW7TsA/fmMmrOkOg/DzeYRwPyKcABp84ORuse3Nc1 W2Ww== 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=uvdk4l69SVq1YCepBd0SNErCFPeMSilcO259odTUTos=; b=GHxApz3Zsowffsz5Xhp69mI8BBaKvTsPged852nfUxnWSmEo+m4jEYcaCqSO21p3g5 +r8AGx1kXSVcOyQrzMoI7Fff9KKDMTtINJBRA77HZD2begzZMkGTNlGX364FrzhBPrJA SV1/n+A6Dpkkn86ZMDPQ4KpvJXeYyHlJfopy+yVGcJmqRh9aj66FOexWpRjBqLLZ88iB jORkpEwcGEFMtPJ0LHqe9Y59dSDKPbgG2x6OMyPJSLb/SCUXrLAsMmdBbV5j/QcuP5D9 WLdmeyUtXlwX+L8nK5fo62PXbWq5DfmNrTIyMJM92fZayqUztCmWO7W9w819VDjQv9PN SmOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=l+z3NP45; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si719188pla.173.2019.02.14.18.15.16; Thu, 14 Feb 2019 18:15:31 -0800 (PST) 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=@google.com header.s=20161025 header.b=l+z3NP45; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438001AbfBNVZv (ORCPT + 99 others); Thu, 14 Feb 2019 16:25:51 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:46291 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388263AbfBNVZv (ORCPT ); Thu, 14 Feb 2019 16:25:51 -0500 Received: by mail-qt1-f195.google.com with SMTP id y20so8556755qtm.13 for ; Thu, 14 Feb 2019 13:25:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uvdk4l69SVq1YCepBd0SNErCFPeMSilcO259odTUTos=; b=l+z3NP45VQ7XjqmgiGSFeyDx69gQDt8EGKaKIWsQEH7XQdV3EtFSlPAyH8ieWnAtN4 hTalZqklXKd0pkRVVIOEbyy2xBsqOFUPT5tASXhKSIBj36KpP3dY0vGEjKJcG3pqrxpE vjJLZUT6gYRtssNYOrih/32Mx+hAECs2nNXgG5wJhvFApQHKiaMC21MbI64RiNq5Va8m Q8V80F+9nUsTmY7u2D4Er/ESohNGhAtQ+vy2BSb/x28lbkpjS2Cl0ow7w5BG5HXwBqF8 wjU5YFJ36CvR0NwZGucMYkGOmAm1Yq3HUF+gsEgFQfP3Jx/t7BM0b+1qkY+ScSyVALij v32w== 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:in-reply-to:user-agent; bh=uvdk4l69SVq1YCepBd0SNErCFPeMSilcO259odTUTos=; b=Hw8Z39sXkvnFHCG4K56CruuhaoUM25thE9O3hynL49HhSaPN6IzdxKiRCj1oDSLQBR Lm0aRtnkU+uG3a/zBg8TbzIDzV+Q/cYJkvj/OU1xTt1WkOPpHcZXCM6SHuFCKUVW+FTt kDxbIr7zDm396MUm7wVn/THSzkdg2h2yqgU9x7/k/RV5XZyUndxkIIFJhPsy2mkM+MWc akv0ZkkSw8E+WKSlCuv2V4nu0IbMq6pyNtc24h3Tdpie2oS+NJKPtJJRnvCpzTGDvFDU EkvTZoPZanE7VdObwC2Dg3nDPcHBXle+qP67waK+JFgFVS0lz5Dnl+gRk7w/LN1z85CW U+HQ== X-Gm-Message-State: AHQUAuZOlhZ5IclMYBj6sogDEp7GiS7REQnLrJ3/wXcrAzZ2BrR/KkEJ +XGexxWGl2CLlEsm/Xf/8eMiVA== X-Received: by 2002:ac8:1ae9:: with SMTP id h38mr4899963qtk.229.1550179550058; Thu, 14 Feb 2019 13:25:50 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id s48sm2145501qts.47.2019.02.14.13.25.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 13:25:49 -0800 (PST) Date: Thu, 14 Feb 2019 16:25:49 -0500 From: Joel Fernandes To: Todd Kjos Cc: Todd Kjos , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , "open list:ANDROID DRIVERS" , LKML , Martijn Coenen , "Joel Fernandes (Google)" , Android Kernel Team Subject: Re: [PATCH v3 1/7] binder: create userspace-to-binder-buffer copy function Message-ID: <20190214212549.GB185075@google.com> References: <20190208183520.30886-1-tkjos@google.com> <20190208183520.30886-2-tkjos@google.com> <20190214194540.GA185075@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 14, 2019 at 03:53:54PM -0500, Joel Fernandes wrote: > On Thu, Feb 14, 2019 at 3:42 PM Todd Kjos wrote: > > > > On Thu, Feb 14, 2019 at 11:45 AM Joel Fernandes wrote: > [snip] > > > > + * check_buffer() - verify that buffer/offset is safe to access > > > > + * @alloc: binder_alloc for this proc > > > > + * @buffer: binder buffer to be accessed > > > > + * @offset: offset into @buffer data > > > > + * @bytes: bytes to access from offset > > > > + * > > > > + * Check that the @offset/@bytes are within the size of the given > > > > + * @buffer and that the buffer is currently active and not freeable. > > > > + * Offsets must also be multiples of sizeof(u32). The kernel is > > > > > > In all callers of binder_alloc_copy_user_to_buffer, the alignment of offsets > > > is set to sizeof(void *). Then shouldn't this function check for sizeof(void *) > > > alignment instead of u32? > > > > But there are other callers of check_buffer() later in the series that > > don't require pointer-size alignment. u32 alignment is consistent with > > the alignment requirements of the binder driver before this change. > > The copy functions don't actually need to insist on alignment, but > > these binder buffer objects have always used u32 alignment which has > > been checked in the driver. If user code misaligned it, then errors > > are returned. The alignment checks are really to be consistent with > > previous binder driver behavior. > > Got it, thanks. One more thing I wanted to ask is, kmap() will now cause global lock contention because of using spin_lock due to kmap_high(). Previously the binder driver was made to not use global lock (as you had done). Now these paths will start global locking on 32-bit architectures. Would that degrade performance? Are we not using kmap_atomic() in this patch because of any concern that the kmap fixmap space is limited and may run out? thanks, - Joel