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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26A81EE14C3 for ; Wed, 6 Sep 2023 23:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244759AbjIFXeM (ORCPT ); Wed, 6 Sep 2023 19:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240901AbjIFXeL (ORCPT ); Wed, 6 Sep 2023 19:34:11 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC1EE66; Wed, 6 Sep 2023 16:34:06 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 916C65C00E3; Wed, 6 Sep 2023 19:34:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 19:34:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jcline.org; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1694043243; x=1694129643; bh=vBTjdMfz1C O5+QvldXBB+2bQ59B3jeU81T91GJRZKcc=; b=lCbZbYYS3BAZ5uNKthMk1f2xTa Fai2IZ8aUGUTKsBa07bR8OklHlqG2i35GZqaBndYGzq2G+s6q+wh3gpiypHMHkv0 VgUeQbWrCOuMtmTlFY+iWtQhvgGiwunlAghInQvPUhsdvRQkEtCVsU+dw/9oieLG DcmrWC7/mZ3exbfVNeXuPpO9FoLprv+YZTmtxWll8OTgpdUBMEPNXrWjLRtwYWot dGnDJibx0k/kIXpr5WDpT37RWKJGjQg1ciEiTB19qgb8lqRMstyk2xgz7FHODibE eq9X79czzYlxXsF7+WMVQbdS9i/SuC8TDgOC5qYNahPRBugZr8WP7uUGvgJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1694043243; x=1694129643; bh=vBTjdMfz1CO5+ QvldXBB+2bQ59B3jeU81T91GJRZKcc=; b=gJHjU750+HzSv7RYPPkd3G/rLMEs+ obWwwh3TAzL5rtFQUCV16ciho2lwUcRbnM8Kf20i+iX4PPyN/AI9exx7FKFV5Wxe 1O5I9QMItyY4P4L88Pz5ndQ8iojAMB0PpD3ugJDL4iFVTxeWFk7Shd88cND8j9SA 5qWHdHVeGUK9kIIvUxxuDWRbyJhqASjjvcIOF7ieJSY1rJKS05O3LUFJ9AB0KSDE k+nEwnR4zJAiyeslbr5OkrHZflH91oTKfp54dv+wEnBBhy4ZL1Zv7ity0qhjZNZg RvvDAxP4hBcmA98u70lmdCYzEFjN6PU6NEgiIIYawfUImSYTzbJ2mmbCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehgedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomheplfgvrhgvmhih ucevlhhinhgvuceojhgvrhgvmhihsehjtghlihhnvgdrohhrgheqnecuggftrfgrthhtvg hrnhepveelveefheeuhffhieduvefgudefiedvfeduteejlefflefggfekvdeuhffgteev necuffhomhgrihhnpehshiiikhgrlhhlvghrrdgrphhpshhpohhtrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhgvrhgvmhihsehj tghlihhnvgdrohhrgh X-ME-Proxy: Feedback-ID: i7a7146c5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 19:34:02 -0400 (EDT) From: Jeremy Cline To: Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremy Cline , syzbot+0839b78e119aae1fec78@syzkaller.appspotmail.com Subject: [PATCH] nfc: nci: assert requested protocol is valid Date: Wed, 6 Sep 2023 19:33:47 -0400 Message-ID: <20230906233347.823171-1-jeremy@jcline.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The protocol is used in a bit mask to determine if the protocol is supported. Assert the provided protocol is less than the maximum defined so it doesn't potentially perform a shift-out-of-bounds and provide a clearer error for undefined protocols vs unsupported ones. Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation") Reported-and-tested-by: syzbot+0839b78e119aae1fec78@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=0839b78e119aae1fec78 Signed-off-by: Jeremy Cline --- net/nfc/nci/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index fff755dde30d..6c9592d05120 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -909,6 +909,11 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, return -EINVAL; } + if (protocol >= NFC_PROTO_MAX) { + pr_err("the requested nfc protocol is invalid\n"); + return -EINVAL; + } + if (!(nci_target->supported_protocols & (1 << protocol))) { pr_err("target does not support the requested protocol 0x%x\n", protocol); -- 2.41.0