Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3395421ybp; Sun, 6 Oct 2019 11:00:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYaiHMzw3UHbtTFGBFTrw6Va2oueQv6PoTyxmhjNaDJOEzdpvgLsHtAFQJnNzDMx3lVzoa X-Received: by 2002:a17:906:22c1:: with SMTP id q1mr13072352eja.325.1570384845268; Sun, 06 Oct 2019 11:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384845; cv=none; d=google.com; s=arc-20160816; b=CmA6HhwukEvc3nob5/x+RBA0OaRf95XTEdfqkC32Mcb/x42hr2akfUzvfj0kEgLX2r HYt56mNP7HVO07yRola5M/f3aw0lgKu3APDcxTCCW5LEWfcd/eB/mvETJLEH6FxTEbXi Udfx4dokB+rWRlfFrgrVdX5p5Us9+z2otnVm2iFXoFNmptSNo4HtNHvJj3LgQ80n4pg4 UsRhEguTIOqYLeikkC4Bz35YkfQpQJSEsq6lBNvEay+AftJwpAlEgSAYfa822RgG6Gno LCygnhjRgw4LnkSTxLvj6mHfx3Jz9n2iaEdXi/fRMLK+6qsnsCdNdlCGsE6nz6F1u1Ug u32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k0pzkBxbY1gZkiWNmKOnBBBAAoinCbPOfMxht2rI1go=; b=BFHckMAA5VCozWjdoPPtb3fpq8pM+TwSyO1+mi/3o3N0qJ2oeV5UN89RncY9WUQOic qSyjODUHrUf8ut4f1awS3EMwBqUB67FKgTz67ggNbaim+jXPxsHI2wQYbanxstzAGxk6 87E0wKnhzusdh6/Rl0bToFc2eJjNNpUma+19VrgsGwKF6CCfI8aeDeaG9gF9jGk8OH8t dhrKnSxPf8UWgaZQU8MP/9Z2UHhOjrQIEKWdODem2DZxoM7LdQMPIwwC3WKdIHYTB4Qh +Cn5e56/aDDSMRyvYtVzGrbFCcuvaqA8BMYHkVxHYCRx6xgdwOK+D3zfN7ljUaUX5r+i BRgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CJOkCvGF; 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 nj7si6022249ejb.262.2019.10.06.11.00.21; Sun, 06 Oct 2019 11:00:45 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=CJOkCvGF; 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 S1729586AbfJFRcb (ORCPT + 99 others); Sun, 6 Oct 2019 13:32:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:58952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729573AbfJFRc3 (ORCPT ); Sun, 6 Oct 2019 13:32:29 -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 72F3F2133F; Sun, 6 Oct 2019 17:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383149; bh=SQJ2TA1+dys19b096G1EEsqcCLyoAwdRC5caxt6qv2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJOkCvGFdGVGmCLiWbhf0vI8hY+FOUX6YutoVzqwtutyRDJjx4zKR9VeIkVc0R317 RWa+ZMqfMTRY00V4chUsRKvOHAgI8VHqczdgYcwtOMn8XI2MRUvSJ6C9cnVybzKCH+ OhUaECGB29VUFH07oSt0jCnqjeHAPNwzROQ/DcgI= 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.19 104/106] NFC: fix attrs checks in netlink interface Date: Sun, 6 Oct 2019 19:21:50 +0200 Message-Id: <20191006171204.760312069@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@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 @@ -981,7 +981,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]); @@ -1029,7 +1030,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]);