From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8F363F39EE; Wed, 20 May 2026 18:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779301684; cv=none; b=Fu7g+prE5x4Z/RyM+pUih3LShlRFrkWId9MEUiKO41NfJPulHbXLTqL3FfojC1xBKr436H07sGyoDio7ABnO4YcCGJHMdkTcDoQS5hQpz405ywiFhLmESQNvyt67yx8ZMPtmuKahlH3pLEk0lORp5kWRIjbi5nszDCIqKVv3h+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779301684; c=relaxed/simple; bh=jgVbQ+W7BLPzVp9hZDnpu+iDy2djidGEgXL9YJeDW8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uD0DWYGs8kWDOcCDeV4mQhr4gq8OiNx+qot+PL66p5P1ziyeeR9WUoYW5N6dk1s7z/eyEY2ZKjIL17CvbmL8Mhte5vrB+DzDAiC+ohrIeFPhqnB679kAqZHUHCocaEpcC19rwIvYjVZSj/PkmiU2jfFz/3cYVuWiuvxubsME+x0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qIp4FD/D; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qIp4FD/D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5143F1F000E9; Wed, 20 May 2026 18:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779301683; bh=B80piun3Z1eLwwNRZjLItg7tbRTNKTGUDiPx5KnG/QE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qIp4FD/DNQD3q2ny4pc80+qfEdD5+dpB9C9AYCTKYIdfKbhY8r6RWKF/x+2aXjhEe CfJil1WpbTfum6k+4TlD/BdKltR7VqajMH5bu+qwL4ty283kwkwCbhx5sbLHv9slWp gpW5jTyqnEJ+UAuDdrEp0qnIW7ydBfbKjbjyYN2A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhenzhong Duan , Lu Baolu , Pranjal Shrivastava , Shuai Xue , Kevin Tian , Jason Gunthorpe , Sasha Levin Subject: [PATCH 6.12 647/666] iommufd: Fix return value of iommufd_fault_fops_write() Date: Wed, 20 May 2026 18:24:18 +0200 Message-ID: <20260520162125.305341764@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhenzhong Duan [ Upstream commit aaca2aa92785a6ab8e3183e7184bca447a99cd76 ] copy_from_user() may return number of bytes failed to copy, we should not pass over this number to user space to cheat that write() succeed. Instead, -EFAULT should be returned. Link: https://patch.msgid.link/r/20260330030755.12856-1-zhenzhong.duan@intel.com Cc: stable@vger.kernel.org Fixes: 07838f7fd529 ("iommufd: Add iommufd fault object") Signed-off-by: Zhenzhong Duan Reviewed-by: Lu Baolu Reviewed-by: Pranjal Shrivastava Reviewed-by: Shuai Xue Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe [ applied identical hunk to drivers/iommu/iommufd/fault.c ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/iommufd/fault.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -317,9 +317,10 @@ static ssize_t iommufd_fault_fops_write( mutex_lock(&fault->mutex); while (count > done) { - rc = copy_from_user(&response, buf + done, response_size); - if (rc) + if (copy_from_user(&response, buf + done, response_size)) { + rc = -EFAULT; break; + } static_assert((int)IOMMUFD_PAGE_RESP_SUCCESS == (int)IOMMU_PAGE_RESP_SUCCESS);