Received: by 10.223.185.116 with SMTP id b49csp6366526wrg; Wed, 28 Feb 2018 08:14:42 -0800 (PST) X-Google-Smtp-Source: AG47ELs5i2M+Wc6OSW20YfHNM+oKKA+jXbfhWx+B74uizckcpBf7a2bxETajuLH1uCtp8Z3WoMf/ X-Received: by 2002:a17:902:3084:: with SMTP id v4-v6mr10810349plb.102.1519834482360; Wed, 28 Feb 2018 08:14:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519834482; cv=none; d=google.com; s=arc-20160816; b=QYEWdni+BcdlX7E6n6efyhB1Rbgi6nca4H9+oZyTfFEHLzAWOAedxTsTUS8SJ/6rnG 32LN7ZXmvIpgDWTHRzvBsZUHdVCs06kZkpIgRkecXHrmGJiHtvLLckM6kIIv3jjpFWCs evbCFUQ+E6EfexYtjQ7f9MBwDCB89i1p6KzgQtriDxDfBR30ssGrC0lefJiElTJjt54t 2hpwMI06Eh1+ZO83HF1p3OiOoGI9w8VBxehuBcHX6iu45fwUeRmmtfAEAEUjd3qVG9d1 P4IwjM8nkszCrlnticzObGypkUrmlhuUW42insoG5JluXSuhABMiOV78SQwA0OuUrhzw NtiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=rLV8AqY9FLSdGEDWk5BFiZ94pxTzLWYnFhpxEpetweM=; b=i3yBvWYLWAwDrD/GwRycASY+yG8FeDjPjz6JkcMysFdYisoTGV9d+6+q8qaga0aX+y oKynhERwC2NL/Jo7OphbkHYTahL46FMM6WFydaDDyjQLzE63R7IHgPVyJ0aX4cnkxBHd in97zK5g0NRkOPzuPLnQsl/KEKIUARfv1jSrLsGPtuTGDxFBYZufZBkF2Zrq0J3R1+g+ YZBcQ+Bp1W/or5Qz5rVUzwLthuDEULUe7PZLNndlUgeWY53o3pak6r0LndLPQTPKB9rL fmn4VoVkJ2a9d0+KZzaRL7Nyvq0Fh9qeP1b4Ip/GK+nc1wXfMbY6SGMdvCfEKfPu93Bf edCQ== 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 r6-v6si1488132pls.13.2018.02.28.08.14.27; Wed, 28 Feb 2018 08:14:42 -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 S933111AbeB1QNU (ORCPT + 99 others); Wed, 28 Feb 2018 11:13:20 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35023 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933272AbeB1QMA (ORCPT ); Wed, 28 Feb 2018 11:12:00 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yp-0006Xh-IV; Wed, 28 Feb 2018 15:22:27 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yj-0000GU-UQ; Wed, 28 Feb 2018 15:22:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, syzbot+1ddfb3357e1d7bb5b5d3@syzkaller.appspotmail.com, "Johannes Berg" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 207/254] cfg80211: check dev_set_name() return value In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -315,6 +315,7 @@ struct wiphy *wiphy_new(const struct cfg struct cfg80211_registered_device *rdev; int alloc_size; + int rv; WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key)); WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc)); @@ -346,7 +347,11 @@ struct wiphy *wiphy_new(const struct cfg rdev->wiphy_idx--; /* give it a proper name */ - 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->wdev_list); INIT_LIST_HEAD(&rdev->beacon_registrations);