From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 876EEC10F14 for ; Sun, 6 Oct 2019 17:27:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5350F2087E for ; Sun, 6 Oct 2019 17:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570382868; bh=B6BL85jY4OkpSWiUv0mD608NVnEBdyIGCZju8gkYxBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AxD65StzN4Qe7CqEGOMSQT6R9UDHNuSNgiUJzP10snAIoZqRj4K1CetbPOYkFqwPw uuMO+ZInOvl2Ug/N7Aqxdy5Qr9NtC0Dqt69Bxh/pppxDv0pQM98ufjP3xxOsWsv5nl 6jYzUupg19w3gcZMLkow5ROg+R/koKssWzCejHFY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbfJFR1r (ORCPT ); Sun, 6 Oct 2019 13:27:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:53222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbfJFR1p (ORCPT ); Sun, 6 Oct 2019 13:27:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 AC5692087E; Sun, 6 Oct 2019 17:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570382865; bh=B6BL85jY4OkpSWiUv0mD608NVnEBdyIGCZju8gkYxBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxedjKSOugwsLvLx2ScYY3jB2nQqyLG+ZVJbJnVKG9Zur/LTdmefPD9p+dJifJg5/ mQ1PmgayWP96yPekH/cYj7yBjYR2c2mrk+79RGRzu5ue3SaQzOEDrgHe6ykoA2WtAm SetzzQpsGfEZfzg79bolILgBCU++PJbQ7eLB1diY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Andy Shevchenko , "David S. Miller" Subject: [PATCH 4.14 67/68] NFC: fix attrs checks in netlink interface Date: Sun, 6 Oct 2019 19:21:43 +0200 Message-Id: <20191006171139.523099025@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171108.150129403@linuxfoundation.org> References: <20191006171108.150129403@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov commit 18917d51472fe3b126a3a8f756c6b18085eb8130 upstream. nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX attribute being present, but doesn't check whether it is actually provided by the user. Same goes for nfc_genl_fw_download() and NFC_ATTR_FIRMWARE_NAME. This patch adds appropriate checks. Found with syzkaller. Signed-off-by: Andrey Konovalov Signed-off-by: Andy Shevchenko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/nfc/netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -970,7 +970,8 @@ static int nfc_genl_dep_link_down(struct int rc; u32 idx; - if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) + if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || + !info->attrs[NFC_ATTR_TARGET_INDEX]) return -EINVAL; idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); @@ -1019,7 +1020,8 @@ static int nfc_genl_llc_get_params(struc struct sk_buff *msg = NULL; u32 idx; - 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]);