Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp690636rwe; Fri, 14 Apr 2023 08:29:02 -0700 (PDT) X-Google-Smtp-Source: AKy350YEBJL6S1dEtEGrs0ggjy4sJAeAAE+64oQRNvPXnp8CEA53Ewh9Y7B2H3/1zRuuBLLUGiWJ X-Received: by 2002:a05:6a00:856:b0:636:a399:e81a with SMTP id q22-20020a056a00085600b00636a399e81amr8866834pfk.6.1681486142114; Fri, 14 Apr 2023 08:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681486142; cv=none; d=google.com; s=arc-20160816; b=sn8cSSa/Y+Lpc1pNPb2Ah9u/FM4uZdXxbF9J0GbjqXyaNvIKnxpJcYP3egSNSwtBbd FT1QgpAwAyoVD/I3nUz0jQbaj9nONDhc8B9hTi+Q5mOWOWdS3Xr/I+6q4ZAZESwd65go a49URC0re3jgFfop5n90lHymZCkNU07LcaxzUTNfBRLBiWVgRdNM/m9HPOgwXPH2GnZA B+l3KVEci+wCKdJsNk60Eha0+2EF4ExJ6fpZj58RZmN4ThSpxjOXIXuVLLAWuyhfPb+O f4YdTGkkVxrZXKjbA23pKgE1HZoU3dYsn8tORRUuot+iMWC6Wh9Qo4dntRQ4besp0yqF Ifog== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fivVDqpX8JnXWHwPIKU74adS6+9rHNUAq7px4Jf3VzY=; b=gntLaUyuFUlrOabsrOOhbBDj7g2dhI2+ErTZkSJj+qJDRyXhBbgxJNDKgW4x0Dh3Rg 9ya/hrKFc3jLpj5+ZX/EO8p+hYswnbFmAvjUwFqOgxAxau+9YQagj+4izh5DIdWsbdfH DOJ8szEHycDijq9I30hilVCDf5XesLiN7r3yIbS9kt2EKZ6yxVJGJO1AUxADOpZ+MLKx qhGhw6BqJx6IqkibTve/yqMtJMBsrmZc4uk5yWE8hIzRjrZtZ6k2yYakCaEDFI1muz11 dCHtYPjPynoYr1A/gZg5foes2krHGiUi/viNeSWCWbQVHPIb7hfXeln+c8CwzFouIT2D oKgQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020aa79618000000b0063ae1f587e3si4713601pfg.11.2023.04.14.08.28.42; Fri, 14 Apr 2023 08:29:02 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjDNP0x (ORCPT + 99 others); Fri, 14 Apr 2023 11:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230392AbjDNP0l (ORCPT ); Fri, 14 Apr 2023 11:26:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ACF75D338; Fri, 14 Apr 2023 08:26:07 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F0001713; Fri, 14 Apr 2023 08:26:03 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DAC573F6C4; Fri, 14 Apr 2023 08:25:16 -0700 (PDT) From: Luca Vizzarro To: linux-kernel@vger.kernel.org Cc: Luca Vizzarro , Alexander Viro , Christian Brauner , Jeff Layton , Chuck Lever , Kevin Brodsky , Vincenzo Frascino , Szabolcs Nagy , "Theodore Ts'o" , David Laight , Mark Rutland , linux-fsdevel@vger.kernel.org, linux-morello@op-lists.linaro.org Subject: [PATCH v2 3/5] pipe: Pass argument of pipe_fcntl as int Date: Fri, 14 Apr 2023 16:24:57 +0100 Message-Id: <20230414152459.816046-4-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414152459.816046-1-Luca.Vizzarro@arm.com> References: <20230414152459.816046-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 The interface for fcntl expects the argument passed for the command F_SETPIPE_SZ to be of type int. The current code wrongly treats it as a long. In order to avoid access to undefined bits, we should explicitly cast the argument to int. Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: Kevin Brodsky Cc: Vincenzo Frascino Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: linux-fsdevel@vger.kernel.org Cc: linux-morello@op-lists.linaro.org Signed-off-by: Luca Vizzarro --- fs/pipe.c | 6 +++--- include/linux/pipe_fs_i.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 42c7ff41c2db..5b718342105f 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1231,7 +1231,7 @@ const struct file_operations pipefifo_fops = { * Currently we rely on the pipe array holding a power-of-2 number * of pages. Returns 0 on error. */ -unsigned int round_pipe_size(unsigned long size) +unsigned int round_pipe_size(unsigned int size) { if (size > (1U << 31)) return 0; @@ -1314,7 +1314,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) * Allocate a new array of pipe buffers and copy the info over. Returns the * pipe size if successful, or return -ERROR on error. */ -static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) +static long pipe_set_size(struct pipe_inode_info *pipe, unsigned int arg) { unsigned long user_bufs; unsigned int nr_slots, size; @@ -1382,7 +1382,7 @@ struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice) return pipe; } -long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) +long pipe_fcntl(struct file *file, unsigned int cmd, unsigned int arg) { struct pipe_inode_info *pipe; long ret; diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index d2c3f16cf6b1..033d77f0c568 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -273,10 +273,10 @@ bool pipe_is_unprivileged_user(void); #ifdef CONFIG_WATCH_QUEUE int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots); #endif -long pipe_fcntl(struct file *, unsigned int, unsigned long arg); +long pipe_fcntl(struct file *, unsigned int, unsigned int arg); struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice); int create_pipe_files(struct file **, int); -unsigned int round_pipe_size(unsigned long size); +unsigned int round_pipe_size(unsigned int size); #endif -- 2.34.1