Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6772033rwb; Mon, 12 Dec 2022 06:17:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PiicSPy3LiCVCyAmXRLzl6lJ+lm5Xr3ZDiffjf7IgbAoPbaSPvtP2dkdElg81O+EMSdSK X-Received: by 2002:a17:902:cccf:b0:187:2f28:bfd6 with SMTP id z15-20020a170902cccf00b001872f28bfd6mr20530790ple.21.1670854668744; Mon, 12 Dec 2022 06:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670854668; cv=none; d=google.com; s=arc-20160816; b=DkyGmerqMeVZUtdfyRYXZhzQBkHLiIHHtRFKWcrt6TRL/LfUMzlHWedF8zwmEn450D waORP4w/hbV+C7lButraBdy2/4vT4C3UMkQQ/LnQlXvEPly4zaKAKLC6geWEfVI4/4CU uTxZDGs2Pwlev4HDBhldPX4hCWZEBRztfCqcopUIAjzgrN1cA4UuRdt/yGYwyGmyZ3fJ 9jDcc1Y6xtGWsuhLXN+U/ah4uybsIhkXCttqGqwGBpLmG5VnhlhhPnagIej9ljcFi1wA uwkW9a/JB3cGaqsskKOsU0qGLEi6Y9Zpw4edchrzsKpLP8RzoCZrz6Ed6bTDPCvU4XZS OqKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ENmqkNhO0we5ClYydQt4rr7UFtzl0obXV5iv9tIFidg=; b=HxINXWW4tS/1pr+6o1IZJqA2FnhD3Y2wL5wgOK8Rf8CliHp1B3x033HW/HCU6KLPW0 XMfwhKRkzleMioONjOrQA10hSlSHI81TBMQhbm2378zJJNSfSLvGhz3iOoE1nLVeJV+J vzaNF5yHHG+PHuFNeaxeiqGugcMIQRMwCP7qCof/Md25ixJ2VLE4Gg0Qx+idSO30ou1e wg1kf3Gg7IljKLanYSwDXfprXDmPGKLcyrO0nP7tjukeF8K3qRTOPoAjWk7mrxobqSrE RsJ6lir4E3OgfeQ2+O0tsmXwnmO8fEX3LhvMRLy66MBsr/tyymj8cMLQF1PhJzQAS4qk dArA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o52V7S3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a17090276c800b0017efeb31274si8882972plt.507.2022.12.12.06.17.37; Mon, 12 Dec 2022 06:17:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o52V7S3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbiLLN5T (ORCPT + 75 others); Mon, 12 Dec 2022 08:57:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233157AbiLLN5P (ORCPT ); Mon, 12 Dec 2022 08:57:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C497B9FDF; Mon, 12 Dec 2022 05:57:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4104561115; Mon, 12 Dec 2022 13:57:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E93C2C433F0; Mon, 12 Dec 2022 13:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670853433; bh=SosdTNqvZlwkRrhdbSd1fjxE5vGZbAdcWj210RKTI3A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o52V7S3C2/BOF2hvCpJBT3nZMNMTaJw5lytNmb8LuvDuJqKK8rnGrgR7vdIaWNefT Vfzo/Y2FAxBzTu+EGJhQLNEXM6lcEjRjtpEw3Olu6xVcMxg9EBvrSb53G1lsFI5GB2 MQJIJO//nzvxRzUd4qCe4THaT7/LUVrsSQfa6RT8= Date: Mon, 12 Dec 2022 14:35:04 +0100 From: Greg Kroah-Hartman To: Prashanth K Cc: "Gustavo A . R . Silva" , Shuah Khan , John Keeping , Linyu Yuan , Pratham Pratap , Vincent Pelletier , Dan Carpenter , Udipto Goswami , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "# 5 . 15" Subject: Re: usb: f_fs: Fix CFI failure in ki_complete Message-ID: References: <1670851464-8106-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1670851464-8106-1-git-send-email-quic_prashk@quicinc.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 12, 2022 at 06:54:24PM +0530, Prashanth K wrote: > Function pointer ki_complete() expects 'long' as its second > argument, but we pass integer from ffs_user_copy_worker. This > might cause a CFI failure, as ki_complete is an indirect call > with mismatched prototype. Fix this by typecasting the second > argument to long. "might"? Does it or not? If it does, why hasn't this been reported before? > Cc: # 5.15 CFI first showed up in 6.1, not 5.15, right? > Signed-off-by: Prashanth K > > --- > drivers/usb/gadget/function/f_fs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c > index 73dc10a7..9c26561 100644 > --- a/drivers/usb/gadget/function/f_fs.c > +++ b/drivers/usb/gadget/function/f_fs.c > @@ -835,7 +835,7 @@ static void ffs_user_copy_worker(struct work_struct *work) > kthread_unuse_mm(io_data->mm); > } > > - io_data->kiocb->ki_complete(io_data->kiocb, ret); > + io_data->kiocb->ki_complete(io_data->kiocb, (long)ret); Why just fix up this one instance? What about ep_user_copy_worker()? And what about all other calls to ki_complete that are not using a (long) cast? This feels wrong, what exactly is the reported error and how come other kernel calls to this function pointer have not had a problem with CFI? ceph_aio_complete() would be another example, right? thanks, greg k-h