Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1179223rwb; Thu, 10 Nov 2022 12:17:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM7+EqE3KcO4CI6Wwz9546DlAOlcIimvi8wBTuCuYw4pCjXHa2zit/hbVfdj1iIeZD0sfm0j X-Received: by 2002:a17:906:b849:b0:7ad:c66e:ad9d with SMTP id ga9-20020a170906b84900b007adc66ead9dmr3678708ejb.413.1668111463563; Thu, 10 Nov 2022 12:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668111463; cv=none; d=google.com; s=arc-20160816; b=v5S1cHRL1go1EK3XEZqon+RN0+awGjLbAaEqNR9rSt44LFEg5kaSH+mdfK6owvpsw3 p3NwiIdIwrS0/tJt3vPsOVohxTgKUGHaY8DlCbICJisQCkWG+HqKR2yVHRhCKIKUCQ48 e72dkp8BsvQWkB+zKeIsPGuPrGK9fXTLE4217W4ilFdVJ7OABvj5nOCro+bFAjM1T+5s Vb5F5IMJfRgBXkP14TULDtoXPEJ/3vCdenGj79kDzZhdcpQ/i4uBbJAtlp1IVzwcFPg2 Z8SgH53AThVR/jB4zvdO+NgSjZm9HWthtvNRpmrJJNXwp4pLuCpq5xYg0azBFgu9B+X4 h65w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=2pCPNKdx3WNpIGdiI6G5F3qhAgKWXle3KXfKs0ER5VY=; b=ths5DybDaonlu1RZ+X5UDKF5HCzjkAKqlxIBE00fOfUr9xoh5GM8WJiE32ZuhfxP3x DW7YOwzMfwz7AtuYM1bOgRItSYRoybYnVWAxmAwhW0gh2mdfJxuak3G/2mZm7SNvytrh nneyIb3VVR7AU/7BxvjBSlSe2B+gXqpOJGgN68WpMfgxQAQ/GUvvcLeqyddG9dY3IxEJ I94A3k1q6viyU0O1TgkCT+y34umZYk9a7d8h/RPVQAxj3jXI9Ads4yPpzu2INPgMDpzc rNNA0G/dzWiaQtWpGNJH2khwZoPeVOKZj2O+AeYjPTjbKDwnj1maSEhKvdhiTlTHfmn5 5cQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qWEXo2c/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a170906064a00b007adb2868da6si156339ejb.646.2022.11.10.12.17.19; Thu, 10 Nov 2022 12:17:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qWEXo2c/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbiKJUQc (ORCPT + 99 others); Thu, 10 Nov 2022 15:16:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbiKJUQb (ORCPT ); Thu, 10 Nov 2022 15:16:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A225F4D5DD for ; Thu, 10 Nov 2022 12:16:30 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3795E61CAD for ; Thu, 10 Nov 2022 20:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D4E2C43142; Thu, 10 Nov 2022 20:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668111389; bh=wc22eyHGw2b/YPLdii2igwaFo5ZDgn6bjvKlINXaGZk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qWEXo2c/QllZY9OqMa2VPH0/kof6QtIEW+I7j30uG/gZkn/9E21Cp0PWAELadEmN4 dKI/0JpSCgYZY6s2K8bcXcG6KS1ynA2uSqwHiCbI7Zs1jGH0pOOlUn3phnBKlN/ZfV msHi0NMCh8OacPxrvm4rBBEG6ghGrgGEgSoa3Ff8DeYI+qAn1bIzQ51RynzMf5l8ZN HzOaHuQuxL4idkbLSG6Menl569p7f3nIyf/X0bt3tNoFW8fhNKo7of/DpjSUNwntJg d50d/qxdOFl8CxHcK4yD3jC3gEDBj/FxgMchS91QVp6ROyj1iCE3Tp5i+2SGV+vE1K 2JBT6xvwC2uxQ== Subject: [PATCH 1/2] ext4: dont return EINVAL from GETFSUUID when reporting UUID length From: "Darrick J. Wong" To: djwong@kernel.org, tytso@mit.edu Cc: catherine.hoang@oracle.com, linux-ext4@vger.kernel.org Date: Thu, 10 Nov 2022 12:16:29 -0800 Message-ID: <166811138914.327006.9241306894437166566.stgit@magnolia> In-Reply-To: <166811138334.327006.2601737065307668866.stgit@magnolia> References: <166811138334.327006.2601737065307668866.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-ext4@vger.kernel.org From: Darrick J. Wong If userspace calls this ioctl with fsu_length (the length of the fsuuid.fsu_uuid array) set to zero, ext4 copies the desired uuid length out to userspace. The kernel call returned a result from a valid input, so the return value here should be zero, not EINVAL. While we're at it, fix the copy_to_user call to make it clear that we're only copying out fsu_len. Signed-off-by: Darrick J. Wong --- fs/ext4/ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 95dfea28bf4e..5f91f3ad3e50 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1153,9 +1153,10 @@ static int ext4_ioctl_getuuid(struct ext4_sb_info *sbi, if (fsuuid.fsu_len == 0) { fsuuid.fsu_len = UUID_SIZE; - if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len))) + if (copy_to_user(&ufsuuid->fsu_len, &fsuuid.fsu_len, + sizeof(fsuuid.fsu_len))) return -EFAULT; - return -EINVAL; + return 0; } if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)