Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1477735pxb; Thu, 16 Sep 2021 08:16:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Vl1RM3WQ+kDQP1QAreIqDrhrFZYhzuELHkbLy3viKsSwnZ+Q2uz4wmTGZYkeUHSPY1E8 X-Received: by 2002:a92:dc01:: with SMTP id t1mr4395688iln.267.1631805401980; Thu, 16 Sep 2021 08:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631805401; cv=none; d=google.com; s=arc-20160816; b=IlisquTDEENJ9PGuVfm2Pl0GgQuYfstGHVwjynjYM9rsgFftthXpJXzP6kC0UdJdeI mYQA3/mai9PrWd7S25DlEfWe6OL/9hcFraUlMoyNJ/VGGSsp/lfKtJvTq5/0WMvJWktG L8LkpV5F8kD/X6HWraohiSenqqLaZzJ967Fk7CsSjaXQH7lgBhhO1rEIMtinE2ta4SuY R8ask/ckDxcXge6vMb4d8Kt5sUF8Lk5SMrouOZZOO9uz4tCUkV+1HDYF78lJAiiN43BY 507NcsQdv1LENAELb4kiV2gcDvDTA7UQOn0frn5AidMpaJfWVeNVAY0d9r2ojpgbrBW3 qRSg== 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=1Na8E10edSXu1C0NVuxQho3lbg+CDYA3VNhzIXyAPEc=; b=gMZCxYKS42da6Re2kAN9U1LH10BW75J/v6u0ySUIW3WZ6ijo5W7ihVAz2WSnfhMM5Z GPCCo8pViix6TEcNON+HgYJWQN/rTaiUEhhH/ScpXScIlavj4YrH5LWefWlqlac8VHqW 356X6k4DvISUWX+ZPmZ4JlPTTTieS8S6ljWYEuhtwVzutWxFjODo8/9dEEpn7Dq1fOPv 1AuQsVjR6dRpxW4yVG1L+Ea+eoR5SmUm/bXjkoXzArJx6CmAcru6EmAQfrbdOdtfollX V/m5NroICM0Tz2Khc8SsU1KIPxDy9gNxbOP6muuo6zsF8kAMkPV/mzlz79tjPrpItE3X e1CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i2dYB1Q/"; 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 v2si2633003iot.49.2021.09.16.08.16.18; Thu, 16 Sep 2021 08:16:41 -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="i2dYB1Q/"; 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 S236100AbhIPOiC (ORCPT + 99 others); Thu, 16 Sep 2021 10:38:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235955AbhIPOiB (ORCPT ); Thu, 16 Sep 2021 10:38:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BF9061164; Thu, 16 Sep 2021 14:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631803001; bh=Qqm3TnW06OUx8Ms7O6IvNEY02BAkvJWTijFgoy80DEE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=i2dYB1Q/8dDVkoHSuQjVDxUoB0+X6m3HY6uMVbtTI2Rd72glxkzVfk3PFP1mnM5c8 NTrarVJzkGHRnxpPkfjXQKatE78vXH5MWvJ8VTbkU9OD9WijEp2dWwPQW932a8yv2t WnazG6f/eLOmyjO0/N3zULc1ZQ6V7lSznpUrrsPyQtfsowfUGvML4kNO8vFB7lUWLp be38ebWGA4DZ6IGJm9nPZzZljRwvhdWY2m31EB1Iyhnbu3sPEEXMooE0FGD4ZZlvft w9w2sKTEClRhg9INYp1Sjpryfxavp4Wza4KytogJ2eoz++8RaQGJzo2ZYJxkSH69+z ZxcuGvUk367QQ== Date: Thu, 16 Sep 2021 07:36:40 -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: <20210916073640.7e87718a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <1631756603-3706451-1-git-send-email-jiasheng@iscas.ac.cn> References: <1631756603-3706451-1-git-send-email-jiasheng@iscas.ac.cn> 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 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. If we do need the nla_ok() we should probably also switch to nla_for_each_attr() and nla_for_each_nested().