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 B4D3FA0032; Mon, 22 Nov 2021 14:19:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F3AE4014E; Mon, 22 Nov 2021 14:19:55 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 3CC474003C for ; Mon, 22 Nov 2021 14:19:53 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10175"; a="232267219" X-IronPort-AV: E=Sophos;i="5.87,254,1631602800"; d="scan'208";a="232267219" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2021 05:19:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,254,1631602800"; d="scan'208";a="606407272" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP; 22 Nov 2021 05:19:51 -0800 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 22 Nov 2021 05:19:50 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Mon, 22 Nov 2021 05:19:50 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Mon, 22 Nov 2021 05:19:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dYpAZS1bN+b34aIxiaibHaM3+jfLD6xZLpcbXGyiXeOj6NQiwQpe9vm057s2JBPL3Tl5l4xCFV26i+j5J63+OebTf2uSQfajDMI4MG3Z3saKlOc1eWZmK35IDvamP1zhny9rB68+kBa5gtF9U0fyB5FB1eNt2Nx/rvn9QKwewGUPsVJDPHOAuBGOUFMQNN0GZifA9gaZbZuKA3thKkLQ3yggmIKCJ3aC5Jh4uFWtHBzSNOWQhU1XwLQYdbyfmkRAhs3695z50GjH2LzdxFq55PgQ5CUXE50keLnWqjcdQ2yIa2vmM9a59LqjKZJb4DqECHTV1K7YBwcxudxkvdWs4A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tLW9cR8WbPmVaYzGumb0YuNI1SE/O+ZGY7MVktT9F2I=; b=VTzOF/IzXthvtVkrwK3ubbvu9lVvqx7dkdvliWBu4INo5gRyUCNRQiRqGXyGC/BqlzK1CiXxqfG5nnB8I7LQKfWQdfWUHiwxV20J8XlpkZlAodyQMnhSnkVEqR9g3hpWXaema/9fqkEISujv/H+DjCc860x0XpCEtqh5/GPHwbkpf4/zMukL3VRMshR+ER0zkW7DtiVIdkH8Jbavh2bjtHmjFBq4p6wgxabY8fWV2gfnDZZGlM9LSvuhQB8fVRwX4QzZEGQxM7dndaFNUaIapfthDYLpY0oU3r7fXicX/HevKpaH2umGc1UD3VFLwYacR+Q6CSQwyxFOeDJKybXk7w== 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=tLW9cR8WbPmVaYzGumb0YuNI1SE/O+ZGY7MVktT9F2I=; b=w8MBdtogVC+cSnvXmlJL/D/nnnrdFnw5bntq8ejTXAHVWbRAKum34LlqqMMXThnNLr3D4Vn76c1GRE2RFf+Rxfzqy3GedB24dkPCLou/RnW5d1W+Jj9CgmGQG5+R7QGAhsZFGJc7nOc9r8IJgehmGfPaRM3mD3MfFR/jknU+mGc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB4887.namprd11.prod.outlook.com (2603:10b6:510:30::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Mon, 22 Nov 2021 13:19:25 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bc5f:31a7:10ad:443c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bc5f:31a7:10ad:443c%5]) with mapi id 15.20.4690.028; Mon, 22 Nov 2021 13:19:25 +0000 Message-ID: Date: Mon, 22 Nov 2021 13:19:19 +0000 Content-Language: en-US To: Markus Theil CC: , , Michael Pfeiffer References: <20211120131436.52694-1-markus.theil@tu-ilmenau.de> From: Ferruh Yigit Subject: Re: [PATCH] kni: fix ioctl signature X-User: ferruhy In-Reply-To: <20211120131436.52694-1-markus.theil@tu-ilmenau.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB3PR08CA0011.eurprd08.prod.outlook.com (2603:10a6:8::24) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DB3PR08CA0011.eurprd08.prod.outlook.com (2603:10a6:8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Mon, 22 Nov 2021 13:19:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24cc1ecf-b2a0-4e27-fe92-08d9adbab482 X-MS-TrafficTypeDiagnostic: PH0PR11MB4887: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tDd3Pz7HwHaFqo8wdM5hnUTjnFhA8qV6vj8WEQV+ZcAJPsylxAC/8qrvJK1MilE0k2RbgdKK8593I6x4cttUBHj5emGC/fCwRBKEZNLGTbBjcy/cNy48QdQ5W2BnRq7OAfyRIEqqjOiEbSNjSqnEylFpBJevBAygg2kEO1szN/vCJxVI9IyfD+xVnZ79cqYOIxue7y5cZexPgkh9AfxKR4440W+mB9VXeCeIWqCK1EYDt4bDLYwKSx6uoi0BKkxIsg/8tTjLywRAOgxKAouuNtyyoOGu/GxuR4u4RaSj2hPbgodmgFhjzHPgHPH5KQO2EgjhuPq6Uetg8xr4cdAKSfRBxNI+DoBnd63DLnOEeWZ+gD89EbbQzAwbDpY+JFgB5j7ecqkX1m0BpC+dbOsKzHqbQWTNSJhwXSIxVe8vEx+d4LlEdXPRLbNVJrtoscJ/yJ4R93iJCgg9RPyoi2zafpcaLUc20Y697CJ0T/T97rDaKk2z+nLivJ5WRWy768DUE3Rktyd54+mxYG3VooGghAHEugPXB/1GLizc6YLcsRuCWGWmQ2B+HKjYkwRoxXhWchtbKYo+vlEb0v0AEjB8vk1+FWAvisC4fnLfB7VmBkwbDq7M5JkB8azCm7sTtQjeFoz8itr2JYICkn5K9g5UGo1pvf6pGn13d8lx1rrlejctYpX1tKpWoOz28CFCUg/to2nHKNJpwre9PrEK0Za/Rw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(44832011)(31686004)(86362001)(8676002)(31696002)(4326008)(53546011)(956004)(2616005)(6666004)(38100700002)(5660300002)(316002)(83380400001)(66476007)(186003)(82960400001)(8936002)(66946007)(2906002)(6486002)(6916009)(16576012)(36756003)(508600001)(26005)(66556008)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aWRyV2FiWUFqSVljN0VZQnR5cFYyd3paVGpHOWJ6ZlEvQ2N1K2NsMGxVaGNW?= =?utf-8?B?bmZsZ202ajhyZjRtazNTY2kwZEJ5cDE4Z01KcHJDMEtySE5VeEhodEkyK2Rh?= =?utf-8?B?SXZUWG1qNXlzQ0x6RDMwang2UmhTVE9jWkU5U0xiZldUY2VaR1hvREtuQVNr?= =?utf-8?B?bzJhOXVrVkRpbG1qaWhBMzgwSjBDVHo0ZlZwV25RaW5YY2YybDJ1QmhoTmU4?= =?utf-8?B?RnFZNVRzdXhtc2k4dS9PRmVVNXR3S2w5RjJtMmZobHVsd21UUEZIYkR6MWNH?= =?utf-8?B?M1lvZXNZZVRuOVcwbmh0NG9Ud05oVTN4WkppM1RmNVV3THpaNGlRbFFBZ2Rk?= =?utf-8?B?WHgyd2FmNjk2ajAya1ZYY05HUEtsem1BaG12cWxUb1dxSmIrRi9HWHpHRklm?= =?utf-8?B?UmlIV1huTEs5TDR4R3FpVytxR0VXMW1LUzUveTZ3djhQYjMzUXlGTDV2Tm5H?= =?utf-8?B?OEtZZk5UeDEyWFJCT2tneTFCNU9pWWszMWszOW8rZmt3T2Y4N3NWZHMvRkpG?= =?utf-8?B?NlJOTEdtU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HQXdD?= =?utf-8?B?ZTQzZDdXdkdTTnJoYWQ5N3EyQ0tlTTVoVzBEOHR4OFpmZTVraWZ2ZmJBRTB2?= =?utf-8?B?bjg3THFzQVk0TVZzSWxqN0VzaW0yRVFoVk5TbDRVTzVtNG44dGVLS1pUTW1Y?= =?utf-8?B?akhLeVdPU0NlVGM2ZHhpZHdud3ZJNE5JcWEvRlVDY1hMYjNVOHQ1ZHBwWEQy?= =?utf-8?B?Z0YwcFZPOEpLb1h4N3hxR0lFVmpUdGRudUFEaEpETTV0ODRLV3ZmVWV0YmU0?= =?utf-8?B?MUM4YW9NQ0hjNVhsZ0hudGJ6QlQ2VTBNd0t4OG5wTGRuMHQyTld0NkNIUDJy?= =?utf-8?B?bFBIK09iUmtlUSs0UUZHTndjZjV2WTNpajM5S2dsVzlVLzRTZWp4NDVnYTV3?= =?utf-8?B?UDQrYXZ2Qnp3clEvNGVJM0YvVEtUaHd0UlErVllYZjNxQ0ZZa3Ridk84Q0lQ?= =?utf-8?B?K1J1QWlHVGQ1V3dxT2ROeDVZN0JLT1VOeWpQWHJFdWxwR1lWRTBUODdmZURS?= =?utf-8?B?SUs4ODRwSlI1Vms0UitkT3I1ZjJqOGdMOUFBcDJhV3Y4eFZDRU1MbFQxMmpF?= =?utf-8?B?QWJZWHljS284eVBNdnV6K20ycEluYStyb1cxYVQzRHZEZGRJNEluTC9vbzNr?= =?utf-8?B?TkxLNmhZQjRxeWwwa1Y1SzZycUNWTm5jOW1WM3pkYnptUzBESUxEdFVkTW1l?= =?utf-8?B?QjZxSlZGTlNzUXdxd2d1bUZ6YTJIYkRIaVN6VW4wNUMxT0RqOEI0cWgyckd1?= =?utf-8?Q?uN0ykYnC6ZnCLf5iiRonrkA=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 24cc1ecf-b2a0-4e27-fe92-08d9adbab482 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 13:19:25.6140 (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: zWQNr+K925ewXrw0Vkq/A0CMMue/QpngxpuruCdcCHdcWX3LHKzKvNOroUhXjqRMOCMOvAIm4ubuIZ2gacK/9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4887 X-OriginatorOrg: intel.com 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 On 11/20/2021 1:14 PM, Markus Theil wrote: > From: Markus Theil > > Fix kni's ioctl signature to correctly match the kernel's > structs. This shaves off the (void*) casts and uses struct file* > instead of struct inode*. With the correct signature, control flow > integrity checkers are no longer confused at this point. > +1 to update the signature, the code is like this from the initial release, not sure why. My concern was if this cause build issues with old kernel versions, but as far as I can see the signature is like this at least since 2005, so that should be OK. A few minor comments below. And overall for the patch, I suggest postponing this to next release, since we are just about the release v21.11. Although change looks safe and trivial, still I think it doesn't worth the risk, taking account that current code is at it is for years now, it can wait a little more. > Signed-off-by: Markus Theil > Tested-by: Michael Pfeiffer > --- > kernel/linux/kni/kni_misc.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c > index f4944e1ddf..d4e00abc40 100644 > --- a/kernel/linux/kni/kni_misc.c > +++ b/kernel/linux/kni/kni_misc.c > @@ -245,7 +245,7 @@ kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev) > return 0; > } > > -static int > +static long > kni_run_thread(struct kni_net *knet, struct kni_dev *kni, uint8_t force_bind) > { > /** > @@ -286,12 +286,12 @@ kni_run_thread(struct kni_net *knet, struct kni_dev *kni, uint8_t force_bind) > return 0; > } > > -static int > +static long > kni_ioctl_create(struct net *net, uint32_t ioctl_num, > unsigned long ioctl_param) > { > struct kni_net *knet = net_generic(net, kni_net_id); > - int ret; > + long ret; > struct rte_kni_device_info dev_info; > struct net_device *net_dev = NULL; > struct kni_dev *kni, *dev, *n; > @@ -416,7 +416,7 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, > > ret = register_netdev(net_dev); > if (ret) { > - pr_err("error %i registering device \"%s\"\n", > + pr_err("error %li registering device \"%s\"\n", > ret, dev_info.name); > kni->net_dev = NULL; > kni_dev_remove(kni);> @@ -437,12 +437,12 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, > return 0; > } > > -static int > +static long > kni_ioctl_release(struct net *net, uint32_t ioctl_num, > unsigned long ioctl_param) > { > struct kni_net *knet = net_generic(net, kni_net_id); > - int ret = -EINVAL; > + long ret = -EINVAL; > struct kni_dev *dev, *n; > struct rte_kni_device_info dev_info; > 'kni_run_thread()', 'kni_ioctl_create()' & 'kni_ioctl_release()' are all static functions, I think it is OK to keep their signature. At works their return value assigned to a 'long' in 'kni_ioctl()', which is safe. > @@ -478,8 +478,8 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num, > return ret; > } > > -static int > -kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param) > +static long > +kni_ioctl(struct file *file, uint32_t ioctl_num, unsigned long ioctl_param) > { > int ret = -EINVAL; What do you think about changing 'ret' variable type to 'long'? It will be implicitly cast to 'long' anyway during return, but keeping it same with return type looks more proper. > struct net *net = current->nsproxy->net_ns; > @@ -507,8 +507,8 @@ kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param) > return ret; > } > > -static int > -kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num, > +static long > +kni_compat_ioctl(struct file *file, uint32_t ioctl_num, > unsigned long ioctl_param) > { > /* 32 bits app on 64 bits OS to be supported later */ > @@ -521,8 +521,8 @@ static const struct file_operations kni_fops = { > .owner = THIS_MODULE, > .open = kni_open, > .release = kni_release, > - .unlocked_ioctl = (void *)kni_ioctl, > - .compat_ioctl = (void *)kni_compat_ioctl, > + .unlocked_ioctl = kni_ioctl, > + .compat_ioctl = kni_compat_ioctl, > }; > > static struct miscdevice kni_misc = { >