From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 651FBA00C4 for ; Thu, 17 Feb 2022 14:04:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57FC541156; Thu, 17 Feb 2022 14:04:30 +0100 (CET) Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by mails.dpdk.org (Postfix) with ESMTP id 6085841142; Thu, 17 Feb 2022 14:04:28 +0100 (CET) Received: by mail-il1-f169.google.com with SMTP id h11so2179194ilq.9; Thu, 17 Feb 2022 05:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=12S04ggKBorW+68yTtpWnAnLNVwCWZO5QHn+aYl1OTI=; b=lyd7QT295oYsDJWGrV+A9LqzDPZNkXELg9ITmTD8B93ggKz44Hil9/fIiOPhoTsHzz mDcoUu9OT5Q1fDS62IDLsidNZCdLewe0l/eaZlpqMOSoGbzru64xcrMICNJDIIjAlfsh wL+3h0j+YfSA98KTBe/DHN//tarByqKjAgMDETYu/Iq76Tex9/r1MNZq584g89H107zA itFZq1qAtCIannrryRHTmzkOmJLtlYvHOGQGgtX2Rw57KLGfo73iDUzAX05ebar4D2Ru 02VAMf+lD0k+S1tjw536/rrTnLq62P21Z7il0SGbCetYTNk/T3ypYWabVBpbsCiaUAGF /A7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=12S04ggKBorW+68yTtpWnAnLNVwCWZO5QHn+aYl1OTI=; b=moP+10GLcG7kywh2dNVnpes5L9Nk1/rT5bsGoLldkjVQixZEqaJMZidyJEBDCBwVMT 1kTD01lwbfj2VS7HdJxxYNbI3eurHLYUUL6+Ce/yQuc8O7/aZEpUYYlAigFoSH8f1pLc mAXak9j3hvi1+EetDDGSyybeeDL5ZBD/CzqtRWQCUtmHFBEAOTPtwGYVnslPLId0uy2F tn7BvQzkkFbcREXDhzGTAn8zMLTT8B2E0sUe3UPR/CwUpvyaxadO+exfSzsw6ZlMdMc7 sc3t2CZcrU821ry44KfQbJg12ODlmbdDjKKTu/6VK5Wz7YfVbJB3uwzkCYTyjK7HyA0V 0GgQ== X-Gm-Message-State: AOAM530bzLHEbwJcKN4bo5tqJBqXANEyLAqj1bAMg6M1tiqHuksDQINQ SsElON8pO5PwtpmL5ePc4XY1aLA68PHn0XqgdHY= X-Google-Smtp-Source: ABdhPJx/ezwJTdQ3btYyDlRef0CKbwA3uxznNYrA4Bh59rluLxVK+htYhkCwmvswGvT/cT5dXGKWAUI45LdK6slIU5M= X-Received: by 2002:a05:6e02:1788:b0:2be:ffc9:8bb2 with SMTP id y8-20020a056e02178800b002beffc98bb2mr2053499ilu.294.1645103067513; Thu, 17 Feb 2022 05:04:27 -0800 (PST) MIME-Version: 1.0 References: <20220207061246.4209-1-adwivedi@marvell.com> In-Reply-To: <20220207061246.4209-1-adwivedi@marvell.com> From: Jerin Jacob Date: Thu, 17 Feb 2022 18:34:01 +0530 Message-ID: Subject: Re: [PATCH] common/cnxk: validate length argument To: Ankur Dwivedi , Ferruh Yigit Cc: dpdk-dev , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Koteswara Rao Kottidi , Jerin Jacob , dpdk stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Mon, Feb 7, 2022 at 11:43 AM Ankur Dwivedi wrote: > > The x->len is passed as argument to npc_prep_mcam_ldata(). In the > function the len is used to reference elements of int_info and > int_info_mask array. The arrays are of length NPC_MAX_EXTRACT_DATA_LEN. > > Validating the x->len value so that it is not greater than > NPC_MAX_EXTRACT_DATA_LEN. > > This patch also resolves warning observed with gcc 12 compiler. > > log: > ../drivers/common/cnxk/roc_npc_utils.c:13:26: warning: writing 16 byte= s > into a region of size 0 [-Wstringop-overflow=3D] > ptr[idx] =3D data[len - 1 - idx]; > > ../drivers/common/cnxk/roc_npc_utils.c:163:17: note: at offset 64 into > destination object =E2=80=98int_info=E2=80=99 of size 64 > uint8_t int_info[NPC_MAX_EXTRACT_DATA_LEN]; > > Bugzilla ID: 854 > Fixes: 665b6a7400bf ("common/cnxk: add NPC helper API") > Cc: stable@dpdk.org > > Signed-off-by: Ankur Dwivedi > Reviewed-by: Kiran Kumar Kokkilagadda Changed the subject as common/cnxk: fix NPC key extraction validation Applied to dpdk-next-net-mrvl/for-next-net. Thanks > --- > drivers/common/cnxk/roc_npc_utils.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/common/cnxk/roc_npc_utils.c b/drivers/common/cnxk/ro= c_npc_utils.c > index ed0ef5c462..007c454c3c 100644 > --- a/drivers/common/cnxk/roc_npc_utils.c > +++ b/drivers/common/cnxk/roc_npc_utils.c > @@ -166,6 +166,9 @@ npc_update_extraction_data(struct npc_parse_state *ps= t, > int len =3D 0; > > x =3D xinfo; > + if (x->len > NPC_MAX_EXTRACT_DATA_LEN) > + return NPC_ERR_INVALID_SIZE; > + > len =3D x->len; > hdr_off =3D x->hdr_off; > > -- > 2.28.0 >