Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2081836lqo; Mon, 13 May 2024 07:26:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+7ezcF5xlRvNnOgKXP21hyMHqyeB9SXiD1N6Amv6fvJQhDQUGlCucZgM+XA0mk742oPm8wOKHWNfnu27QaX6pnhvi+2L2OpzS9asDIg== X-Google-Smtp-Source: AGHT+IGo7gBXR/MjrsVk3yyszVPUV1xIuFjldtLd8qeb0EX/QN039pwr0UOoV8XtB7P0QJYnMN1L X-Received: by 2002:a05:6a20:7350:b0:1af:d043:8714 with SMTP id adf61e73a8af0-1afddeef6eamr16157420637.0.1715610368492; Mon, 13 May 2024 07:26:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715610368; cv=pass; d=google.com; s=arc-20160816; b=bqF0Ju/LzgfTBvLVXAULWn92bJVw0irywhqZmqKqZ3i2hksRaM4bdd4a7lrug+O2qR 2BNsZNCDICO16B/6+BHNQN4E39RVyT5Chj43g7uiHEBZnc4qDrapg96Rf0xdyvxGsjDd Q0lEWi5yRBaQ97HEeajHNBGWw50vbkwFgNfnDBqLFKqEyOJuU+Y1i9Z7h2sgNvXX38ig VV6J5vS+VOMgPg30llI4gNFRmu47OIutcz0QCRx1ah7eQ99F26hSXQGJKC39SD4L3hkZ FsSSVc1f3I8v76Vh4LPTlR/lzW06XOQIwfzT8jrCsCfUwm2PLGurJSCPaAvYqCLAhFUv nk8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=1mQ8WPslMoftdqzaHK1NCfVMRDtfWj09Ps/lbcpv4EM=; fh=EF3UtRjFDJzaJUuaxoeStXdz65KgBSrYMEh6DIdi7kY=; b=HviQVNAP7+1KnG67O96X3W6xaTywXMxcY0BHKeKWL30EMqS5WOgDMQ3yP66D81NBPa IY+PyLHbFdtuElyt2E/8LcpwIA1hCmXBF7/txu7OzSfE4aekRJB4m1Io6tXYuoMa5grl E/Hcy/WGbmhgVnkvBu1wXgX1BfgmKOafVYdJWXhLSUnw+kgUpEZ7coU2pCe+NGb7knXJ TIFIqWU5zGlqcWfdzmetfQWJ4QFBnEcPzsThnG+nDPrVTaYVq4jxJUufxOuCRwuXP7wY 0gmS+MKs54HQe74W8/4/QSt3DnKIAW1cBDz4a9v5ohe0wCwuCRcmvTGNPISFwtdsz2z9 sl3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TWkT38Pt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177696-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177696-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412c36927si9375639a12.748.2024.05.13.07.26.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 07:26:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177696-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TWkT38Pt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177696-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177696-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 10BADB21CA7 for ; Mon, 13 May 2024 14:26:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD0F153BFA; Mon, 13 May 2024 14:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TWkT38Pt" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FF07152180; Mon, 13 May 2024 14:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715610358; cv=none; b=jP83H1NpQMH/3NAb8DuaP0PFynQS8v/MaX4kpOhng0BNmhV4XBn2zX7YnK8XkTfvmqXCyRELpf9r3capyEsGnXeQuUUpqjMADJis08pRqdBW6T1IT5BlkkD/MIRxp1YO2FQfQh9M8AZaMCodNRX3RT9TmEyasf+9aE7GFSSRjXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715610358; c=relaxed/simple; bh=Z0soZAvJTumXWH5oqtMOt5hbcby8BsPnK3uvg1K3qWc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YhL2opayRf1rIvieqVNOkVjBisiUxcvF7hpMkYorLL8NUrK98qQDhgwnaHGmWKFUfehfu2EUvEh/H+x4QTaDnFNnp2DoxTPq0DsJ+uqaNCFJ+Lm2/avWW2UjJDhZbppwQWwUxo2/arfROqH3ei8qmee0m38rpM/sm1Nfdrgmx7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TWkT38Pt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1849C113CC; Mon, 13 May 2024 14:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715610358; bh=Z0soZAvJTumXWH5oqtMOt5hbcby8BsPnK3uvg1K3qWc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TWkT38PtpcuL9Yc4GgENz80mTgbNv03+YIHJIlSV04+L6M+GFl+CnwJ9/rQ8dI9zi apItoISrU9wvpHMgOpAVdklvtyiOUJx7CgujjbS5jOr8E5NwP2pn/EVdjTXTTIfHqa OiWLfBCHAVZhAGpEuQenXZubonu20NLbsx996j/5GqPHVYcOwbK3eP5Cjz+YjqC0/v WmxYWosqAzLhyAQnKu40in4Xs5S+tcNmoQLlfRFd+5skNJ0+swwvx1HtZ9NtaAZqzW 8l2qYPCRzNZYz1ScyYpFMYuh2kRNYzNd5gxZ6s+FuGE0GJ7p9N38xkJvlb1cZCl5QO Uspxdh+mInhEQ== Date: Mon, 13 May 2024 07:25:56 -0700 From: Jakub Kicinski To: Ryosuke Yasuoka Cc: krzk@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syoshida@redhat.com, syzbot+d7b4dc6cd50410152534@syzkaller.appspotmail.com Subject: Re: [PATCH net v4] nfc: nci: Fix uninit-value in nci_rx_work Message-ID: <20240513072556.278df9f4@kernel.org> In-Reply-To: References: <20240509113036.362290-1-ryasuoka@redhat.com> <20240510190613.72838bf0@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 11 May 2024 20:02:28 +0900 Ryosuke Yasuoka wrote: > Sorry I don't get it. Do you mean I just insert > BUILD_BUG_ON(NCI_CTRL_HDR_SIZE != NCI_DATA_HDR_SIZE) or insert this and > clean up the code duplication like this? (It is just a draft. I just > share what I mean.) I can avoid to call nci_valid_size() repeatedly > inside the switch statement. > > static void nci_rx_work(struct work_struct *work) > { > ... > if (!skb->len) { > kfree_skb(skb); > kcov_remote_stop(); > break; > } > > BUILD_BUG_ON(NCI_CTRL_HDR_SIZE != NCI_DATA_HDR_SIZE); > unsigned int hdr_size = NCI_CTRL_HDR_SIZE; > > if (!nci_valid_size(skb, hdr_size)) { > kfree_skb(skb); > continue; > } > > /* Process frame */ > switch (nci_mt(skb->data)) { > case NCI_MT_RSP_PKT: > nci_rsp_packet(ndev, skb); > break; > > case NCI_MT_NTF_PKT: > nci_ntf_packet(ndev, skb); > break; Yes, that's what I meant. I'd probably merge the nci_valid_size() check with the !skb->len check, too.