Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754382AbcLBRjw (ORCPT ); Fri, 2 Dec 2016 12:39:52 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35350 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752207AbcLBRjm (ORCPT ); Fri, 2 Dec 2016 12:39:42 -0500 From: Quentin Lambert To: Oleg Drokin , Andreas Dilger , James Simmons , Greg Kroah-Hartman , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Cc: Quentin Lambert Subject: [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space Date: Fri, 2 Dec 2016 18:33:32 +0100 Message-Id: <20161202173332.5100-1-lambert.quentin@gmail.com> X-Mailer: git-send-email 2.10.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 811 Lines: 27 lnet_ipif_enumerate was assigning a pointer from kernel space to user space. This patch uses copy_to_user to properly do that assignment. Signed-off-by: Quentin Lambert --- shouldn't we be using ifc_req instead of ifc_buf? drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -181,7 +181,13 @@ lnet_ipif_enumerate(char ***namesp) goto out0; } - ifc.ifc_buf = (char *)ifr; + rc = copy_to_user(ifc.ifc_buf, (char *)ifr, + nalloc * sizeof(*ifr)); + if (rc) { + rc = -ENOMEM; + goto out1; + } + ifc.ifc_len = nalloc * sizeof(*ifr); rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);