Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2321248pxy; Tue, 3 Aug 2021 03:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhXjI9muvZufREGkFz9gCjQGguzYRNfAVEd1g9L9/euiC8PHPuhNHOi8NG/x2seqV8Zucx X-Received: by 2002:a17:906:3a57:: with SMTP id a23mr20034966ejf.469.1627986972195; Tue, 03 Aug 2021 03:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627986972; cv=none; d=google.com; s=arc-20160816; b=LDaimoU91c8xt5WoKZ3EEUUBoZB3bo/luK4Z2ZrXkEgs7wD9zpklyRpDwR9HmStrid OxHcwfpbVZaw2f4AjPwG4slpuFCLQm9z2UaJYRd+KTewP5rC71ptJfHVtguGnqP8C7nQ 5xaVr2m8mS6XhoY5+Egg7ukp14icb3IcvhbBWsheClK55o5Z666Tvby3T0rDyuWLcYok nMpw4vBDO8r4jUcHgbYaYJnAanzsUW9sIYRjh6+EHtENxG9gXv2WrXuXXW+NWfRAVfnX xwFYJcMBCal6EdvVU1vNhUEsEGXrZCBwjwZeAcrPerAyDFxcbBqfWrh2chFAJ5yKCqyp ZFsA== 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=M+P09UYsgBUeZcTU8h1JnZ3LSSnMLTRIwZzJkf+vohM=; b=B4TZHh0y1Bms+aY2Ys6lKtrBCzUl7o31u7aqmoUs8Yk8Zy23rP9yWnNyAq0GN7106E wnajGyUqWpXHmC98+R/n18dY6ZeZOHkBAyvhaucszQL0Nv3q6p+4x+EurlHgMeHCmNVT 2kvj6zGV1aTm3Vqecs8hjPtN5Jk4k3MJs0Sl464UJdk8Tc79G8PuE10DtP8dcvBpkK4Y tuXcHrCewZ/lnZTsDz8LLHriFG5VtDAPUMnDa23rFq7WTFNWdD+zWFMq/tfLbMyRdO1L zXpzxHOuyT4TzHCw0Zz2zEZtG6m9MeaWRm59UbVlDRQlpLVmIRGuJ9LYm1PNx2HghnFt V4nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aYiS8O6y; 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 s11si14003463edh.361.2021.08.03.03.35.46; Tue, 03 Aug 2021 03:36:12 -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=aYiS8O6y; 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 S235058AbhHCKeK (ORCPT + 99 others); Tue, 3 Aug 2021 06:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234674AbhHCKeH (ORCPT ); Tue, 3 Aug 2021 06:34:07 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775EAC06175F for ; Tue, 3 Aug 2021 03:33:55 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so4062854pjb.2 for ; Tue, 03 Aug 2021 03:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=M+P09UYsgBUeZcTU8h1JnZ3LSSnMLTRIwZzJkf+vohM=; b=aYiS8O6yfH4RXLh5tsW0rUzfNmOf85niYQL8XSJr6R+tGFje/QeWK6zhSNG2RIzmks 9Rozjsh2h+s/sTo4APqNHzLhnUbSKFKupmoTIqSi3pZu9GhMBFOU4Ykxj6VKzGuMJ/7d qLOla3h3ZswF/uHIM7eVNH3If6KctvKTPrwfgGk6eROEm6zY008X/7Xe86q2ZHPSjqA7 doMW1AofGD+8P8BgqLZCsCDALihzXGtvyJi6lbzSROXMhL9DWeo7mSR5keU5XFav+B6u 0z+yzT6W4aPpm/71b1gkIb3V1oo9nz2vtpTRkGEgBcptT7LyvRF+LmS3Vtd0z43uf1XC hxzg== 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; bh=M+P09UYsgBUeZcTU8h1JnZ3LSSnMLTRIwZzJkf+vohM=; b=S/eE/CLkSwZdGX7tEeHUjnE4+Velu2W7Ycm0WkHt67IFS/lbMnsK4a2xreJr31o/LM /3WL2WFRCcAhkGR0H4zU+QJ5XgQS2NuMgb2eUQImOkuTWmjgDS5aT098wTNMwrtTRXpt i67XOLPavraF6G24GfW8ISfCIdjMcfJotb62ZspKmKUK0p+RePh1oFNapC1s/9WSOXcn QLBiE8UD5nSLc2S1gL4X6dooNtdd5BGn2LDt/n76PkQfV6t05KDE7LqNsae7w2K1w8A1 ylN+wbHQeVfZTpwfHuxdRH4vzEuM0QQqGAcqxbRbsAA8PQJXLoCkdSlvxQNx/Nl/kjWZ txSA== X-Gm-Message-State: AOAM533LN4S6KvV0CBtaj7A2LHyKFseYnF/o2OipHtDY7BAfocYZ9cb7 v2Ed1VZ1cHVcq52hIeuJd0Q= X-Received: by 2002:a17:903:1203:b029:12b:599b:524c with SMTP id l3-20020a1709031203b029012b599b524cmr18090633plh.10.1627986835078; Tue, 03 Aug 2021 03:33:55 -0700 (PDT) Received: from localhost ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id n7sm10364089pjh.8.2021.08.03.03.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 03:33:54 -0700 (PDT) Date: Tue, 3 Aug 2021 03:34:45 -0700 From: CGEL To: Davidlohr Bueso Cc: keescook@chromium.org, christian.brauner@ubuntu.com, ktkhai@virtuozzo.com, jamorris@linux.microsoft.com, varad.gautam@suse.com, legion@kernel.org, linux-kernel@vger.kernel.org, Ran Xiaokai Subject: Re: [PATCH] ipc: add set_ownership() and permissions() callbacks for posix mqueue sysctl Message-ID: <20210803103445.GB607784@www> References: <20210729030651.536326-1-ran.xiaokai@zte.com.cn> <4b67a8df7823cc14ffb69657c82562b2@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b67a8df7823cc14ffb69657c82562b2@suse.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org O Fri, Jul 30, 2021 at 08:09:32AM -0700, Davidlohr Bueso wrote: > On 2021-07-28 20:06, cgel.zte@gmail.com wrote: > > This patch adds a ctl_table_set per ipc namespace, and also the > > set_ownership() and permissions() callbacks for the new ctl_table_root > > for ipc mqueue syscgtls. > ^^ sysctls > > This makes sense to me, just some nits below. > > Acked-by: Davidlohr Bueso > > > > > Signed-off-by: Ran Xiaokai > > --- > ... > > +static int set_permissions(struct ctl_table_header *head, > > + struct ctl_table *table) > > +{ > > Please use curly braces for the else. > > > + return (mode << 6) | (mode << 3) | mode; > > +} > > + > > +static void set_ownership(struct ctl_table_header *head, > > + struct ctl_table *table, > > + kuid_t *uid, kgid_t *gid) > > +{ > > + struct ipc_namespace *ipc_ns = > > + container_of(head->set, struct ipc_namespace, mq_set); > > + struct user_namespace *user_ns = ipc_ns->user_ns; > > + kuid_t ns_root_uid; > > + kgid_t ns_root_gid; > > + > > + ns_root_uid = make_kuid(user_ns, 0); > > + if (uid_valid(ns_root_uid)) > > + *uid = ns_root_uid; > > + > > + ns_root_gid = make_kgid(user_ns, 0); > > + if (gid_valid(ns_root_gid)) > > + *gid = ns_root_gid; > > +} > > Could set_permissions() and set_ownership() be factored such that we can > avoid duplicated code between ipc and net ns? Something like: > > void set_permissions(struct ctl_table_header *head, struct ctl_table *table) > { > struct ipc_namespace *ipc_ns = container_of(head->set, struct > ipc_namespace, mq_set); > set_permissions_common(ipc_ns->user_ns); > } > > Thanks, > Davidlohr Hi Davidlohr Thanks for your comments. I will sent a v2 patch together with Christian's comments.