Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pipe: Pass argument of pipe_fcntl as int

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 <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Kevin Brodsky <Kevin.Brodsky@arm.com>
Cc: Vincenzo Frascino <Vincenzo.Frascino@arm.com>
Cc: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: David Laight <David.Laight@ACULAB.com>
Cc: Mark Rutland <Mark.Rutland@arm.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-morello@op-lists.linaro.org
Signed-off-by: Luca Vizzarro <Luca.Vizzarro@arm.com>
Message-Id: <20230414152459.816046-4-Luca.Vizzarro@arm.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Luca Vizzarro and committed by
Christian Brauner
515c5046 ed5f17f6

+5 -5
+3 -3
fs/pipe.c
··· 1236 1236 * Currently we rely on the pipe array holding a power-of-2 number 1237 1237 * of pages. Returns 0 on error. 1238 1238 */ 1239 - unsigned int round_pipe_size(unsigned long size) 1239 + unsigned int round_pipe_size(unsigned int size) 1240 1240 { 1241 1241 if (size > (1U << 31)) 1242 1242 return 0; ··· 1319 1319 * Allocate a new array of pipe buffers and copy the info over. Returns the 1320 1320 * pipe size if successful, or return -ERROR on error. 1321 1321 */ 1322 - static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) 1322 + static long pipe_set_size(struct pipe_inode_info *pipe, unsigned int arg) 1323 1323 { 1324 1324 unsigned long user_bufs; 1325 1325 unsigned int nr_slots, size; ··· 1387 1387 return pipe; 1388 1388 } 1389 1389 1390 - long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) 1390 + long pipe_fcntl(struct file *file, unsigned int cmd, unsigned int arg) 1391 1391 { 1392 1392 struct pipe_inode_info *pipe; 1393 1393 long ret;
+2 -2
include/linux/pipe_fs_i.h
··· 269 269 270 270 /* for F_SETPIPE_SZ and F_GETPIPE_SZ */ 271 271 int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots); 272 - long pipe_fcntl(struct file *, unsigned int, unsigned long arg); 272 + long pipe_fcntl(struct file *, unsigned int, unsigned int arg); 273 273 struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice); 274 274 275 275 int create_pipe_files(struct file **, int); 276 - unsigned int round_pipe_size(unsigned long size); 276 + unsigned int round_pipe_size(unsigned int size); 277 277 278 278 #endif