Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp157413pxx; Wed, 28 Oct 2020 01:02:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjk6DdCEJqfIqs+4hwdt7VB6WnAJBI46x7xQkwubDOHFNGts7SwVO6ejx3nVkskGxzFJ9j X-Received: by 2002:a17:906:354c:: with SMTP id s12mr6492697eja.263.1603872130286; Wed, 28 Oct 2020 01:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872130; cv=none; d=google.com; s=arc-20160816; b=m9UwDondAD6JCJGilrxiemtm9dyUkepOMuytLI4YGba+tNnqCQgC9igC+g5Mmvi8Wd RylHfoeWVNfIa9M7Z4VINgakP9GJ1YWd7tc5IJZqYn8xrrXVNsUGaA5thEyA+2k3gHf2 Bg5FflU4qHuiCKyqjwocnS+rrQEZ3z/tDx+FfECrl0hJ5A/K4zNTqO6V4s3HTBJX37T6 QgFJAlA5GFkilRJeLuf5lbduIEXo+jj5sw7osIDsDCmKyiVpVK6V9cIMmeDuGTmdQLAf t+KcixF9S3TT8tGIlmSQHSP7VYkWsOvICSepb8H1vUz9ZQ+Y+Xp54WBpC2VnWJjPkdtY 64Fg== 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=eZqA+8v/3SSB7zydA5LRCwt/c2CksBccH5F9IJWzk0I=; b=KCjGhbGCViRfdL/h5ygoymG/3P3zDrCztHD8cyl2IFKVEaLHvXUuLlF+AID6PQzQ8u spwAF/AQWZd/FHUtBd5FWK62DkeC9/eYu9VVnXHienNOKmUljg2EKFAhQw11ppiLq+I/ /H1kgQ6ixedEFFC81cZdY8iMKMljmb4sKKLOjQWFDAWKMmm7jcw0bGKEmUIWGVD7Pa0n Hum/koXuXp0b+gjifFpCZdrDJgpalXueah5YDdN/ZeTKbzLCDQX0aP0xPlNgl28nevJ5 7ewgge4/LiUjmQyQ0GXcfF4k4TVFwR4GVIFjZEj0TITKJWEcKR24pGNbUCa9qU5ZznOs geDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XZ3V+DID; 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=fail (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 a42si3838927edf.535.2020.10.28.01.01.48; Wed, 28 Oct 2020 01:02:10 -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=@kernel.org header.s=default header.b=XZ3V+DID; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368135AbgJ0N5F (ORCPT + 99 others); Tue, 27 Oct 2020 09:57:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:43496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368116AbgJ0N5C (ORCPT ); Tue, 27 Oct 2020 09:57:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19FAA222C8; Tue, 27 Oct 2020 13:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807021; bh=UFH+PIYYf3yBfJFCGyzpNZn4BPeYskw+RFzwEqw2vcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZ3V+DIDl6VbpS8EaeSsJjP2tBoJnYojzM/113MrLkSPoHygw3PVQ4IQ8Dc3n2y2z AgqPGidrxsD8r4VfK6IbdYpJ2MoabbzGmjOww33ijKHLBw+c+9OQVQ0EjSOH0xkWos yITarhgLwFu9IKj1hmDQ1foREKSUWEkfT/fPxzjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Defang Bo , Jakub Kicinski Subject: [PATCH 4.4 014/112] nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download() Date: Tue, 27 Oct 2020 14:48:44 +0100 Message-Id: <20201027134901.234984715@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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: Defang Bo [ Upstream commit 280e3ebdafb863b3cb50d5842f056267e15bf40c ] Check that the NFC_ATTR_FIRMWARE_NAME attributes are provided by the netlink client prior to accessing them.This prevents potential unhandled NULL pointer dereference exceptions which can be triggered by malicious user-mode programs, if they omit one or both of these attributes. Similar to commit a0323b979f81 ("nfc: Ensure presence of required attributes in the activate_target handler"). Fixes: 9674da8759df ("NFC: Add firmware upload netlink command") Signed-off-by: Defang Bo Link: https://lore.kernel.org/r/1603107538-4744-1-git-send-email-bodefang@126.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/nfc/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1190,7 +1190,7 @@ static int nfc_genl_fw_download(struct s u32 idx; char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1]; - if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) + if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME]) return -EINVAL; idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);