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 6EB8EA0548; Wed, 21 Apr 2021 06:55:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42FC1418AA; Wed, 21 Apr 2021 06:55:00 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 11B9D4181F for ; Wed, 21 Apr 2021 06:54:57 +0200 (CEST) IronPort-SDR: qEbsxVW5JnQlXl8f2Ak3chEpfaCdbBsIi/mNVV+KpCMhq+CUCayBL4AfKtDMtGOWPZokBCjjwT JOQNjhaT5aFg== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="193517054" X-IronPort-AV: E=Sophos;i="5.82,238,1613462400"; d="scan'208";a="193517054" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 21:54:57 -0700 IronPort-SDR: eHTv1nO3S/UCbzF+RnelKlal1zVKR/9nDaqjimd7l8EQuKqeFTV48JKHrccrUmLHkZT8Jcntkx 4PLm2m3V5KEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,238,1613462400"; d="scan'208";a="534769064" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 20 Apr 2021 21:54:56 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 20 Apr 2021 21:54:56 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 20 Apr 2021 21:54:56 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 20 Apr 2021 21:54:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cyeddPCUs5Gab1K1X+V8JrGkkZj6LQ8F35gAespdmyKe602v9IBlF3PplGOviCo1K3UP0sBq+kM36HGgxUGC7czDNfBJrtil6yZAYbZajDVLz2R/kssRsYU4MTzHx+G4TVgnIMNdtjm4IhtFffQSk0Ud62gUdVSOmnKTKbyJOu6YRJct1iPS6sg24c34jbJmomeEZueFGdcQJ5EPxlYmdrYQ0iErNjt+O6LNPiPgU/KnfvmVUc51m5kjkROuH/ZZ3A01nv8PEItLqHp0OBuvzyxPHCtYABHSyblLC+Ef/GZ797LG2kEun3vdbO+krgZC44rpsgudWjP6pX3xP0cXIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WGh4VYTWpRGX7+2ufGzrROj/ZeiFy/0INGdSnDKz3RY=; b=EC5/Qlj0vOP2sXf4rczhpJV3whmp0nvkir3I376YzhINXaaPbl8oEl7dzTtcNghUwnMqd1yokNrCgEQ8aAx1/FSNCv7l8mRUQ4mzZxndG6SGs8V7kdVAMJbuzd9yZUkDaBg8eEERFNJ9/Q9X7e0vuebH+yUQPeAuU1Quxm8GKGQ+5XvRb3C9nQ3BphY5GLqnhLEJwds9NdM+fVbhZNJYAEfIVPTxhryPD8T3MYBszbO9OpxhdJ/YPKWwZRqc1CMUZLABTVSomMEgPPzvIXs35HWoxc535mCU1idRRisCBtioK2wMU8Nmqjnbd9lyoMDKk3S8gTc3X9LygOwzxfza/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WGh4VYTWpRGX7+2ufGzrROj/ZeiFy/0INGdSnDKz3RY=; b=We1GFC0UUD+MQRrhUweeHcA1x4o9kna5U0P6fHx/zUdQhLsGmFPlhwp3YgVpwbExJ8+jMYiwhb/CNp6VH9JQVJqY+5N+vZ39HybNgZwV7N08EIlZz/YBOnPDS7GaEibDvePj1Me0hAdcTkuioBB5aZs/LhruwjJQEIWGJHF+Kgc= Received: from DM4PR11MB5534.namprd11.prod.outlook.com (2603:10b6:5:391::22) by DM5PR11MB1529.namprd11.prod.outlook.com (2603:10b6:4:b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Wed, 21 Apr 2021 04:54:52 +0000 Received: from DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::79a3:3404:b907:d49c]) by DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::79a3:3404:b907:d49c%6]) with mapi id 15.20.4065.021; Wed, 21 Apr 2021 04:54:52 +0000 From: "Li, Xiaoyun" To: "Min Hu (Connor)" , "dev@dpdk.org" CC: "Yigit, Ferruh" , "Wu, Jingjing" Thread-Topic: [PATCH 1/2] raw/ntb: check spad user index Thread-Index: AQHXNlM1yphyrhWkEkWLNDd8WVGsa6q+UClQgAATB4CAAAJCIA== Date: Wed, 21 Apr 2021 04:54:52 +0000 Message-ID: References: <1618970896-37852-1-git-send-email-humin29@huawei.com> <1618970896-37852-2-git-send-email-humin29@huawei.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.53] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5f109aa7-21db-46bf-9829-08d9048199c9 x-ms-traffictypediagnostic: DM5PR11MB1529: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:284; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: q67QU/9LTuwpAjKx9qkkh6TDfA/LBqtuJm2++vC4B1u3Uz4Kv5zVXwXTyOwAPOUwmpdxkLH24C8kwh7O9cOxCqr8+qw54DOF6PKTTwcGU3KPQj39pyoVf9g+yeCPA6xuUCDZsMFUZSYcKKXirqwP43eF4CVflahPAyWIYxxKSAfriujNcat66KJFLmHwacNoMGiDoZvDuyhD9rKc0cxl8xtG4aue5C+PP0wLR+j2qlZEUHi5snl+zi2m43CwNQ6+cArx+D8IzieeelbYs/zrjDK7WCzz15V9rOvy8yjL957L4vqc3H2mfW4pn+hKCG2EkLiR2mEywcSVSqcuJY0EbeH12a4vk+ev7rN/nI5KjxSidCsyU3D+4lr1RtTltWxVi5+LWcnwuOqjTOZgfL7faGNf6T/0n8TMtXZ/Vj07klVLwXda7bCPgN25kD59Ax8rAhSr0CGNsIRzPQqWeyb9Mqk1/PuNB2A//e4Cfr1EsFYjdMpDJY5R478gPe09B+gxQF7t2qanxPNTqGbN1SL591aE4A5/rvbg66fXiAoXGJ4cID3/sT5GVi6/o7+kO+4RXtS40ya/Bxw6w7CzmH33MUB6t+LHIo8BXIRgn3gZAIo= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5534.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(366004)(346002)(396003)(39860400002)(136003)(33656002)(52536014)(6506007)(110136005)(54906003)(8676002)(8936002)(53546011)(186003)(66476007)(122000001)(71200400001)(26005)(316002)(7696005)(66446008)(107886003)(9686003)(66556008)(64756008)(76116006)(5660300002)(86362001)(478600001)(66946007)(83380400001)(55016002)(2906002)(38100700002)(4326008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?iso-2022-jp?B?a1lGQnMzSEk2VEQ1eEZSUk1Cb1N2cDlUZHE0OUt1YjRKUjRaMjcxTUdn?= =?iso-2022-jp?B?ZVphMjFtdDIwdTFSMkhWbUNrYlNiM0l2cENETG9XcGh1T0FPcEFFTm9h?= =?iso-2022-jp?B?T29PeVhqWmp0aGlXYkk2cWZYbVM5WGM1VEREV20ybDhUMlZIWGR5S3R2?= =?iso-2022-jp?B?ZHlGeGh0amRGVXB5d3FRcExRWDdPNjBXRlJNN3VvbWdnd1JRTHBMMFJP?= =?iso-2022-jp?B?UCtPbnpTcUoxZE9vMDc1T3A4UFFMd3hsT1l0NDZwU2FBMHF4dVBKQ3lG?= =?iso-2022-jp?B?L29tQ3ZFVmZaZkcrUVRhNUNnQ1dGMGN4cndhdHNRL2ZCN2ZXSWdabmkz?= =?iso-2022-jp?B?L1VtUU9UWE1MWlZWSmkzMHc5L2xkSGk1RjkyWFZ1Vk1CQ25zQ1ZjQzNV?= =?iso-2022-jp?B?LzlQbUdBUzF6OUtKK1k1K1RaRWQ2TU04M3hEU29yNGZyQkVIeUQxOWpk?= =?iso-2022-jp?B?cTZrNTB4TENIOXBVM2NnY3draXZ3MUQzZE1icHl6ZlMyREtTTTFTMzhv?= =?iso-2022-jp?B?UzhWWm5nYVg0SjBsK3o3Uk5LWWZEellsVFphY1U3WlY3THFIOHFLM1dx?= =?iso-2022-jp?B?TWNQTEVhNTcxd0hvcll0RDJYV1NvTWdnV1V6RDNrZUtFSHlaYy9GV2dT?= =?iso-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tkSEhv?= =?iso-2022-jp?B?STQ0MVNxRE9VelppZFY4NFJZdldDeGxwNmVQSWRkZkhiNVhKQU5xeVZ1?= =?iso-2022-jp?B?VWZrV256M2tCYjZ2YVl6N2xJMWprOHFySTVYZ1RnY01TRzFwL3hLTnNk?= =?iso-2022-jp?B?QU9pcFFDRXhrdUtna1BFVTZsWmVLVmFIb2swZGtXaWJ6d24wbmtidnhY?= =?iso-2022-jp?B?MFYzUXVuTnV1RmYyb0g1L3B4VndycnhDZTF3blVLRGZxeGViYU5NZ1Qx?= =?iso-2022-jp?B?K2tqTGpvK2xyb1RwTTZBbFpueTJNTUpqVkxrMWw1TWJDdlQ3YTlzN2dk?= =?iso-2022-jp?B?S2I0emhEZXYwM2JRdHEvRWFFeUJpNUNSd3dpNXZKVFVBQzJhWERVWHhi?= Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5534.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f109aa7-21db-46bf-9829-08d9048199c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2021 04:54:52.5480 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Tp1kdE4F7HhY9ppHf+eRBNBRNU4uD7fpuy9CzOSKGiYI135GmRANhZfk7JJuDo0Q2vCHgDWVVWeb+oD6g4R6bA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1529 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 1/2] raw/ntb: check spad user index X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Min Hu (Connor) > Sent: Wednesday, April 21, 2021 12:37 > To: Li, Xiaoyun ; dev@dpdk.org > Cc: Yigit, Ferruh ; Wu, Jingjing > Subject: Re: [PATCH 1/2] raw/ntb: check spad user index >=20 > Hi, xiaoyun, >=20 > =1B$B:_=1B(B 2021/4/21 11:31, Li, Xiaoyun =1B$B > Hi > > > >> -----Original Message----- > >> From: Min Hu (Connor) > >> Sent: Wednesday, April 21, 2021 10:08 > >> To: dev@dpdk.org > >> Cc: Yigit, Ferruh ; Li, Xiaoyun > >> ; Wu, Jingjing > >> Subject: [PATCH 1/2] raw/ntb: check spad user index > >> > >> From: Chengwen Feng > >> > >> This patch adds checking spad user index validity when set or get attr= . > >> > >> Fixes: 277310027965 ("raw/ntb: introduce NTB raw device driver") > >> Cc: stable@dpdk.org > >> > >> Signed-off-by: Chengwen Feng > >> Signed-off-by: Min Hu (Connor) > >> --- > >> drivers/raw/ntb/ntb.c | 8 ++++++++ > >> 1 file changed, 8 insertions(+) > >> > >> diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c index > >> 6dd213e..0f0e3f2 100644 > >> --- a/drivers/raw/ntb/ntb.c > >> +++ b/drivers/raw/ntb/ntb.c > >> @@ -1080,6 +1080,10 @@ ntb_attr_set(struct rte_rawdev *dev, const > >> char *attr_name, > >> if (hw->ntb_ops->spad_write =3D=3D NULL) > >> return -ENOTSUP; > >> index =3D atoi(&attr_name[NTB_SPAD_USER_LEN]); > >> + if (index < 0 || index >=3D NTB_SPAD_USER_MAX_NUM) { > >> + NTB_LOG(ERR, "Invalid attribute (%s)", attr_name); > >> + return -EINVAL; > >> + } > > > > It's unnecessary. The value will be checked in intel_ntb_spad_write(). = There > will be error remind in that. > > > Nothing to do with intel_ntb_spad_write. If index is no checked, > hw->spad_user_list[index] may be be out of memory and result in > segmentation default. Are you using this driver externally? Or you just check everything in DPDK. This is actually only used for ntb example in file trans mode. And only 0 a= nd 1 are used for index. >=20 >=20 > >> (*hw->ntb_ops->spad_write)(dev, hw->spad_user_list[index], > >> 1, attr_value); > >> NTB_LOG(DEBUG, "Set attribute (%s) Value (%" PRIu64 ")", @@ > >> -1174,6 +1178,10 @@ ntb_attr_get(struct rte_rawdev *dev, const char > >> *attr_name, > >> if (hw->ntb_ops->spad_read =3D=3D NULL) > >> return -ENOTSUP; > >> index =3D atoi(&attr_name[NTB_SPAD_USER_LEN]); > >> + if (index < 0 || index >=3D NTB_SPAD_USER_MAX_NUM) { > >> + NTB_LOG(ERR, "Attribute (%s) out of range", > >> attr_name); > >> + return -EINVAL; > >> + } > > > > Same as above. > > > >> *attr_value =3D (*hw->ntb_ops->spad_read)(dev, > >> hw->spad_user_list[index], 0); > >> NTB_LOG(DEBUG, "Attribute (%s) Value (%" PRIu64 ")", > >> -- > >> 2.7.4 > > > > . > >