Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2826943pxb; Mon, 1 Nov 2021 02:38:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw68ZokWtj3Kxu56ZQwSYBgssCmibSePTIvAiBTD6QaOFArmVJhz4iKe+7v8Tw5/fc8EJph X-Received: by 2002:a17:906:6a0a:: with SMTP id qw10mr7572972ejc.141.1635759509444; Mon, 01 Nov 2021 02:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759509; cv=none; d=google.com; s=arc-20160816; b=zqhSp6oQtQ3WKiSJJ6QFcPS+oBlBCPW9AvFvTp8ONqVE8wUREIgav/ICvTu653Vdy6 KAoXlonKnzFBn+TiFkwXOwo7xuZLUC7sDQ1fNfEYaIqzAi49fxej/VLPGt6NsHdKcTW4 ro1VXPQEVTM28aYOjKBc0UjDq6/d/qzUgU+mgTYp5WSV2K5of9EjjLY7rhVRpbFMfntb sZSkS49/GoPBYVYULkElWCuFP6xgaThQwH6Cls2R1aEosWy0IQjuZOgIQi17SrWhK+Jv 93NrFDtjn0ootr4awEW1ekYOZAk0Hyvk05f02BbfWbF05SZ9te5MQeIDJ6pe0Lo4Jfr4 dslg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oVBZqMdj7IkYWsPGT5eVop+L4vig/P4xVxKrKFKhVd4=; b=blqjwy2xuvVQ/eRmVHA+VOlczwZcMw0rsmLm4xsHrnBMMoccknHor/RTw6iOyQZYCA 0om4gBjnj03G4BufD27pIHGPJQhKX89Jawut1DlOnLBMRtJer6P/NB0wQin/6cIR//Ns r45zek7ial+JFKBi9so45a8dy/b+aQ7Yt1DBl5Yv7SXE38FgBIk2AM+tV+tglx0CZ+NW CYLrpm0jblbtVVDE8Go6IC6RBps1EkEwl/Yab5zN00ngPKSckAsxzciybl34JFOekKV5 FrFuTHWghSwpdkoKbRc3QPgioMQSOKVsPa6oMAo3S5lnvVw6OsZ5srAjggoY/moEXgM8 JD+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2vwyGk+L; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ht17si24314049ejc.113.2021.11.01.02.38.04; Mon, 01 Nov 2021 02:38:29 -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=@linuxfoundation.org header.s=korg header.b=2vwyGk+L; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233887AbhKAJiY (ORCPT + 99 others); Mon, 1 Nov 2021 05:38:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbhKAJfs (ORCPT ); Mon, 1 Nov 2021 05:35:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 096A2610F7; Mon, 1 Nov 2021 09:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758765; bh=kCanV9jbpB0i0XOkDrbxtLn7ngkluchTu+lemPaNNBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2vwyGk+Lmh9vZ6PT/4JCwvgJQWElqu4q7BkMm/4ZhWEKCU8bvlXEZXNwE8viMFHFw 2xknDdlOvqyg9DmObBCG5zTEld4AIx9ZCED/6VGo/UY2n6t+xHc0siOMvKOPQF1E91 Fpq6nnofVWSIXTuwv6eP4AXH8HRPBSBkeyvqUIvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Xin Long , Christian Brauner , "David S. Miller" Subject: [PATCH 5.10 50/77] net-sysfs: initialize uid and gid before calling net_ns_get_ownership Date: Mon, 1 Nov 2021 10:17:38 +0100 Message-Id: <20211101082522.257342068@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long commit f7a1e76d0f608961cc2fc681f867a834f2746bce upstream. Currently in net_ns_get_ownership() it may not be able to set uid or gid if make_kuid or make_kgid returns an invalid value, and an uninit-value issue can be triggered by this. This patch is to fix it by initializing the uid and gid before calling net_ns_get_ownership(), as it does in kobject_get_ownership() Fixes: e6dee9f3893c ("net-sysfs: add netdev_change_owner()") Reported-by: Paolo Abeni Signed-off-by: Xin Long Acked-by: Christian Brauner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/net-sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1957,9 +1957,9 @@ int netdev_register_kobject(struct net_d int netdev_change_owner(struct net_device *ndev, const struct net *net_old, const struct net *net_new) { + kuid_t old_uid = GLOBAL_ROOT_UID, new_uid = GLOBAL_ROOT_UID; + kgid_t old_gid = GLOBAL_ROOT_GID, new_gid = GLOBAL_ROOT_GID; struct device *dev = &ndev->dev; - kuid_t old_uid, new_uid; - kgid_t old_gid, new_gid; int error; net_ns_get_ownership(net_old, &old_uid, &old_gid);