Received: by 10.223.185.116 with SMTP id b49csp1112101wrg; Fri, 23 Feb 2018 12:08:17 -0800 (PST) X-Google-Smtp-Source: AH8x2255ZVibaLnZDvvqxuWlOPBVFefEQV544bJIPZFb8LaQ+TP89AzF6Wviyrz+5WibYuOb7ycE X-Received: by 2002:a17:902:7681:: with SMTP id m1-v6mr2809332pll.144.1519416497826; Fri, 23 Feb 2018 12:08:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416497; cv=none; d=google.com; s=arc-20160816; b=XOLo6e1lymPM8PPYFs2/ex9cTSIthBbtsi6A/24Xr0bO0ipFd/Da4QyoFxEdqOwwlU QH2RFGhSnYpwuyVSFkStQsZyNQuowFG/3faX1j3C32CaN6wu4kZPFMG52GHf20Qh1Keu JlDTN2IvDIvoqgTawyen8L1T5WNHQ1IQL3X0SQFGP+t4fQUB7GbxVUlH+UHFPWSvX9tt 5826q3Jpjbww8o59OaCrLg3G3zP2aVzajBQzPvhQjq6tP7wt6MkJuDywCfBC/x1GMoAC LvKL/+2/dbl6jOq9UBVDpSz8D2GrCDm9tNjj87g7Bne3gNd3b0mAWbVdxyjknoDunW/y 3v5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rds9WsaNyHcs/6DJWnfH8Gq/yQnfNeAobPgoZn/0l9k=; b=rdSTKoH/Ur/vyk4vlwimLjCOU+3yIh0jkap6m99P6OXKIwW6r+MlpdOB9LPFfg+B1s rmXhmOkeCYVqqWfzidsvYgAHSzVCUH788xlPvK1PkHewAsFyo0V1l2bn9cgU+FeKNFpr UTI8FYlBj38/ztEgibKoXwoYh9wpmJaaD/K+YEU4XdN+xIIi/zckfqf81QYzIiYzIY5O ki5q/PmWle25BJ7lFIkL8pDEzLt78xQqm+yIjy7AT1KNjCVe05Z/b602KTQL5nctO6NH AR4js7hfFpbvuTu6IoWP95tnhZZQ5zwA+IoijwcUu/9rKoI0aSdVntvpX31PJN/fiHbh kOdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2-v6si807635pll.382.2018.02.23.12.08.03; Fri, 23 Feb 2018 12:08:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755114AbeBWUHO (ORCPT + 99 others); Fri, 23 Feb 2018 15:07:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41956 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932769AbeBWSmy (ORCPT ); Fri, 23 Feb 2018 13:42:54 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F2D551011; Fri, 23 Feb 2018 18:42:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+1ddfb3357e1d7bb5b5d3@syzkaller.appspotmail.com, Johannes Berg Subject: [PATCH 4.9 004/145] cfg80211: check dev_set_name() return value Date: Fri, 23 Feb 2018 19:25:10 +0100 Message-Id: <20180223170725.307645045@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Berg commit 59b179b48ce2a6076448a44531242ac2b3f6cef2 upstream. syzbot reported a warning from rfkill_alloc(), and after a while I think that the reason is that it was doing fault injection and the dev_set_name() failed, leaving the name NULL, and we didn't check the return value and got to rfkill_alloc() with a NULL name. Since we really don't want a NULL name, we ought to check the return value. Fixes: fb28ad35906a ("net: struct device - replace bus_id with dev_name(), dev_set_name()") Reported-by: syzbot+1ddfb3357e1d7bb5b5d3@syzkaller.appspotmail.com Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -421,6 +421,8 @@ struct wiphy *wiphy_new_nm(const struct if (rv) goto use_default_name; } else { + int rv; + use_default_name: /* NOTE: This is *probably* safe w/out holding rtnl because of * the restrictions on phy names. Probably this call could @@ -428,7 +430,11 @@ use_default_name: * phyX. But, might should add some locking and check return * value, and use a different name if this one exists? */ - dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx); + rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx); + if (rv < 0) { + kfree(rdev); + return NULL; + } } INIT_LIST_HEAD(&rdev->wiphy.wdev_list);