From patchwork Tue Aug 13 13:56:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijie Shao X-Patchwork-Id: 13762092 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 32D0719DF76; Tue, 13 Aug 2024 14:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723557767; cv=none; b=l8D3bs/hu6X+oiRlHf2DOg/aOANT3BjQmRE9YFno++VrM+rHX19e/djXQ6Z9xmo7JsFcj8osuVYUDEmHpNdFvQSAeVSet5HOxmDxdU4giKNHlpxsXrWOkmg9J7PGJ0aqwsdjEUm50aZYo/2s+vuhtm9VxgPxx9wM6Lz2jn6Ao/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723557767; c=relaxed/simple; bh=BVoF6xKSHJyIe3qsWJNAKz/mPt6vgQCUQQFOTncLDlQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lpqSFjy5lm4W/g7AFElPEewlfYp2c/OQ8clwGkA3Jm5HCUtrPBAbHUCbIvogIiUflNvloMc/SFhtMuaAHMqOFADl9PPBn7R0H/QbyWSQwQFe+ELQc8eK+u/Qodgzzfhc4ExW+AjUHHpoKapN9eDWftj47sLXoK/TC/c/QszNcn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4WjtJ00Jgxz1j6SL; Tue, 13 Aug 2024 21:57:52 +0800 (CST) Received: from kwepemm000007.china.huawei.com (unknown [7.193.23.189]) by mail.maildlp.com (Postfix) with ESMTPS id B81C31A0188; Tue, 13 Aug 2024 22:02:42 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 13 Aug 2024 22:02:41 +0800 From: Jijie Shao To: , , , , , , CC: , , , , , , , , , , , , Subject: [RFC PATCH V2 net-next 11/11] net: add is_valid_ether_addr check in dev_set_mac_address Date: Tue, 13 Aug 2024 21:56:40 +0800 Message-ID: <20240813135640.1694993-12-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240813135640.1694993-1-shaojijie@huawei.com> References: <20240813135640.1694993-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000007.china.huawei.com (7.193.23.189) X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC core need test the mac_addr not every driver need to do. Signed-off-by: Jijie Shao --- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index 751d9b70e6ad..ad86b8c939c1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9087,6 +9087,8 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, return -EOPNOTSUPP; if (sa->sa_family != dev->type) return -EINVAL; + if (!is_valid_ether_addr(sa->sa_data)) + return -EADDRNOTAVAIL; if (!netif_device_present(dev)) return -ENODEV; err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack);