From patchwork Wed Mar 23 23:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12790223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67A3FC433EF for ; Wed, 23 Mar 2022 23:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3F636B0074; Wed, 23 Mar 2022 19:06:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEE976B0082; Wed, 23 Mar 2022 19:06:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8F766B0083; Wed, 23 Mar 2022 19:06:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id BA2C76B0074 for ; Wed, 23 Mar 2022 19:06:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8BB66246DC for ; Wed, 23 Mar 2022 23:06:30 +0000 (UTC) X-FDA: 79277186940.04.843694E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf21.hostedemail.com (Postfix) with ESMTP id 0AE361C0007 for ; Wed, 23 Mar 2022 23:06:29 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id B5FF0B8217F; Wed, 23 Mar 2022 23:06:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C695C340EE; Wed, 23 Mar 2022 23:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648076787; bh=u8NikUXS3lKhEPGBMZz34AzW0dMm+xyst10stuZzfes=; h=Date:To:From:In-Reply-To:Subject:From; b=19H5erTVx/m2WAsNRfXfBdJJG1aqs0Wr/asUdzwnsMhhZ2ob2BCn6HtlKf1T5EXAy +W45FfC37SpMRk7m6L46yFcaSEJ9YKdqceTDwV8lW5dTa9osclNHsswfD9iPI8ixM8 1oMhInodKY5Br0vf0GUjHXYMGiOVvLOBk4HFGEv0= Date: Wed, 23 Mar 2022 16:06:26 -0700 To: schwab@linux-m68k.org,hirofumi@mail.parknet.co.jp,David.Laight@aculab.com,deller@gmx.de,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220323160453.65922ced539cbf445b191555@linux-foundation.org> Subject: [patch 23/41] fat: use pointer to simple type in put_user() Message-Id: <20220323230627.6C695C340EE@smtp.kernel.org> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0AE361C0007 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=19H5erTV; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 914ogfehb3n9yf68bjwedarx1ezcayg6 X-HE-Tag: 1648076789-464279 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Helge Deller Subject: fat: use pointer to simple type in put_user() The put_user(val,ptr) macro wants a pointer to a simple type, but in fat_ioctl_filldir() the d_name field references an "array of chars". Be more accurate and explicitly give the pointer to the first character of the d_name[] array. I noticed that issue while trying to optimize the parisc put_user() macro and used an intermediate variable to store the pointer. In that case I got this error: In file included from include/linux/uaccess.h:11, from include/linux/compat.h:17, from fs/fat/dir.c:18: fs/fat/dir.c: In function `fat_ioctl_filldir': fs/fat/dir.c:725:33: error: invalid initializer 725 | if (put_user(0, d2->d_name) || \ | ^~ include/asm/uaccess.h:152:33: note: in definition of macro `__put_user' 152 | __typeof__(ptr) __ptr = ptr; \ | ^~~ fs/fat/dir.c:759:1: note: in expansion of macro `FAT_IOCTL_FILLDIR_FUNC' 759 | FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent) Andreas Schwab suggested to use __typeof__(&*(ptr)) __ptr = ptr; instead. This works, but nevertheless it's probably reasonable to fix the original caller too. Link: https://lkml.kernel.org/r/Ygo+A9MREmC1H3kr@p100 Signed-off-by: Helge Deller Acked-by: OGAWA Hirofumi Cc: David Laight Cc: Andreas Schwab Signed-off-by: Andrew Morton --- fs/fat/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/fat/dir.c~fat-use-pointer-to-simple-type-in-put_user +++ a/fs/fat/dir.c @@ -722,7 +722,7 @@ static int func(struct dir_context *ctx, if (name_len >= sizeof(d1->d_name)) \ name_len = sizeof(d1->d_name) - 1; \ \ - if (put_user(0, d2->d_name) || \ + if (put_user(0, &d2->d_name[0]) || \ put_user(0, &d2->d_reclen) || \ copy_to_user(d1->d_name, name, name_len) || \ put_user(0, d1->d_name + name_len) || \