From patchwork Sun Mar 21 16:32:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 12153139 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F774C433DB for ; Sun, 21 Mar 2021 16:33:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6350C601FC for ; Sun, 21 Mar 2021 16:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbhCUQco (ORCPT ); Sun, 21 Mar 2021 12:32:44 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:34576 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbhCUQcN (ORCPT ); Sun, 21 Mar 2021 12:32:13 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id EAFE51C0B78; Sun, 21 Mar 2021 17:32:10 +0100 (CET) Date: Sun, 21 Mar 2021 17:32:10 +0100 From: Pavel Machek To: kernel list , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eric Dumazet , Wei Wang , Cong Wang , Taehee Yoo , =?iso-8859-1?q?Bj=F6rn_T=F6pel?= , netdev@vger.kernel.org Subject: net/dev: fix information leak to userspace Message-ID: <20210321163210.GC26497@amd> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org dev_get_mac_address() does not always initialize whole structure. Unfortunately, other code copies such structure to userspace, leaking information. Fix it. Signed-off-by: Pavel Machek (CIP) Cc: stable@kernel.org diff --git a/net/core/dev.c b/net/core/dev.c index 6c5967e80132..28283a9eb63a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8949,11 +8949,9 @@ int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name) ret = -ENODEV; goto unlock; } - if (!dev->addr_len) - memset(sa->sa_data, 0, size); - else - memcpy(sa->sa_data, dev->dev_addr, - min_t(size_t, size, dev->addr_len)); + memset(sa->sa_data, 0, size); + memcpy(sa->sa_data, dev->dev_addr, + min_t(size_t, size, dev->addr_len)); sa->sa_family = dev->type; unlock: