Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1621882pxb; Thu, 16 Sep 2021 11:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZRiqgT8vFUDoCACeGW31N255uBmxAUFwwDmcpHwLDDa1rTlahMr3HxOvF1UysHeCnlRAq X-Received: by 2002:a5d:9e49:: with SMTP id i9mr5287059ioi.125.1631816335844; Thu, 16 Sep 2021 11:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631816335; cv=none; d=google.com; s=arc-20160816; b=mRpueKAkLtdfrzmDy6DUzAz0z7T7FpL5fhlhHSnMRmqyYDPXsTjm4722/u7CbFKUQT dgfekCiU1qo5hls4C4IVy9HlCZ0cbsVjqjyTs4qEvc2bHZIL2aXSjCSl7UKTlCk0GlCm HDk9FrzvvoCAOnOxWP+kGncfPoJo7r6oJBGJgEUvP3tPso7IkSeMzmhdCCug1b0sG9Yr DHEm6+4fLtC33qfvikeu1FQrMIhuYleW3wRC5QoLj0sDgE//4RMW3JIBzSZyC2jZkpZA IotFJGQsG4041EenPd+BN9nJXWeMuH4cTpBF3dfSJBLWbT5JKjBkV84gkF6g7YaGCCL6 cGmA== 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:subject:cc:to:from:date :dkim-signature; bh=DWxAmJiWa3Tg3K9Ea3VJUub2WWLY3UWCPCKdP3zZs2w=; b=iauaKuZyz/8u8F/BeQ/UScl0q85O6WQtcrcOIQuawEG1aBQ62/GJW5uvAekAcAZsJ7 WkLghgQj2ZkCCENXfI7+OR3YogxOF0RZrGk+gMcX3HAhWnnjlEh2HUkAR09o2LMq2Tyx yXBSkn44WGx49+hxgq2Jk5/vU5gTwiRcz0vPjqmdmG6o6wXMXz3C3OI/thr/uV32itaf LBqyY2JRg6l1MdOTqzj7a7Jz0t7wEv8yUvNWwYmQ1UFo8KP88eugW1F/VIhgY2+/1Iab Pa6bGY+o4UEACp2ulYIzxgMzjwkHaXUgT7cXi2yej8w/rgIXfRHei6Hfkjld4zvkALdo fxGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KrTIiPJh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si3584823jat.122.2021.09.16.11.17.58; Thu, 16 Sep 2021 11:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KrTIiPJh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235955AbhIPOkK (ORCPT + 99 others); Thu, 16 Sep 2021 10:40:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236152AbhIPOkI (ORCPT ); Thu, 16 Sep 2021 10:40:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B0B16120C; Thu, 16 Sep 2021 14:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631803127; bh=VizvyrKA/9G+ItaOY/JY1TvKtQ6RYDHfj7esRMFMBEU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KrTIiPJhTAtfCx/XLWrZwg1PkKsxc0I0pfi6RduJEvRxRUnLknsOowkEottopLauQ bAXfz2xCbNJIHTV+liX94Uyd25Hk4NDafKrKhNJh6J0zJtDrGMLFepx/Eh2DvqopkP K3UuOhrBW1BHVFedY+YGanzFoXLwzPr9y026vqJ4mVpXQnXFUhS9m6VprJTLR5R5Fe EiaQXFC63aNSU+OYV/S0iW7YUlOTCZFXy0rbmBZG61tIzgnPMOz85W0wwCF1C8YuxQ ccbwk7DJhn0ZfsKyP7db8/bJ6IhNohovdblszG6Zsz5j1fULaljcpRXpkZlWmJkkZ4 zk9kV9Y8amo2w== Date: Thu, 16 Sep 2021 07:38:46 -0700 From: Jakub Kicinski To: Jiasheng Jiang Cc: pshelar@ovn.org, davem@davemloft.net, netdev@vger.kernel.org, dev@openvswitch.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] openvswitch: Fix condition check by using nla_ok() Message-ID: <20210916073846.31b43b2a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210916073640.7e87718a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <1631756603-3706451-1-git-send-email-jiasheng@iscas.ac.cn> <20210916073640.7e87718a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Sep 2021 07:36:40 -0700 Jakub Kicinski wrote: > On Thu, 16 Sep 2021 01:43:23 +0000 Jiasheng Jiang wrote: > > Just using 'rem > 0' might be unsafe, so it's better > > to use the nla_ok() instead. > > Because we can see from the nla_next() that > > '*remaining' might be smaller than 'totlen'. And nla_ok() > > will avoid it happening. > > > > Signed-off-by: Jiasheng Jiang > > Are the attributes coming from the user space here or are generated > by the kernel / were already validated? Depending on that this is > either a fix and needs to be backported or a possible cleanup. > > Please repost with the explanation where attrs come from in the commit > message, and if it's indeed a bug please add a Fixes tag. And please use different subject for each patch, otherwise patchwork bot thinks this is just two versions of the same patch and marks the one posted earlier as Superseded. > If we do need the nla_ok() we should probably also switch to > nla_for_each_attr() and nla_for_each_nested().