From patchwork Tue Oct 27 13:49:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307026 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 8BB20C55179 for ; Tue, 27 Oct 2020 17:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C91922400 for ; Tue, 27 Oct 2020 17:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603820807; bh=cfV8T+Ru9AOsXNkhf9qmxbj6PykI5w+nPzTghM6P43Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nEmx16Gvmjj2YgzJlcR9j2TM70XjI3O0KRaaGaq4Tfdjkd6oBzFJTf+7puuR/4F2v 3TpeuWuobQ3m0Usx2eRbrxTCO+NXncJR+Poc2fOqFG8KbBCR+KytXB2rxkVN+jq+fi 76TeAtTwfRZ8Isf9mKMxagwbhy+Sxe9X9rN5B/Wc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896767AbgJ0Oag (ORCPT ); Tue, 27 Oct 2020 10:30:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902085AbgJ0O3w (ORCPT ); Tue, 27 Oct 2020 10:29:52 -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 50F232222C; Tue, 27 Oct 2020 14:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808990; bh=cfV8T+Ru9AOsXNkhf9qmxbj6PykI5w+nPzTghM6P43Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7rCKL5v5emFRT3gu75VZpt+Ctnmr6uFM/GcFyk1863D9rzDWzdO/xQfiKCXATcrH p6GVmG+5szXtPf2tBihUxJ0QcAovKB/y56N47NjGdax5ptWBcz5TM8Ft7vaELUsBE6 S4mW0//N2GT9Bs80Qy1ih2rpiNEd8rCZFO8N/dPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Defang Bo , Jakub Kicinski Subject: [PATCH 5.4 035/408] nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download() Date: Tue, 27 Oct 2020 14:49:33 +0100 Message-Id: <20201027135456.706047584@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1225,7 +1225,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]);