Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5573852pxb; Mon, 14 Feb 2022 02:20:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjYg5KLJkx8T6qb2/rvvSeJTDhEucbGUqoegAN+fCQaYMhn17I/AKFWvJqH6FIr8jbuqDN X-Received: by 2002:a17:903:40c6:: with SMTP id t6mr13315033pld.117.1644834028768; Mon, 14 Feb 2022 02:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644834028; cv=none; d=google.com; s=arc-20160816; b=KC3+3XeDVIvZSqR680cQD/JxZV3mO9d1t9cQNkUL4+u3re5BcC1SZXy0ZT2tQZ3eiH 4snmfa4eFanhBucZp3710Z8fdz8QubhWsWW7xsD52qXh9vudGPcOiyem4a/lErQYHZAx RUrFWYMLW2wxS3rcVEs+/oX+KrylEaNTB9NoAbcqrHPdVCIOmX555Y6aB9RD+NhhMVyM HK7iBjgAl5yrXqI1B/70NRsW5/eEfLFHS7RsTL/cS5VrfZreIR1fVnCH5p8Wk5v8t8Tv WN/gqklz5yn0NfVcrw8RCpfMJLj2MaLVEozKZdchNo5P3kEUhBqfDieNvKJq+D01FHxL 18Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from; bh=BRUOVZNU39g/PDjYk2OZFrg5uBPwbSrwIvHSebNidm0=; b=sROCbG/ZKkFfv22weVNjkkz0jncar25vlK27x9oUVWLMFHDyHQdXKKatTnpVe60aQG I4yBM5KEP2QmnPXwoiPMRviyx5ktme+YBp+dYC/+hbqRyiZg1hjWw5t0qiAt6Jg8uqIj Oum87xiFW+QUko6ipOthseRD5Slaq2ryShEVNqfmlbObJC10J1z5gVS0qGYcP2vb+VhM Yi0UQP5WhvVDI56i+7eUYaGuJ3SyVHP1Ct4acYRDxbtptF0GjWMMnV2W3twceNq/RE31 PY4Ldy6ghl1OTx4/X0lctfQgpRqIX67i7G4+0dGVGb6QlvDd9cpK09Vb0dgEl0YIbJD6 naag== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17si10745007plh.596.2022.02.14.02.20.14; Mon, 14 Feb 2022 02:20:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241554AbiBNIHB (ORCPT + 99 others); Mon, 14 Feb 2022 03:07:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbiBNIHA (ORCPT ); Mon, 14 Feb 2022 03:07:00 -0500 X-Greylist: delayed 419 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 14 Feb 2022 00:06:52 PST Received: from mail.parknet.co.jp (mail.parknet.co.jp [210.171.160.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 848B75F27B; Mon, 14 Feb 2022 00:06:52 -0800 (PST) Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 5364915F93A; Mon, 14 Feb 2022 16:59:52 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.16.1/8.16.1/Debian-2) with ESMTPS id 21E7xoRZ051364 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 16:59:51 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.16.1/8.16.1/Debian-2) with ESMTPS id 21E7xoWK253761 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 16:59:50 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.16.1/8.16.1/Submit) id 21E7xoEx253760; Mon, 14 Feb 2022 16:59:50 +0900 From: OGAWA Hirofumi To: Helge Deller Cc: linux-kernel@vger.kernel.org, Andrew Morton , linux-parisc@vger.kernel.org Subject: Re: [PATCH] fat: Use pointer to d_name[0] in put_user() for compat case References: Date: Mon, 14 Feb 2022 16:59:50 +0900 In-Reply-To: (Helge Deller's message of "Sun, 13 Feb 2022 23:10:27 +0100") Message-ID: <87y22dho95.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE 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 Helge Deller writes: > The put_user(val,ptr) macro wants a pointer in the second parameter, but in > fat_ioctl_filldir() the d_name field references a whole "array of chars". > Usually the compiler automatically converts it and uses a pointer to that > array, but it's more clean to explicitly give the real pointer to where someting > is put, which is in this case 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) > > The patch below cleans it up. > > Signed-off-by: Helge Deller Looks good. Acked-by: OGAWA Hirofumi > diff --git a/fs/fat/dir.c b/fs/fat/dir.c > index c4a274285858..249825017da7 100644 > --- a/fs/fat/dir.c > +++ b/fs/fat/dir.c > @@ -722,7 +722,7 @@ static int func(struct dir_context *ctx, const char *name, int name_len, \ > 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) || \ -- OGAWA Hirofumi