Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp980603pxb; Wed, 15 Sep 2021 18:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMZRSEITanyi9pqPYp0t/B9OCdP0NQq4/amJguWn18+UrxTPCgJYMPYiGVO/C5mDyInETD X-Received: by 2002:a17:907:8693:: with SMTP id qa19mr3154211ejc.497.1631756733172; Wed, 15 Sep 2021 18:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631756733; cv=none; d=google.com; s=arc-20160816; b=vwVhdX8LxtKkyne0z1sN2vVnDTWRseH9mkmbSyFi5KS2BpWkqa9VCdJ27eUgcG1C/J 5SEN979hmmYKrxTGYvmwDhpwlyzQPEN3dFo6WKTz4eEMtesLNjcjdfEiVr53sW6JlPn8 0AivcfOsmiS+aKNYOwRxWtrkl4If1XBgMK1BfWABqJh/44UuSjO9rMunr/r88YbpEybF 3qbKChCUJd+/PtNEiFTqgAxQ2pYRevDDFIu4fkuS6so51MSn4VGIMXlvtP4lwy8wV/0n UAJr+Y+FAZ0IW8n1OoBvwxcRZePALeg881KZb+5vsVIji8p/+amgOo7S/LfmFIex+vWD PP+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=07ETT6fgnW5nWRIgB8EHpIPx3XiCkiGS/54ZMZF6qRg=; b=OgOD0nzilQ7bcMKQJNNaNKYu0v87cdF5BEkoZjtkkYwgRpt4uTW0PYLwM+OAj2lZTK ZE/ROBivYLvNZJxUgA+oHHt0Xr/vk2e210IXjdLlcD1m+Wsjh419lMHVBpLi4Lm3BfTj 2Cna6raI1YMSGVSIS6TL2U8XIJKzR9OIFQYT5nNLpOXx5yEGFXdU/1WmIrXGx+VJGMUc M8PXeEIP5r1HN7lMWgGOKv0WC0PUbUxVEr3gMsPp+w8cRqzJBhZcozdxDcyTomUMGIcQ fFXIQGLHYLuhww6yiKkLKOIQLxAVwF2J7YN+zbNOCnCwRCQtCXizj/7ZsJmE42gm2waP ZePA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de36si2226543ejc.56.2021.09.15.18.45.09; Wed, 15 Sep 2021 18:45:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbhIPBpO (ORCPT + 99 others); Wed, 15 Sep 2021 21:45:14 -0400 Received: from smtp23.cstnet.cn ([159.226.251.23]:39544 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229600AbhIPBpM (ORCPT ); Wed, 15 Sep 2021 21:45:12 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-03 (Coremail) with SMTP id rQCowADHzno9oUJh3yyVAA--.47849S2; Thu, 16 Sep 2021 09:43:25 +0800 (CST) From: Jiasheng Jiang To: pshelar@ovn.org, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, dev@openvswitch.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] openvswitch: Fix condition check by using nla_ok() Date: Thu, 16 Sep 2021 01:43:23 +0000 Message-Id: <1631756603-3706451-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowADHzno9oUJh3yyVAA--.47849S2 X-Coremail-Antispam: 1UD129KBjvdXoWrtr13GrW5uF1xAry8XF15twb_yoW3AwbEka 1fKF48X3y2vFnYkr18Gw4qqw1vvw1fWr1F9w17KanrJ340qw45u34DWFWxJr18ur47urZx Xw4ayr45Ka17ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_ KwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1l IxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUOMKZDUUUU X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/openvswitch/actions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 77d924a..116e38a 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -1238,7 +1238,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, const struct nlattr *a; int rem; - for (a = attr, rem = len; rem > 0; + for (a = attr, rem = len; nla_ok(a, rem); a = nla_next(a, &rem)) { int err = 0; -- 2.7.4