Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp921829lqt; Tue, 19 Mar 2024 07:48:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBBGxqbRrJrzINtJfWfS1V9OS+Oiehl2X09uPhKsr7Zf5FwAroNC61HGGXOkbciKafSxv9jOZEWsrc0brFPOqZXAU94tR+SA5MeiAmNQ== X-Google-Smtp-Source: AGHT+IG0GLEjgyS+ybd/+OVgb4Mv0jjjhkOfUWGgAYi7b3rmpA4RrM+jkmFxF2Ree3gNy73yOkxu X-Received: by 2002:a05:620a:4152:b0:78a:1c47:e2e4 with SMTP id k18-20020a05620a415200b0078a1c47e2e4mr547880qko.30.1710859707463; Tue, 19 Mar 2024 07:48:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710859707; cv=pass; d=google.com; s=arc-20160816; b=gh7ztldWo7OgmofBhxpjCNcfT0UPuPssPWtlrXo8xjvF3DTXdbSevC08JZnUsrhaay qpLUcfE4ZY2HG8bSpc/iVaqJhm9h385erFBz4vfO2m+dxVVKOAXVQ8+UWdAO+YAYISlD zFFjrECyaCsqCMur07QjAV7D9fmTuPdL2fQ+Hj7N1ejYFhEoL7GYu6KAs/p8Vh3f2ZY6 beujuDPrRZQSnVPS/uiQWCYCtTpJ3HXpxRrPts1RPEyTKCyEUT2+L84dioO9WQvSAbMs E/AX1xW32y2eBou2Mx97jHBydabj/nONkE3PUh5g3/l26pum6caV4mKtFqcupF4HZYUW d+8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=KXPueMTAfrzqtSn8q0w7M4HgneSXU9ihcQnMvmzCGDA=; fh=TklTwo7qZ29YN2E/7KOrVecKqjM3OaqRYDBswiApIzQ=; b=PCpt1FSGNtywns5uV0u+5TIRv+Ok/DX0o18Q98C+WxmNswX//6CuWJQF3sE+DRR/di hAQvZsVAN4R9YSkz3tmYw2KeHBsxcjjVMQV/D9XO60lgFIjy5gMv32eJYY5zNto2hctp sSNkP9W0AH3sB//VTkKP3D6tqYXRHuH3N5mgLex8yXVZH5KZvDtAvO4Ty7O4YgBhiODQ 8kswDt2tnsYhxlpsrFKdDqNCM0VfWszxXrcTPbN1+F7ALeJTetk9P+OwckfSRlhooqE/ i/dYJma3ORc5c5d09a+wrJNJvPHW/Ps79MTgJz61xEhKxND9SRxmaewSLz4UMLskshO/ d/lA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XnyHI78T; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-107673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d16-20020a05620a159000b00789e8daf444si8193862qkk.219.2024.03.19.07.48.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 07:48:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XnyHI78T; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-107673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F1E081C229FE for ; Tue, 19 Mar 2024 14:48:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06932657A3; Tue, 19 Mar 2024 14:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XnyHI78T" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D4D01CD09 for ; Tue, 19 Mar 2024 14:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710859688; cv=none; b=MIq2shl4guv1yqHfAeyfOBZcaqu2fMI6qt8HibMR1DU96ckDMmvE9KkP3eo13jYEVoM1yAEsEvSt1rNLurW3FKKpzleQW1hJxnpaoWFF+wfkMvTBle8+TiIH9VpC1hpuYC5Fda9PrnT4AunxsTty43vPUGZIc1dbq7w0XcE4erM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710859688; c=relaxed/simple; bh=RlgzlVLtithqwcsBUwyF4k8tcSmUYR/TNIpOdEw5rIE=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=ZDvWgaN2/LZiXFSCE11XaKPxTpiO1rAOWdwFqfACqYY9lq5Hl5SbJeeWohN3NpiZ0k5MmhYjExUo/UBbFEfCtIzOdUsCHnuciAbYbFre1QlxACbhfFH9W1d/Rm9cmupntb4dDUJgyfesuojvjYPHGwp2N11AfM7fHesS5cp36Jk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XnyHI78T; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710859685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=KXPueMTAfrzqtSn8q0w7M4HgneSXU9ihcQnMvmzCGDA=; b=XnyHI78Tb7J3wCI3q0N9vONZQX+ZGAlbTFXHP/ELPieHXB/i/powbdQ+GTpgU7Wl0UFsUm aIsGlinspnwUrKJr9Sj+TdBCd0ax+km86UAo4eMO37dWBo+/aR3O46MPy2IKYdrllNKPSh wipLTiSz4doAAou734t7fJXpXHOcf+g= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-jv9OiEu1MrWipEvV49qpuQ-1; Tue, 19 Mar 2024 10:48:03 -0400 X-MC-Unique: jv9OiEu1MrWipEvV49qpuQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33ed3e8cf50so660983f8f.1 for ; Tue, 19 Mar 2024 07:48:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710859682; x=1711464482; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KXPueMTAfrzqtSn8q0w7M4HgneSXU9ihcQnMvmzCGDA=; b=Sh0NQ62TDn33Xd+eHsCyFdlc3fEtlny82HiJTIzDHEhr5Ty1I9EXTzdflAy7XCGAQG HokgoDwJqGNlVDbx8MiEma+FAf/iSISlNI9XUomauFBCcHzNNqHizG8TBxp0DP6A5A65 Kk9/toVBP6iUPWJZvM6YNp8W8mwzSokPpRRmOlnP/C4iByKB90b74GJkGRrm5MPCPzOo pQrg7fmqD+Fa+Nfy2l8ti8SfSfoR52nPQ1WVuAslO6NYdNRTElbr/VNIIg38UQtJ3rkc JLVOFU43A1+VeNAukJwSA1N6LflBiF4gUcqLao1YgaSjCj0a1RZ5dlSpib7442pgrKSK 3nww== X-Forwarded-Encrypted: i=1; AJvYcCV4Q1yjQYvedqYh3pu5jTuVrxpjnV8Z4AQfFLgxV8NMPTWG9d4/313bxkW7yT1G4Z+qBJWKa9HMQvcRlavEuG1VeJZFq2aLbd8fO2wK X-Gm-Message-State: AOJu0YwacwPlBXlOdYIgTOfaB/K19IIyyEeT9q2VSqrG5AlwRPBcvL9+ UoFK0oQD7sFqm0xeuQ8SrkObd6nD+BCvuRV+ksQj/2JgpfEQWHCsTPYH1CT882tZ5ikiRDcFy93 hpqA/C8zK/jh5r7q+C6l/QzcRIlu6G5kYWgkqnmDMMsb7Bs2CwaLO0fqcK7Ze1w== X-Received: by 2002:a05:6000:e46:b0:33e:1eea:33b1 with SMTP id dy6-20020a0560000e4600b0033e1eea33b1mr2145178wrb.4.1710859681848; Tue, 19 Mar 2024 07:48:01 -0700 (PDT) X-Received: by 2002:a05:6000:e46:b0:33e:1eea:33b1 with SMTP id dy6-20020a0560000e4600b0033e1eea33b1mr2145156wrb.4.1710859681487; Tue, 19 Mar 2024 07:48:01 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-224-202.dyn.eolo.it. [146.241.224.202]) by smtp.gmail.com with ESMTPSA id bo6-20020a056000068600b003418016b04csm3689253wrb.76.2024.03.19.07.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 07:48:00 -0700 (PDT) Message-ID: <5a1e45fd0bb89faa906866b7525210f4aaecab2e.camel@redhat.com> Subject: Re: [PATCH] net: always initialize sysctl ownership From: Paolo Abeni To: Kuniyuki Iwashima , linux@weissschuh.net Cc: davem@davemloft.net, dmitry.torokhov@gmail.com, ebiederm@xmission.com, edumazet@google.com, j.granados@samsung.com, kuba@kernel.org, linux-kernel@vger.kernel.org, mcgrof@kernel.org, netdev@vger.kernel.org Date: Tue, 19 Mar 2024 15:47:59 +0100 In-Reply-To: <20240316003958.65385-1-kuniyu@amazon.com> References: <20240315-sysctl-net-ownership-v1-1-2b465555a292@weissschuh.net> <20240316003958.65385-1-kuniyu@amazon.com> Autocrypt: addr=pabeni@redhat.com; prefer-encrypt=mutual; keydata=mQINBGISiDUBEAC5uMdJicjm3ZlWQJG4u2EU1EhWUSx8IZLUTmEE8zmjPJFSYDcjtfGcbzLPb63BvX7FADmTOkO7gwtDgm501XnQaZgBUnCOUT8qv5MkKsFH20h1XJyqjPeGM55YFAXc+a4WD0YyO5M0+KhDeRLoildeRna1ey944VlZ6Inf67zMYw9vfE5XozBtytFIrRyGEWkQwkjaYhr1cGM8ia24QQVQid3P7SPkR78kJmrT32sGk+TdR4YnZzBvVaojX4AroZrrAQVdOLQWR+w4w1mONfJvahNdjq73tKv51nIpu4SAC1Zmnm3x4u9r22mbMDr0uWqDqwhsvkanYmn4umDKc1ZkBnDIbbumd40x9CKgG6ogVlLYeJa9WyfVMOHDF6f0wRjFjxVoPO6p/ZDkuEa67KCpJnXNYipLJ3MYhdKWBZw0xc3LKiKc+nMfQlo76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RLNApEA7C2nX6RW0XmA53PIQvAP0EAakWsqHoKZ5WdpeOcH9iVlUQhRgemQSkhfNaP9LqR1XKujlTuUTpoyT3xwAzkmSxN1nABoutHEO/N87fpIbpbZaIdinF7b9srwUvDOKsywfs5HMiUZhLKoZzCcU/AEFjQsPTATACGsWf3JYPnWxL9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-03-15 at 17:39 -0700, Kuniyuki Iwashima wrote: > on Fri, 15 Mar 2024 17:20:31 +0100 Thomas Wei=C3=9Fschuh =20 > > diff --git a/net/sysctl_net.c b/net/sysctl_net.c > > index 051ed5f6fc93..03e320ddacc9 100644 > > --- a/net/sysctl_net.c > > +++ b/net/sysctl_net.c > > @@ -62,12 +62,10 @@ static void net_ctl_set_ownership(struct ctl_table_= header *head, > > kgid_t ns_root_gid; > > =20 > > ns_root_uid =3D make_kuid(net->user_ns, 0); > > - if (uid_valid(ns_root_uid)) > > - *uid =3D ns_root_uid; > > + *uid =3D uid_valid(ns_root_uid) ? ns_root_uid : GLOBAL_ROOT_UID; > > =20 > > ns_root_gid =3D make_kgid(net->user_ns, 0); > > - if (gid_valid(ns_root_gid)) > > - *gid =3D ns_root_gid; > > + *gid =3D gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID; > > } >=20 > How about setting the default in proc_sys_make_inode() instead ? > because the default value configured by new_inode() is not I also think that could be a better option, as the caller is already providing default values in some cases. Cheers, Paolo