Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1668211imu; Fri, 9 Nov 2018 22:38:57 -0800 (PST) X-Google-Smtp-Source: AJdET5fLtozP1aAb/o/eKQIxxHJGuoS7tRQ2+wTc4WpHnqBGi73GjLc7eSiwHxqjVp/XvCebCKDL X-Received: by 2002:a62:4502:: with SMTP id s2-v6mr7760783pfa.31.1541831937602; Fri, 09 Nov 2018 22:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541831937; cv=none; d=google.com; s=arc-20160816; b=086UKQPsZlbuZ1eksraQQwbcR38AvrLlKX7o516G98MiF0GZIyCRJWHr5GxyCg64zP B57TlD3Z5of7aE1GZzPTA8NCKfLc7c3TBf0DOVtNm7ggF6Pzw4NHkmDte4aSWoh9jXrd 3rmJ8Nh40cn6oH+kxDurqYlzKj9JMa46uOv0L0q+jSFJjeWL/5fKAyd52SXRES67j9eV 4+OICJrMIm5SJnZGmmDC09+dEyiUJH5MNOAD460f5MxX5OLy37K+jN9C/1+d89UDZMYl gIkDGbCe4sOjDSj72CLL9Iv2+DpnGBM3ipbP54nqpBA0Rd2xBBZI3Dhpn0RZaYjtZttE EPiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CWqz3DjLLmg+s3XuvAvcG7DA2KqfIjnBfFPWEJlzW5c=; b=pN4N1TDyM4/DqgpqNCu6EQfC8tVqOH8+t9l+AzQ9K84tB6liVMVrw4TVopiq6T+BkZ t6y65bgejufymwVDYq8Bi5z39mMczUAE+z8i0BN2aWJDXgDBkqC9OOLGjeSv64ppLmis PWcIIzm/4K0FC3Mz1GKVcONw0WHqjODiiYOUVqatii5TOQ/pieM07M5raa7ht+nnh2wM 7RmOLORG5u4+wA2J+aGQlGeL/EcuYCI8Pog/8pjDhuQc7Sx6JWdhZ2l1edTJTwndNQHZ f6dSrQZ2YNpK9oyStzndYCikznBHF8sOzOjTfHh1+N7hPjt1udiqROik40kn6niVPEkx s1+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B5uUPUx9; 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 w5-v6si8713073pgj.506.2018.11.09.22.38.42; Fri, 09 Nov 2018 22:38:57 -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=B5uUPUx9; 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 S1728817AbeKJQWI (ORCPT + 99 others); Sat, 10 Nov 2018 11:22:08 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36656 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbeKJQWI (ORCPT ); Sat, 10 Nov 2018 11:22:08 -0500 Received: by mail-lf1-f65.google.com with SMTP id h192so2884960lfg.3 for ; Fri, 09 Nov 2018 22:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CWqz3DjLLmg+s3XuvAvcG7DA2KqfIjnBfFPWEJlzW5c=; b=B5uUPUx9IFG5d4DjsO91uTQCgz+/ifl3l1Au17BZtYxq3qcgQt41kyGCZvO0yPcI8W 0rOvL5Dk1J7xsL28J1P6t27y/xBAxD39yOn0gaPjhuDL4SIR3rRi+vb21cI4whKTh2d4 wKBd/CN9xj81WiOjbASvFaDGEVSe9/KmTg1By5Sw8JXDw6MV08X14uhJxq3R4vCCq0I9 nUW/F58VU6Ce6mA2DmXjcwbubNWXntPhKNgqoXKsHO6y25rdHRwTZonSfhAl4hHGuLoJ YSQ71stCY5fMqY+JArOeJV9b19qAlT7KWb287arhSYr95Lh+fZwDR31sbBehq8xdyq4J 5bQg== 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:content-transfer-encoding; bh=CWqz3DjLLmg+s3XuvAvcG7DA2KqfIjnBfFPWEJlzW5c=; b=MhKGeSnxirlOgfzW8pBovOc9USYBXvShlTFBoh7YvN8+wN7G9QC748piON/XAvycAS 8+iZE7XWTDYMTI1t56NB5ZW5we/pHt+WWk+ABPgvgNZunlCpG6eSeIlMNGh9qEHjF5oM vxv2MMkf8ldevZypN7yRel7EPy+4oSYizIojUlwyzzYqHoEXzrme/UaJR2HvCARh6CiW zzCHLwQBj2PZ3k3lqk/hlpXNADurQtz2gJwy5r5HVab48oMN3o3rEevQcRXY1Hm1Yk/s dRQQtyBFrXbM0hHSjIgXhIW/GhSIfrX/CovJSMNOK2YyjVHzN/H4/12m3CTJOGamt28j lGSg== X-Gm-Message-State: AGRZ1gJcRRGrDbLl306lE7q2kppBms3NQVU73VCKdPaKElrEpdU56jex bAayyKbw2cOI35s6r1WZZFK7O4UKAfRtFE03shX4vQ== X-Received: by 2002:a19:1cb:: with SMTP id 194mr7070838lfb.61.1541831894492; Fri, 09 Nov 2018 22:38:14 -0800 (PST) MIME-Version: 1.0 References: <5FBCBE569E134E4CA167B91C0A77FD610198F851AC@EXMBX-SZMAIL022.tencent.com> <5FBCBE569E134E4CA167B91C0A77FD610198F8A217@EXMBX-SZMAIL022.tencent.com> <5FBCBE569E134E4CA167B91C0A77FD610198F8A4B2@EXMBX-SZMAIL022.tencent.com> <5FBCBE569E134E4CA167B91C0A77FD610198F8A65C@EXMBX-SZMAIL022.tencent.com> In-Reply-To: <5FBCBE569E134E4CA167B91C0A77FD610198F8A65C@EXMBX-SZMAIL022.tencent.com> From: Todd Kjos Date: Fri, 9 Nov 2018 22:38:02 -0800 Message-ID: Subject: Re: Re: [PATCH V3] binder: ipc namespace support for android binder(Internet mail) To: chouryzhou@tencent.com Cc: Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , akpm@linux-foundation.org, dave@stgolabs.net, "open list:ANDROID DRIVERS" , LKML , chouryzhou@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 9, 2018 at 9:43 PM chouryzhou(=E5=91=A8=E5=A8=81) wrote: > > > > > > > If IPC_NS is disabled, "current-nsporxy->ipc_ns" will also exists, i= t will be a static > > > reference of "init_ipc_ns" (in ipc/msgutil.c, not defined in binder.c= by me) with > > > no namespace-ization. You will get the same one in all processes, eve= rything is > > > the same as without this patch. > > > > except, as far as I can tell, binder_init_ns() would never have been > > called on it so the mutex and list heads are not initialized so its > > completely broken. Am I missing something? How do those fields get > > initialized in this case? > > > @@ -5832,8 +5888,12 @@ static int __init binder_init(void) > > goto err_init_binder_device_failed; > > } > > > > - return ret; > > + ret =3D binder_init_ns(&init_ipc_ns); > > + if (ret) > > + goto err_init_namespace_failed; > > > > + return ret; > > They are initialized here. Ok, This init_ipc_ns is a global declared in msgutil.c if SYSVIPC || POSIX_MQUEUE. This seems kinda hacky, but now I finally see why the dependancy... msgutil.c is the only file we can count on if !IPC_NS && (SYSVIPC || POSIX_MQUEUE). There must be a cleaner way to do this, I really don't like this dependency... wouldn't it be cleaner to do: #ifndef CONFIG_IPC_NS static struct ipc_namespace binder_ipc_ns; #define ipcns (&binder_ipc_ns) #else #define ipcns (current->nsproxy->ipc_ns) #endif (and make the initialization of binder_ipc_ns conditional on IPC_NS) This gets us the same thing without the incestuous dependency on the msgutil.c version of init_ipc_ns...and then binder doesn't rely on SYSVIPC or POSIX_MQUEUE directly. > > - choury - >