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 B235C46A5F0; Tue, 21 Jul 2026 15:41:50 +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=1784648511; cv=none; b=b3oBGApoIPs9w+IX8uxGzEIgH6juxR/YTWEaDEdGylI2jWQQpN3eiFWzWz/9MJ7CHeZin/03gv/VP8CjC4D1StKHigYCM25gJqV2zFbAbM6ImpYPtrcNEzbBxUcn6daws0A+s+u4KrVi43M0JdrsJqEhak/QNsut/3iPR7wBkt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648511; c=relaxed/simple; bh=mRMjerLiwmgKRAFTjoAL+i9CLafAOekLeZssWy2rz2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i/03D+gpPOFyOMR2cITsNDpGvbqXJ4NbRIkJypkFAHH3qrVe4V2EcalWXrJa7hJ30fHSRRnxENDbxslmc4AD585vdkyLGxZJyOw0Eqc0sAM7IpbK8BoizkYBx0cnh6vTlWeU57pvPZSsb15OG7cKQ7hReyh0nO04bLsehXKquGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cpB64mHY; 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="cpB64mHY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC091F000E9; Tue, 21 Jul 2026 15:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784648510; bh=7BuoZI+XnZ/8OnKEHB9XmInh1R8NJlsPQewKKPefN5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cpB64mHYkum+idpmBo60FCc/OshuPvJQAm/lJ3R5Sa1+Ki/8IN1wMworbLIzIkTif /PIjOKnnMTaa3iIbxeUk4LPaU67xvsYbHjZiC7nHwP9bIA/ULqWBgTVd/BbJ656YJW rVrKCr8+y0yDuFSycre/zKDjJqEAYtNkIS6tctBs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Francesco Ruggeri , Salam Noureddine , David Ahern , "David S. Miller" , Michal Luczaj , David Wei , Luiz Augusto von Dentz , Luiz Augusto von Dentz , Marcel Holtmann , Xin Long , Eric Dumazet , Kuniyuki Iwashima , Paolo Abeni , Willem de Bruijn , Neal Cardwell , Jakub Kicinski , Simon Horman , Aleksa Sarai , Christian Brauner , Kees Cook , netdev@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Metzmacher , Aleksa Sarai , Sasha Levin Subject: [PATCH 7.1 0184/2077] uaccess: fix ignored_trailing logic in copy_struct_to_user() Date: Tue, 21 Jul 2026 16:57:37 +0200 Message-ID: <20260721152557.023320054@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Metzmacher [ Upstream commit 4911de3145a797389577abfdf9a5185d36cc18d7 ] Currently all callers pass ignored_trailing=NULL, but I have code that will make use of. Now it actually behaves like documented: * If @usize < @ksize, then the kernel is trying to pass userspace a newer struct than it supports. Thus we only copy the interoperable portions (@usize) and ignore the rest (but @ignored_trailing is set to %true if any of the trailing (@ksize - @usize) bytes are non-zero). Fixes: 424a55a4a908 ("uaccess: add copy_struct_to_user helper") Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Dmitry Safonov Cc: Francesco Ruggeri Cc: Salam Noureddine Cc: David Ahern Cc: David S. Miller Cc: Michal Luczaj Cc: David Wei Cc: Luiz Augusto von Dentz Cc: Luiz Augusto von Dentz Cc: Marcel Holtmann Cc: Xin Long Cc: Eric Dumazet Cc: Kuniyuki Iwashima Cc: Paolo Abeni Cc: Willem de Bruijn Cc: Neal Cardwell Cc: Jakub Kicinski Cc: Simon Horman Cc: Aleksa Sarai Cc: Christian Brauner CC: Kees Cook Cc: netdev@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Stefan Metzmacher Link: https://patch.msgid.link/71f69442410c1186ed8ce6d5b4b9d4a5a70edbad.1775576651.git.metze@samba.org Reviewed-by: Aleksa Sarai Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- include/linux/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 56328601218c5a..09a09cc4aac274 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -510,7 +510,7 @@ copy_struct_to_user(void __user *dst, size_t usize, const void *src, return -EFAULT; } if (ignored_trailing) - *ignored_trailing = ksize < usize && + *ignored_trailing = usize < ksize && memchr_inv(src + size, 0, rest) != NULL; /* Copy the interoperable parts of the struct. */ if (copy_to_user(dst, src, size)) -- 2.53.0