Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2112274rdb; Mon, 9 Oct 2023 13:01:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6hGKFFvvLWNVu4AIE0vskEK7/J/ysRFhJU5Ydd8qKjxsa0OwPYgbi/I0pV51rCT+DSZF4 X-Received: by 2002:a05:6a20:8f26:b0:159:fe1d:2f32 with SMTP id b38-20020a056a208f2600b00159fe1d2f32mr16801276pzk.42.1696881681318; Mon, 09 Oct 2023 13:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696881681; cv=none; d=google.com; s=arc-20160816; b=WotHyOa/RfJPvUjUiAfWQjFj6cAO/3LFuf6/QVIQ9Bjv5BEfehWi1BOT/WQ+PmGWCD dVrYQ0nPhHa47551gJm0HfAcux13eEi2mCCExhaku6SNOuNUlRuCSj8gEybgzbu1fxFs 5DuOkX7L7YzKW7oB7MQNnW+5qVfvV4fJLC4wiRJZfUHVaKfgScUbwsbL5kusecgTfR4T c72lHSwk6au3Uk1AOp4jI4BQiCQ2gexeNBSd9jyDBfhyzRyZ4p/+/LB7kIWjJnDUfb4q jmbiRrnSL6NKra2qrSDSQgbgjU4NwYreW3mrLtLAG1nsxK/u6XmGzbwGUlP20V4nvUjH llKA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=KFJlfLmUur1TF6+IynsFY6BXUkOLslkI1mlBrnqgyjA=; fh=DoABwDUKjstI+bkaLw0tJzBEQrC7QXTOTywJR9+sXfo=; b=vQuuwK0zX1AWpmekJiM/tnSgVTueeDV1ILqW2oZTkTtkynxp/dUyqNkvSYZer/l4Ho Evi4HqfkQckwpX66pfu6lFgJsW10HP4Yp7/0m8r6ZGMdwt1S/gPN06P/SlRjmnKJXPyI lPLGCx+kyYjetvWmJD+TS5+QoKun1rSXeUFStyaza0IpJKSWe4y3pESAZghAEfGNLqgc J/Axq3TRKBY1QKs0ItjmoXARhph0vT/MLSjWzDsGaCdM2g4kYGQzzBj3b1+4NLgRvrTj u2Ls1cx359ulsl3mPCeWtvX81FOO6Ew5YyFoc+peIuYodAGGgB8Z7vaemCQ11kTwHbQe f/YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jcline.org header.s=fm2 header.b=mfumQgKC; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JlZ2nr6c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a21-20020a63e855000000b0059779ae5898si2137469pgk.835.2023.10.09.13.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:01:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@jcline.org header.s=fm2 header.b=mfumQgKC; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JlZ2nr6c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D600A8028FEA; Mon, 9 Oct 2023 13:01:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378508AbjJIUBG (ORCPT + 99 others); Mon, 9 Oct 2023 16:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377401AbjJIUBE (ORCPT ); Mon, 9 Oct 2023 16:01:04 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEBDB94; Mon, 9 Oct 2023 13:01:01 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 67DF65C032E; Mon, 9 Oct 2023 16:00:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 09 Oct 2023 16:00:59 -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:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1696881659; x= 1696968059; bh=KFJlfLmUur1TF6+IynsFY6BXUkOLslkI1mlBrnqgyjA=; b=m fumQgKCR+oxJg/K2hWo1Dy5kKTXmalj5XZ2hMDLUEIjjASlqc1xvOvgm0e9n83fI kQw4FV2jid8N9TfrbN41ry0i8P20hWeBwIS21gwfYBu/xyeFBbVyyTrCibzB/6Xk S2Oz/IwZh9s2TUEtyWk/RaqZ9wz9/7PRK4zuWO5dj0KTFp1uWb3XA99c+9jQ3lz7 fs2Sl/AVlZAaLmA+FdAITgPKPapc5VwEVvfIBB3ivHFUpU0Y835A5tTJcu3V3sh7 7YKC9xTE9mEsewjc5T32nQmHHulp2qJHvhJ496qBlNePIlh62dnlH8qP2b2Cad0x uxLP60wP52VbAx/pNyh4Q== 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:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1696881659; x= 1696968059; bh=KFJlfLmUur1TF6+IynsFY6BXUkOLslkI1mlBrnqgyjA=; b=J lZ2nr6c2vc2qNb1TkWyfTzUluHlH4j8pfh63WBXulVmmiKyNrw/ZILmjzFgvel37 IEnomApgmIFE7XA/Hdj2YQ+574vLvzHQJv4VkK7XRkk5tTkoNyLsuWUKepk7rcB5 pHAU4dxo6YAKPUUlv93QSk9PZRDiKw7AWthXZ3Ssau2qmsCLQ+NXbGcNunU2YIVD U6BzfFrfRU56sW5kXT3bwuDQv+xUixobTThoyQ3aFExVmM4g7yI7w2/F0/3vqFKx 6PFrTr7HR8CE3uKz03oZArxPXBNrAkQO8KQbMc4L6zt5xqMG2r7tVyKR5SiO0KIv IJH8+OJAh1p32MTs5VxcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrheefgddugeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfgvrhgv mhihucevlhhinhgvuceojhgvrhgvmhihsehjtghlihhnvgdrohhrgheqnecuggftrfgrth htvghrnhepheevffeftedvfeeuffetjeevkeefheefjeegheffveekgeeujeehgfevvdfg udeknecuffhomhgrihhnpehshiiikhgrlhhlvghrrdgrphhpshhpohhtrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhgvrhgvmhih sehjtghlihhnvgdrohhrgh X-ME-Proxy: Feedback-ID: i7a7146c5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 Oct 2023 16:00:57 -0400 (EDT) From: Jeremy Cline To: Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Dmitry Vyukov , Lin Ma , Ilan Elias , "John W . Linville" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Jeremy Cline , syzbot+0839b78e119aae1fec78@syzkaller.appspotmail.com Subject: [PATCH v2 net] nfc: nci: assert requested protocol is valid Date: Mon, 9 Oct 2023 16:00:54 -0400 Message-ID: <20231009200054.82557-1-jeremy@jcline.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230906233347.823171-1-jeremy@jcline.org> References: <20230906233347.823171-1-jeremy@jcline.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:01:12 -0700 (PDT) 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 --- Changes from v1: - Target the correct tree (net) 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