From nobody Thu Dec 18 18:51:18 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6062AC77B6F for ; Fri, 14 Apr 2023 10:02:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230073AbjDNKCw (ORCPT ); Fri, 14 Apr 2023 06:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjDNKCr (ORCPT ); Fri, 14 Apr 2023 06:02:47 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2071.outbound.protection.outlook.com [40.107.13.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18C7A7D91; Fri, 14 Apr 2023 03:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R1CjXb9KzVRUCMvJ/++SI3aV4TTk9Q8RSGMhb0oiuik=; b=dxx6QvovAvlKDwJTy6zKVoOKWkteMhKC78UHMJS8TKTL0C0J+LukdhmdyQzYK34XhrauQNUDLcILlE8SOgX0xdPnw0imfTNLC8IKaqWs9zJEH8B2Scrt1KSmDKlmqwtAVuOYPY0Chks+wN0hjSoO/Eme8QMapTW70M6iqMM5tEI= Received: from DUZPR01CA0149.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::25) by AS8PR08MB5909.eurprd08.prod.outlook.com (2603:10a6:20b:297::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Fri, 14 Apr 2023 10:02:42 +0000 Received: from DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bd:cafe::60) by DUZPR01CA0149.outlook.office365.com (2603:10a6:10:4bd::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT011.mail.protection.outlook.com (100.127.142.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 Received: ("Tessian outbound 3a01b65b5aad:v136"); Fri, 14 Apr 2023 10:02:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bb7821e7f456537f X-CR-MTA-TID: 64aa7808 Received: from 5e167ff54ce4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7CA5BD1E-5DA4-47D0-810D-D742C7819C17.1; Fri, 14 Apr 2023 10:02:35 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5e167ff54ce4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 10:02:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dS6waTpHDFbs+G3xws8v72TmZI8rNnR6dBXTlHlNSJx2rjGT1Nn6CTnhZytZBOjhFbjDB2NT0gZRsX1oDtbkThFFQvbXOUf0EEkqyG2F4u3EeHBBUL/fN45WMUeCBUEWNbOg9T0lM6FUZQ/I1tbge9OHMmw/BGPLWLW4zSRzcm5H7nsy1yDuJV5jMljTJ3VUyi86U6/5bb8YVrlLCUXxDTfwItv4UMBudw3rqP/QIpbnHFsGTas0uuK4ZvghNjDhdiAXWUnGrvseCCvad3ldMM08PKLayJYFrrcM7Ufsq6AgGQsP0WLKd9Pnm/oN+swmyCvknIWS5SiPbFNxJaNR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R1CjXb9KzVRUCMvJ/++SI3aV4TTk9Q8RSGMhb0oiuik=; b=Tb0BFgRYJRxmh7cZ4zG48JcJF285PexFp/1eVsam2mOy+DDXJPfDL0E4b8UIhtK8ZYhMl42byh+On5MpG1sjV1uZdugWOk/4oaGrrf3wImEE/mCeCOsHAR7X+nu/0rzwMfK30ca4T6V37NYY82x4wqjCa/Z/IS0q3gSNgZlKAXfq5X7f3r1ZQv+tElD6GpNPeRofegBv8P7OQTSai+8GIx6tnCPlBdNOAzzesH+0rLndZPnB/o4C/wH8XrQjdDhiZe2e+GadseEiOH0s5olzFMe578+XJEAZzYECrboGyvQEDSGAviVQtl69xwB3e8QoPfARmRM4KUXZDuTiV3V2Bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R1CjXb9KzVRUCMvJ/++SI3aV4TTk9Q8RSGMhb0oiuik=; b=dxx6QvovAvlKDwJTy6zKVoOKWkteMhKC78UHMJS8TKTL0C0J+LukdhmdyQzYK34XhrauQNUDLcILlE8SOgX0xdPnw0imfTNLC8IKaqWs9zJEH8B2Scrt1KSmDKlmqwtAVuOYPY0Chks+wN0hjSoO/Eme8QMapTW70M6iqMM5tEI= Received: from DUZPR01CA0025.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::13) by GV1PR08MB7852.eurprd08.prod.outlook.com (2603:10a6:150:5f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Fri, 14 Apr 2023 10:02:30 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::da) by DUZPR01CA0025.outlook.office365.com (2603:10a6:10:46b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 10:02:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:30 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:29 +0000 Received: from localhost.localdomain (10.57.20.128) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Fri, 14 Apr 2023 10:02:28 +0000 From: Luca Vizzarro To: CC: Luca Vizzarro , Kevin Brodsky , Szabolcs Nagy , Theodore Ts'o , David Laight , Mark Rutland , Alexander Viro , "Christian Brauner" , Jeff Layton , Chuck Lever , Subject: [PATCH 1/5] fcntl: Cast commands with int args explicitly Date: Fri, 14 Apr 2023 11:02:08 +0100 Message-ID: <20230414100212.766118-2-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414100212.766118-1-Luca.Vizzarro@arm.com> References: <20230414100212.766118-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|GV1PR08MB7852:EE_|DBAEUR03FT011:EE_|AS8PR08MB5909:EE_ X-MS-Office365-Filtering-Correlation-Id: e12c5ceb-ae88-4900-0724-08db3ccf6319 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Yd8xvFgJbpffiqrw86lv8QOeO3TPMTMcm6oBHz/eBIk6uFGQy/nGZCkVhkBL6BwnH2SC7GfAT7Pvk/lUew7PxZd1H/3tFmA5cINT0Fi2VMFIBpjX+dPXWnQEnRUwBXC470Pc7cVQ2TaUpn1lwDa0W3RATv8oHGkfj4aumxS9314McRNIBDuuntXXSECjL7+z3VmgdRNoa4gB2V7D1dxAIFlpwfzHEUgK0WMs6Jiqurx8FXEGeMhbywgLZQ2jDDxx0SrqR4fHOoTq11XY9NoYH57mY9mBx1PCZ8jRakCUXVa5EaGpwmCI6J1ZVHtPabuf61I2fwTgD0OyqionCOS3WDx1GM/2rFexxh9Ay0aS084W50CVU9xNI6X2Eo6Jws8H0ZXd8Ub5S8THD4kEx7hnD3jCbHLSkJ+V8S7K/grf6YLuwuf78V46ctFkRooTwHr5zleKGqtFjMMjp4w83vnkx3+uor2b8yTCOeL17WKozjVppgDEdqya6VrzD00bQmBWiiO87KvXYSE2M1EQbD7DB86fpXUML8QCId/FU6HPY0jwSJ6uMH3XZbDu424NfNY6q70CRcPped7xk5AKdSSGv4888PQyZWwBjeXyPpsyULj8f9NV72dwCz2m8SDu1dWPJ8d2kwYEWHIR0bxkmL9RTuAB5kM5nv6dZFifMCojTWPuVBm7flOu4Ff6fWouctOZX/VJsYUBI1p308hWP2h1lA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(36840700001)(46966006)(70586007)(81166007)(1076003)(36860700001)(26005)(82740400003)(186003)(47076005)(426003)(336012)(6666004)(2616005)(356005)(36756003)(8676002)(5660300002)(82310400005)(2906002)(478600001)(86362001)(41300700001)(8936002)(54906003)(316002)(40480700001)(70206006)(4326008)(6916009)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7852 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 917572e1-040d-42c8-0a2d-08db3ccf5bfe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cyGkbjyBNJYLUUwntADJx1HdQdyGPr9mq6IuboStAxXtiE0z4OvZ8ycGNV9r9Z2XIZUz5DdBfe8ukOuoBZBhF6ZpJclLmRqHUq2/nXIDvHp0vHQl8hJDAxECV/Tcyn6FnDo8J34el07D9FK8n3/fs133aih5m/eT8h7bW6CQrQUhV0Xv3bM4OK9jvqTfjMJyhO+UuNi3nhsdhbdsSVGw/XZn6xSpazD4WhHKCWluSV0OxdAAKGegp/t3AB+7gkiPf022UZCNQI12JknbAZFvnxvdnC3AnM6jNsa8tGynT78w+Fu7HCgMjTwfU2uf6tsXWwvKqdmM/l0az633/89KVA3a782Zc7hWvBkKIKx2MHkAIf8d+dMUIRrRwm9Fel+NRm1xVVrtulxCMBBvKNQNlK8GnP7gUHlvU6vym9EOidsoANV/Yv0lTRBospIwnPk81yHJwwIMKPWHf3yWWChOJHfDf9YPXwburZLDlARtx3O7jutJd4KT6tkenHxSpIJ2FVPWKf+SKUHVVyVeiDom0bSNwgVvvHNgGBeC2Gm3fHAQXeocH4bJPKbiwY7JVLc4rgHWKd2cFyMNzJrk+kZ/iOCMwnpsd2+uYh55ncI4bys5M8DEgN//J2h3A2CAa7goG5d9jBfaROJIBub63zb9zRbWfsR0qr01hb3Sps4GEQYkdnCHnn0fmJnRDTIwCGpNqEu9MuGP/zwD1BQSAp6Qaw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(46966006)(36840700001)(40470700004)(36756003)(82310400005)(40460700003)(2906002)(5660300002)(8676002)(8936002)(86362001)(40480700001)(1076003)(6666004)(26005)(54906003)(36860700001)(478600001)(2616005)(47076005)(186003)(336012)(426003)(83380400001)(450100002)(70586007)(82740400003)(70206006)(81166007)(41300700001)(6916009)(4326008)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 10:02:42.1382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e12c5ceb-ae88-4900-0724-08db3ccf6319 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5909 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" According to the fcntl API specification commands that expect an integer, hence not a pointer, always take an int and not long. In order to avoid access to undefined bits, we should explicitly cast the argument to int. Cc: Kevin Brodsky Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Luca Vizzarro --- fs/fcntl.c | 29 +++++++++++++++-------------- include/linux/fs.h | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index b622be119706..e871009f6c88 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -34,7 +34,7 @@ #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIM= E) -static int setfl(int fd, struct file * filp, unsigned long arg) +static int setfl(int fd, struct file * filp, unsigned int arg) { struct inode * inode =3D file_inode(filp); int error =3D 0; @@ -112,11 +112,11 @@ void __f_setown(struct file *filp, struct pid *pid, e= num pid_type type, } EXPORT_SYMBOL(__f_setown); -int f_setown(struct file *filp, unsigned long arg, int force) +int f_setown(struct file *filp, int who, int force) { enum pid_type type; struct pid *pid =3D NULL; - int who =3D arg, ret =3D 0; + int ret =3D 0; type =3D PIDTYPE_TGID; if (who < 0) { @@ -317,28 +317,29 @@ static long do_fcntl(int fd, unsigned int cmd, unsign= ed long arg, struct file *filp) { void __user *argp =3D (void __user *)arg; + int argi =3D (int)arg; struct flock flock; long err =3D -EINVAL; switch (cmd) { case F_DUPFD: - err =3D f_dupfd(arg, filp, 0); + err =3D f_dupfd(argi, filp, 0); break; case F_DUPFD_CLOEXEC: - err =3D f_dupfd(arg, filp, O_CLOEXEC); + err =3D f_dupfd(argi, filp, O_CLOEXEC); break; case F_GETFD: err =3D get_close_on_exec(fd) ? FD_CLOEXEC : 0; break; case F_SETFD: err =3D 0; - set_close_on_exec(fd, arg & FD_CLOEXEC); + set_close_on_exec(fd, argi & FD_CLOEXEC); break; case F_GETFL: err =3D filp->f_flags; break; case F_SETFL: - err =3D setfl(fd, filp, arg); + err =3D setfl(fd, filp, argi); break; #if BITS_PER_LONG !=3D 32 /* 32-bit arches must use fcntl64() */ @@ -375,7 +376,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned= long arg, force_successful_syscall_return(); break; case F_SETOWN: - err =3D f_setown(filp, arg, 1); + err =3D f_setown(filp, argi, 1); break; case F_GETOWN_EX: err =3D f_getown_ex(filp, arg); @@ -391,28 +392,28 @@ static long do_fcntl(int fd, unsigned int cmd, unsign= ed long arg, break; case F_SETSIG: /* arg =3D=3D 0 restores default behaviour. */ - if (!valid_signal(arg)) { + if (!valid_signal(argi)) { break; } err =3D 0; - filp->f_owner.signum =3D arg; + filp->f_owner.signum =3D argi; break; case F_GETLEASE: err =3D fcntl_getlease(filp); break; case F_SETLEASE: - err =3D fcntl_setlease(fd, filp, arg); + err =3D fcntl_setlease(fd, filp, argi); break; case F_NOTIFY: - err =3D fcntl_dirnotify(fd, filp, arg); + err =3D fcntl_dirnotify(fd, filp, argi); break; case F_SETPIPE_SZ: case F_GETPIPE_SZ: - err =3D pipe_fcntl(filp, cmd, arg); + err =3D pipe_fcntl(filp, cmd, argi); break; case F_ADD_SEALS: case F_GET_SEALS: - err =3D memfd_fcntl(filp, cmd, arg); + err =3D memfd_fcntl(filp, cmd, argi); break; case F_GET_RW_HINT: case F_SET_RW_HINT: diff --git a/include/linux/fs.h b/include/linux/fs.h index c85916e9f7db..8da79822dbba 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1050,7 +1050,7 @@ extern void fasync_free(struct fasync_struct *); extern void kill_fasync(struct fasync_struct **, int, int); extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int= force); -extern int f_setown(struct file *filp, unsigned long arg, int force); +extern int f_setown(struct file *filp, int who, int force); extern void f_delown(struct file *filp); extern pid_t f_getown(struct file *filp); extern int send_sigurg(struct fown_struct *fown); -- 2.34.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you. From nobody Thu Dec 18 18:51:18 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1B56C77B6F for ; Fri, 14 Apr 2023 10:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbjDNKDK (ORCPT ); Fri, 14 Apr 2023 06:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbjDNKC4 (ORCPT ); Fri, 14 Apr 2023 06:02:56 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2050.outbound.protection.outlook.com [40.107.7.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C872F8A53; Fri, 14 Apr 2023 03:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tO5DDZCuPL5WQhgwtEwx+LQGxLynHuSZjHIJuDDhYak=; b=XAFDX6aboc6bl+MA1/ExnAcY2ooaYex1jfxAvgHt1IemmQ5jav/ipGn8vFSAudti5BI2aAupiUBXUYsrX7DqnTbTGTW8y2Wg1Q0v0rT1d8lrzo7ykoUqO/desyiZe7KyQsAWpywI4F8FbqPUJgZjXuLE03C/Fjzqq8wI6vSt7I0= Received: from DU2PR04CA0090.eurprd04.prod.outlook.com (2603:10a6:10:232::35) by DB9PR08MB9636.eurprd08.prod.outlook.com (2603:10a6:10:45c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Fri, 14 Apr 2023 10:02:49 +0000 Received: from DBAEUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:232:cafe::af) by DU2PR04CA0090.outlook.office365.com (2603:10a6:10:232::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 10:02:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT038.mail.protection.outlook.com (100.127.143.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:49 +0000 Received: ("Tessian outbound 3a01b65b5aad:v136"); Fri, 14 Apr 2023 10:02:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 35b5056c35104267 X-CR-MTA-TID: 64aa7808 Received: from 2b773196d45a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BB736C91-2C76-40DC-B794-E7E984CBF406.1; Fri, 14 Apr 2023 10:02:42 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2b773196d45a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 10:02:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AHg7/VyDNXIbh33XjyU6VQzq+CtodkuoKAm2PZ5uqoxijmlltDhlefZYDrqNT+eZb3lKaEk1p9qEAqymyVmhxdzPFZrV+RApAADOvZ35v776a/lAh7Qa38tSqG6ofcoQOK6AZEXNFsU0CfGTBxEel5WgcVGwshuwLMsQoW0tjJpaJ+jiLUB8m3tSdDjkoSbr/R4jpj0X3+uS3uj+Sw2yPHPmJM1y502mLj6LG5XezrPcuCDohpmYa3OE1XDv3AIJuGdBPJRBNqeB1lV60QouZhWQwl6Bkavd6PpsUGYEtdVRnIUSaMbR9FmWvOWSsxwrYNbaCteZ5fpfqRxLSjHKAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tO5DDZCuPL5WQhgwtEwx+LQGxLynHuSZjHIJuDDhYak=; b=GWUVTe9aC6FwHDsk0CHvxg6mLzboaTw3vFT2uZMgyVgPBY2g5sgL+/bshijw+uSCmrsvb56fy2/piSkIWgE+t3OuR0zSgiw+RUSO0qvx30FKuyoBQ2KlkJqQSatjbB6e4DQAToxXEXqa8UxNHlsFOXSx/BYutXB172MMFPxtxo2dAuwXeXAcPkv/cLp6Z+ou9PONcmh3VQFL/nZhP8WY1WS0+9cCCv1nONV4+kdxhiepSaG0nTw5FKcXlIZfBLRlth/yK/wSvIPG6xSELLKmBJZDVlrxk6e+ExJEZ5tisMKLHXTEd8dNx8ceB4xi+1uVAowrH6eYWXPzCeS3CeoO2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tO5DDZCuPL5WQhgwtEwx+LQGxLynHuSZjHIJuDDhYak=; b=XAFDX6aboc6bl+MA1/ExnAcY2ooaYex1jfxAvgHt1IemmQ5jav/ipGn8vFSAudti5BI2aAupiUBXUYsrX7DqnTbTGTW8y2Wg1Q0v0rT1d8lrzo7ykoUqO/desyiZe7KyQsAWpywI4F8FbqPUJgZjXuLE03C/Fjzqq8wI6vSt7I0= Received: from DUZPR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::7) by AM0PR08MB5490.eurprd08.prod.outlook.com (2603:10a6:208:184::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 10:02:32 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::ff) by DUZPR01CA0028.outlook.office365.com (2603:10a6:10:46b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Fri, 14 Apr 2023 10:02:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:32 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:30 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:29 +0000 Received: from localhost.localdomain (10.57.20.128) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Fri, 14 Apr 2023 10:02:29 +0000 From: Luca Vizzarro To: CC: Luca Vizzarro , Kevin Brodsky , Szabolcs Nagy , Theodore Ts'o , David Laight , Mark Rutland , Alexander Viro , "Christian Brauner" , Jeff Layton , Chuck Lever , , Trond Myklebust , Anna Schumaker , , Subject: [PATCH 2/5] fs: Pass argument to fcntl_setlease as int Date: Fri, 14 Apr 2023 11:02:09 +0100 Message-ID: <20230414100212.766118-3-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414100212.766118-1-Luca.Vizzarro@arm.com> References: <20230414100212.766118-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|AM0PR08MB5490:EE_|DBAEUR03FT038:EE_|DB9PR08MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c483a51-fa88-445c-a63b-08db3ccf6788 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xxSgjTArNLv33vnPZj18K62vC8Ft/UjGLeR2roN6/+8rNWqyQAt97pPz1vBKAPTi/McZir3IVfHzeAH06cEMcVxf/wzJDGlwa6vpmIE4AJZyNbGLFoGO1Ab1g15T9o3yfiXEqaIe+p/dao2q4ITGh0Dh3OJP0TxIr+1jaPJdVxvViWCxvcDjQSTMVqr4Dra1uyZV5TCf+GeWKq4CPPVrMflbzzefOg5BjS4iCIGaspaJky5KelM6NbnxQdmK0H/DmUlraDlsf6UdyNTCwXX6csQ8wIfN45NbEoBPYbBv3UIJ/FFhr51aUSzO/mwGtiDqAe6dh+LxpInYPESrv/nwgiwWhyj7fW802PGyrtU9w9r+3aFBY6GGNlnIZMjUKU8ffBP5/c6pMyIphWpmgtYLrVhJW9xTthgyHRmCdiVMb5zF6frjV6o0zf14szh4Ke3m2fRUytDgB1BECI9vSyRuzXPZ7RH81ZJLFapsDd8JxD+Jk1Tdshyb/7ZQANIZQXm5xaMBPTNcyQgde7hsSMn97cJ8Ms0P8B2zUfQEjOebWgWgmfsogAYDlgvfzGtfuKmamulohMgpa6SpJN/Op0YdyLxIkuMWQIfaROaAW1Y8zr1koxScDhApSkeJOOG+hAqSThg/pNJbfOaOo+1+xOmaNOD52V4uTsY/zo4br9QmeEY5dTa6QL8asDyqfG0xkKCN4d21vM0m0+1wAv2bObGeLQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(39860400002)(136003)(346002)(451199021)(46966006)(36840700001)(336012)(2616005)(426003)(47076005)(82310400005)(86362001)(2906002)(30864003)(83380400001)(356005)(81166007)(40480700001)(36860700001)(82740400003)(36756003)(6666004)(41300700001)(4326008)(70206006)(70586007)(8936002)(8676002)(6916009)(5660300002)(316002)(7416002)(478600001)(54906003)(26005)(1076003)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5490 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bb364269-c422-42bb-ba9d-08db3ccf5d38 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XHlzO5cdJsAuLi2XGoZpUgNdvamfg6GhHqCXMxO/Y8NaFIjFS/t8aq1dyjkznoiqSmIUxhECFzEmqLHJ2xUZ2GTvl7+T50v1ThSgISlzL70DNS2J31xqB3HcIulffPzBuvE3v+fYyPPsC881pvohRRqcAgQ97nkByC8HINQskN72lG+rS99acsHf1yOXi2/kuLQx1DRdzR9gtuepggEknD+I11zjOdQQKoLqtbYp8kFSXK35vxlq2X+PuJc5yvKYZ0LasSbh5Pd1MgKYBxFmzQGqQkIVmKOFfdK3yzDvwF73g+cy03veKaN/Ni1/fN15Pc+3zVjOsxOpN1tjoQLbzgvin3haNqJqRGO1ggEaTxTZoXg6eAggKjakxhH4iheemBj+Z5e9M4njUg3w4g7DoHsmHw9WM3lEGvjzhhgu2UMTBo7LZgaOCK7obU3wPU1EcC++LVWrQaBa7XnQ+ES3tL6w0XTPGk99SXsYHgUdqCLnrbRolI/+R3UkHYDdSButfaeCZbg05nwohxDl9gz5sMhKaBLbTnPvPBl2s5fs+aDAwcijJEyKtqZZb22QEl5FFFhmpqehaBSZuMTmtkNo7yw0znt71tHipUA8PuNahjDNmhTLBgwQrbyYMD0OYQIRGnKOLlOgP54SA5EnnntnagVwfhrznUJnWl+NpTQbL4QzDRHHXRxU4ll1+Y/+DBowDY1h5HVOYi3pfF0fwytjCw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(36840700001)(40470700004)(46966006)(478600001)(83380400001)(36756003)(47076005)(81166007)(40480700001)(336012)(426003)(2616005)(36860700001)(86362001)(82740400003)(2906002)(30864003)(316002)(5660300002)(26005)(186003)(54906003)(1076003)(6916009)(450100002)(6666004)(4326008)(40460700003)(8936002)(41300700001)(8676002)(82310400005)(70206006)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 10:02:49.5650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c483a51-fa88-445c-a63b-08db3ccf6788 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9636 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The interface for fcntl expects the argument passed for the command F_SETLEASE 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: Kevin Brodsky Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: linux-fsdevel@vger.kernel.org Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-cifs@vger.kernel.org Cc: linux-nfs@vger.kernel.org Signed-off-by: Luca Vizzarro --- fs/cifs/cifsfs.c | 2 +- fs/libfs.c | 2 +- fs/locks.c | 20 ++++++++++---------- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4file.c | 2 +- fs/nfs/nfs4proc.c | 4 ++-- include/linux/filelock.h | 12 ++++++------ include/linux/fs.h | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index ac9034fce409..ad5b2cfe8320 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1069,7 +1069,7 @@ static loff_t cifs_llseek(struct file *file, loff_t o= ffset, int whence) } static int -cifs_setlease(struct file *file, long arg, struct file_lock **lease, void = **priv) +cifs_setlease(struct file *file, int arg, struct file_lock **lease, void *= *priv) { /* * Note that this is called by vfs setlease with i_lock held to diff --git a/fs/libfs.c b/fs/libfs.c index 4eda519c3002..1c451e76560c 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1274,7 +1274,7 @@ EXPORT_SYMBOL(alloc_anon_inode); * All arguments are ignored and it just returns -EINVAL. */ int -simple_nosetlease(struct file *filp, long arg, struct file_lock **flp, +simple_nosetlease(struct file *filp, int arg, struct file_lock **flp, void **priv) { return -EINVAL; diff --git a/fs/locks.c b/fs/locks.c index df8b26a42524..265b5190db3e 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -438,7 +438,7 @@ static void flock_make_lock(struct file *filp, struct f= ile_lock *fl, int type) fl->fl_end =3D OFFSET_MAX; } -static int assign_type(struct file_lock *fl, long type) +static int assign_type(struct file_lock *fl, int type) { switch (type) { case F_RDLCK: @@ -549,7 +549,7 @@ static const struct lock_manager_operations lease_manag= er_ops =3D { /* * Initialize a lease, use the default lock manager operations */ -static int lease_init(struct file *filp, long type, struct file_lock *fl) +static int lease_init(struct file *filp, int type, struct file_lock *fl) { if (assign_type(fl, type) !=3D 0) return -EINVAL; @@ -567,7 +567,7 @@ static int lease_init(struct file *filp, long type, str= uct file_lock *fl) } /* Allocate a file_lock initialised to this type of lease */ -static struct file_lock *lease_alloc(struct file *filp, long type) +static struct file_lock *lease_alloc(struct file *filp, int type) { struct file_lock *fl =3D locks_alloc_lock(); int error =3D -ENOMEM; @@ -1666,7 +1666,7 @@ int fcntl_getlease(struct file *filp) * conflict with the lease we're trying to set. */ static int -check_conflicting_open(struct file *filp, const long arg, int flags) +check_conflicting_open(struct file *filp, const int arg, int flags) { struct inode *inode =3D file_inode(filp); int self_wcount =3D 0, self_rcount =3D 0; @@ -1701,7 +1701,7 @@ check_conflicting_open(struct file *filp, const long = arg, int flags) } static int -generic_add_lease(struct file *filp, long arg, struct file_lock **flp, voi= d **priv) +generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void= **priv) { struct file_lock *fl, *my_fl =3D NULL, *lease; struct inode *inode =3D file_inode(filp); @@ -1859,7 +1859,7 @@ static int generic_delete_lease(struct file *filp, vo= id *owner) * The (input) flp->fl_lmops->lm_break function is required * by break_lease(). */ -int generic_setlease(struct file *filp, long arg, struct file_lock **flp, +int generic_setlease(struct file *filp, int arg, struct file_lock **flp, void **priv) { struct inode *inode =3D file_inode(filp); @@ -1906,7 +1906,7 @@ lease_notifier_chain_init(void) } static inline void -setlease_notifier(long arg, struct file_lock *lease) +setlease_notifier(int arg, struct file_lock *lease) { if (arg !=3D F_UNLCK) srcu_notifier_call_chain(&lease_notifier_chain, arg, lease); @@ -1942,7 +1942,7 @@ EXPORT_SYMBOL_GPL(lease_unregister_notifier); * may be NULL if the lm_setup operation doesn't require it. */ int -vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void *= *priv) +vfs_setlease(struct file *filp, int arg, struct file_lock **lease, void **= priv) { if (lease) setlease_notifier(arg, *lease); @@ -1953,7 +1953,7 @@ vfs_setlease(struct file *filp, long arg, struct file= _lock **lease, void **priv) } EXPORT_SYMBOL_GPL(vfs_setlease); -static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) +static int do_fcntl_add_lease(unsigned int fd, struct file *filp, int arg) { struct file_lock *fl; struct fasync_struct *new; @@ -1988,7 +1988,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct= file *filp, long arg) * Note that you also need to call %F_SETSIG to * receive a signal when the lease is broken. */ -int fcntl_setlease(unsigned int fd, struct file *filp, long arg) +int fcntl_setlease(unsigned int fd, struct file *filp, int arg) { if (arg =3D=3D F_UNLCK) return vfs_setlease(filp, F_UNLCK, NULL, (void **)&filp); diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4c9f8bd866ab..47c5c1f86d66 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -328,7 +328,7 @@ extern int update_open_stateid(struct nfs4_state *state, const nfs4_stateid *open_stateid, const nfs4_stateid *deleg_stateid, fmode_t fmode); -extern int nfs4_proc_setlease(struct file *file, long arg, +extern int nfs4_proc_setlease(struct file *file, int arg, struct file_lock **lease, void **priv); extern int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 2563ed8580f3..26c2d3539d75 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -438,7 +438,7 @@ void nfs42_ssc_unregister_ops(void) } #endif /* CONFIG_NFS_V4_2 */ -static int nfs4_setlease(struct file *file, long arg, struct file_lock **l= ease, +static int nfs4_setlease(struct file *file, int arg, struct file_lock **le= ase, void **priv) { return nfs4_proc_setlease(file, arg, lease, priv); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5607b1e2b821..ba59ad558209 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7559,7 +7559,7 @@ static int nfs4_delete_lease(struct file *file, void = **priv) return generic_setlease(file, F_UNLCK, NULL, priv); } -static int nfs4_add_lease(struct file *file, long arg, struct file_lock **= lease, +static int nfs4_add_lease(struct file *file, int arg, struct file_lock **l= ease, void **priv) { struct inode *inode =3D file_inode(file); @@ -7577,7 +7577,7 @@ static int nfs4_add_lease(struct file *file, long arg= , struct file_lock **lease, return -EAGAIN; } -int nfs4_proc_setlease(struct file *file, long arg, struct file_lock **lea= se, +int nfs4_proc_setlease(struct file *file, int arg, struct file_lock **leas= e, void **priv) { switch (arg) { diff --git a/include/linux/filelock.h b/include/linux/filelock.h index efcdd1631d9b..95e868e09e29 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -144,7 +144,7 @@ int fcntl_setlk64(unsigned int, struct file *, unsigned= int, struct flock64 *); #endif -int fcntl_setlease(unsigned int fd, struct file *filp, long arg); +int fcntl_setlease(unsigned int fd, struct file *filp, int arg); int fcntl_getlease(struct file *filp); /* fs/locks.c */ @@ -167,8 +167,8 @@ bool vfs_inode_has_locks(struct inode *inode); int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl); int __break_lease(struct inode *inode, unsigned int flags, unsigned int ty= pe); void lease_get_mtime(struct inode *, struct timespec64 *time); -int generic_setlease(struct file *, long, struct file_lock **, void **priv= ); -int vfs_setlease(struct file *, long, struct file_lock **, void **); +int generic_setlease(struct file *, int, struct file_lock **, void **priv); +int vfs_setlease(struct file *, int, struct file_lock **, void **); int lease_modify(struct file_lock *, int, struct list_head *); struct notifier_block; @@ -213,7 +213,7 @@ static inline int fcntl_setlk64(unsigned int fd, struct= file *file, return -EACCES; } #endif -static inline int fcntl_setlease(unsigned int fd, struct file *filp, long = arg) +static inline int fcntl_setlease(unsigned int fd, struct file *filp, int a= rg) { return -EINVAL; } @@ -306,13 +306,13 @@ static inline void lease_get_mtime(struct inode *inod= e, return; } -static inline int generic_setlease(struct file *filp, long arg, +static inline int generic_setlease(struct file *filp, int arg, struct file_lock **flp, void **priv) { return -EINVAL; } -static inline int vfs_setlease(struct file *filp, long arg, +static inline int vfs_setlease(struct file *filp, int arg, struct file_lock **lease, void **priv) { return -EINVAL; diff --git a/include/linux/fs.h b/include/linux/fs.h index 8da79822dbba..0c9367980636 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1779,7 +1779,7 @@ struct file_operations { int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, lo= ff_t *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_i= nfo *, size_t, unsigned int); - int (*setlease)(struct file *, long, struct file_lock **, void **); + int (*setlease)(struct file *, int, struct file_lock **, void **); long (*fallocate)(struct file *file, int mode, loff_t offset, loff_t len); void (*show_fdinfo)(struct seq_file *m, struct file *f); @@ -2914,7 +2914,7 @@ extern int simple_write_begin(struct file *file, stru= ct address_space *mapping, extern const struct address_space_operations ram_aops; extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); -extern int simple_nosetlease(struct file *, long, struct file_lock **, voi= d **); +extern int simple_nosetlease(struct file *, int, struct file_lock **, void= **); extern const struct dentry_operations simple_dentry_operations; extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsig= ned int flags); -- 2.34.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you. From nobody Thu Dec 18 18:51:18 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60835C77B70 for ; Fri, 14 Apr 2023 10:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbjDNKCt (ORCPT ); Fri, 14 Apr 2023 06:02:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjDNKCr (ORCPT ); Fri, 14 Apr 2023 06:02:47 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2088.outbound.protection.outlook.com [40.107.22.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F917D83; Fri, 14 Apr 2023 03:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HBLXpsB10dl2ZXiqvVeiWURL8MXm9A0bLXW8Wc5CUQQ=; b=J5gYKnen2rMkmfP+/IcHyP+06M0gJJ/dL6KO7Xd+LfelbL+x9R05G1a0mZWxUKH9vR4bBVA1b0fdlgUyGqWEPg7RBe7ocXAiveCJ6YLAA6ZtG20uObdjdMvKwT3N/b33xiqMUTPyvRclGTsM65OQbjFbUBz3CYhV0KOKDivr/Bk= Received: from AM5PR0502CA0022.eurprd05.prod.outlook.com (2603:10a6:203:91::32) by AS8PR08MB9888.eurprd08.prod.outlook.com (2603:10a6:20b:5b0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 10:02:42 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:91:cafe::c4) by AM5PR0502CA0022.outlook.office365.com (2603:10a6:203:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 14 Apr 2023 10:02:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6fdd3755a942e6a4 X-CR-MTA-TID: 64aa7808 Received: from c81e36c9c379.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C24EAE52-F571-4AEC-9997-576D03AD1B5C.1; Fri, 14 Apr 2023 10:02:35 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c81e36c9c379.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 10:02:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8k2plxETt8KU7HFnzmvmotaoFnMbdNT+KP1e87xdz9+SrW/8p3JPSNc/WkCQ28DNOGwptZAHjV47bDVVWnWPDMCxbvsSU+9ayTPyeax8uanAjlqDh+xZbSH6Hq+Req21YqVFxNymgt21c7emxBN9ZocKp47MJXK1246U9Ycqkt876h76OKFJUpRXb6P4Egq9CAuZu/kG55AmHt7RiaPhyAnxk/cn9KynP76zBXJqqaCgpAo2/1AYmktr5MP5Y4SVMMAmVoZJN/9GXRI5Ju3OuUibQKxolT7/StrMH3DUIJKF32kDL3zsCRhOLRbR/emcxqPWEi63GXXKk2A7+5oFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HBLXpsB10dl2ZXiqvVeiWURL8MXm9A0bLXW8Wc5CUQQ=; b=bl2YRe46qkKKlr1kYK70TooTpkmkyNUfzTN6UzEnM7qQfsU71VydUavMYgNM64glZomvKYsm0hzHBLjy0Q2bzT20Wp80SVWpcCg5nZ0/ouZKGSMZTpYH2S1SUdemnJDtP9mgociqEW6EYtUPxHTk4ctZmsiLIlOXZiORPajxZsAGctVwZmgVxs7xi0XSVoQcL++/hqiCuEir+OTmMjOnxQfD4mWQsMZH7vgSzGs3B1sOE9cF1TXpmCyK/T+QPdKuYYmIqYoKgIdTKXhY+bwseGyHMi+PNeoFfg3xBjdbdZfEm9CV+sxOFN6nVKZONezA8nMvxDaH/yZXPEJTMT1aGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HBLXpsB10dl2ZXiqvVeiWURL8MXm9A0bLXW8Wc5CUQQ=; b=J5gYKnen2rMkmfP+/IcHyP+06M0gJJ/dL6KO7Xd+LfelbL+x9R05G1a0mZWxUKH9vR4bBVA1b0fdlgUyGqWEPg7RBe7ocXAiveCJ6YLAA6ZtG20uObdjdMvKwT3N/b33xiqMUTPyvRclGTsM65OQbjFbUBz3CYhV0KOKDivr/Bk= Received: from DUZPR01CA0019.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::10) by AM8PR08MB6514.eurprd08.prod.outlook.com (2603:10a6:20b:36b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 10:02:32 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::b0) by DUZPR01CA0019.outlook.office365.com (2603:10a6:10:46b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Fri, 14 Apr 2023 10:02:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:32 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:30 +0000 Received: from localhost.localdomain (10.57.20.128) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Fri, 14 Apr 2023 10:02:29 +0000 From: Luca Vizzarro To: CC: Luca Vizzarro , Kevin Brodsky , Szabolcs Nagy , Theodore Ts'o , David Laight , Mark Rutland , Alexander Viro , "Christian Brauner" , Jeff Layton , Chuck Lever , Subject: [PATCH 3/5] pipe: Pass argument of pipe_fcntl as int Date: Fri, 14 Apr 2023 11:02:10 +0100 Message-ID: <20230414100212.766118-4-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414100212.766118-1-Luca.Vizzarro@arm.com> References: <20230414100212.766118-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|AM8PR08MB6514:EE_|AM7EUR03FT004:EE_|AS8PR08MB9888:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ae546bf-49d4-44ed-1d15-08db3ccf6375 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: UOI6iqQ+9FzNLRoXVjf907fdQrs5j2Hmpeg8pMF6RF2PEEOEscIpgASFc9avupIJOy04pKObBSr0CqePrE29XCpghpYdGna/VCjL4yL6adghqPjxsJbsO43NSan5zObb0YMMGGa69I3soNa3UmFWTMKky89LK93RrUqT3O9WV3+7y0p0ln6xc8mOkrlCb/UdeTC0RqDJVhZmcOmG/sqR3sL57FXBW3aVlJxcxG2yL7prPQ61vnyRrQ5KPQ1QsgbO0nqxp//BMP+iK5uWg2q+hAilbr1mAc76XI8ilm/EFZgxDCqu9EMMCi/Rcg3T6mUwnzOEEx+mL+wa0TkFqzl2QNhAWYrV6m9Izzh0PkBLDDJKLtho78+RNhuC214vE0Zc0Bn/6TNQ2jUCfXvq1mnKlNaZT2xaLpbMI1agNN9vm0DZ6K+n7aaqkLkT/ujJB3sjTHQ8tfQsCRdzFjn+ap+EaDoemVb82jfqsWRkCeEfwARG/VwzhLGLteCMReDtZ1HBIqVj7yH4h/aHHuUMSveZrVJ2bM9LfReowZveBoSq3aAil2t41Mg1kVxX6Uv/OICZURHXjAFikDlTuH7Z3hz7SR1ddzo4hw8sDa2vMN386YJsMma/izj8PtnXkn/NF/RbRGiCUE+dh6IAe7DJGWW3v4COVgaRRD0GxocnRf///v9Q5oqoAvtgzGp0koSzKSTnhH/b1/IM8AEORJpi8I6haw== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199021)(36840700001)(46966006)(54906003)(2616005)(478600001)(36860700001)(83380400001)(1076003)(40480700001)(26005)(6666004)(70586007)(6916009)(70206006)(316002)(4326008)(82740400003)(47076005)(426003)(336012)(186003)(5660300002)(8676002)(8936002)(81166007)(356005)(2906002)(41300700001)(86362001)(36756003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6514 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0b9d546f-0399-4283-16d6-08db3ccf5d98 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I9KV5Rw1oRbQV+WnmAwxPV6U5QTdEiTjdl7fJyr/6epIjLSkSH4MdFn3pqhOuwNOreFmUN87tOG5HCkJvLU9vtVnXg9+rDEzX04XR3u2KP8ZChq1WZlRF1XAUYv8ee+HIgWd3yJFyqF4sQIX57X0qJLuPgvUZ/WcrJ3oxGAJkNrK48V+T351yTkwrFbh3gmy0KQx1P/4++ncuO7OqZWI4QnneiZhvcarZiFxlEGos0f+n0ieixr5GrjhAiEtSl3df+dF0KdD3TryLJqvDylyefaQ1+glZpLBd46+jwAU6qg2ozI5rJW2uB8tY+0Humhfp1YY8ouVMlsghm3ngxSMufg9hcph1h8E537UU5k1Vb3+LV+X1Sj8+ziwxLL/U3mC8AMvQInthsQH+NLvu7AMTS3/fpxvOFMiHksFFOUEqiRtwkL8jmHhxH35037o9oIJnrAB+FBqrcjdChOufkAvExxXEptkQQhsLW66Ar7IV3QoLPIlHvifMGXAIu94R5XXw5O6VgqeD54re02XvnNGmwGDFBuPb62cZVdp4GmY6zVQqRL5P/1EDERIli1fRLALAbaiJwQhIxNXZp2VZrK8lbkYZ4d2XcerTWr+y5X0SdQFp4SGLmhl6K/tAbO0CXO6k5wMdj6i7v0wBks/3adWUcnxLL8P2NmBRaIQKz824aLF5e56wsgOq8iMXuYcPRrvtn7fK5PthxY2K7R9VlYQdg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(36860700001)(336012)(70586007)(5660300002)(36756003)(2906002)(316002)(8676002)(40480700001)(86362001)(8936002)(41300700001)(81166007)(82310400005)(40460700003)(6916009)(82740400003)(4326008)(450100002)(426003)(70206006)(83380400001)(2616005)(47076005)(54906003)(186003)(1076003)(26005)(478600001)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 10:02:42.6636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ae546bf-49d4-44ed-1d15-08db3ccf6375 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9888 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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: Kevin Brodsky Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: linux-fsdevel@vger.kernel.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 =3D { * 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, un= signed 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 *fi= le, 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 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you. From nobody Thu Dec 18 18:51:18 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD2EC77B6F for ; Fri, 14 Apr 2023 10:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbjDNKEK (ORCPT ); Fri, 14 Apr 2023 06:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbjDNKD5 (ORCPT ); Fri, 14 Apr 2023 06:03:57 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2048.outbound.protection.outlook.com [40.107.241.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4765A9018; Fri, 14 Apr 2023 03:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nr804s7bVZfIa+qC30gqcZLNaKUWavbsiBabftnI6F0=; b=qixR3QS7CAPO1Mvxbh5ot4cVL1+XDPOehs08RJXb+GsSQQ3Z5jc4icKfW/WjqG8CAA+j0zjPdcPWl6DyT07gSCRPgv7ZgJwuPZN4tTr1JhexY/qmoHmYvA/NlnZA1DRLuCYg9bNOjsatzFDHCk8hm+vpf5pTyIYcsXH1GQy5bg0= Received: from DB9PR02CA0001.eurprd02.prod.outlook.com (2603:10a6:10:1d9::6) by DU0PR08MB9273.eurprd08.prod.outlook.com (2603:10a6:10:419::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34; Fri, 14 Apr 2023 10:02:42 +0000 Received: from DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::b1) by DB9PR02CA0001.outlook.office365.com (2603:10a6:10:1d9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT048.mail.protection.outlook.com (100.127.142.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 10:02:42 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Fri, 14 Apr 2023 10:02:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 79bbcc36450c85c4 X-CR-MTA-TID: 64aa7808 Received: from 9c797f34d37d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0FB32275-3A48-4924-9B24-719EE9CDBF69.1; Fri, 14 Apr 2023 10:02:35 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9c797f34d37d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 10:02:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IxprS/EQO5snmOcL5+GUqkc6wZlxd43WXCo+x4Im0Y0L31Oi3t9dUkFkMggZukRAFVFX9VDo8YXGw05zXhXpPJRlWVqAwJ/zXWdkURH0biNyr67DRFVbwl49fROpl9rqB6H7ZC+SyVJ437iJeIds6Uk4M5QDsm5YGQa9DXRf0rLqRopgxgTtm7CQuixhOBHAb6bxePlI0KS8ZnDAzRN7KGqhC6idkkFZd7xnVbyIpX7kkY8r6j05fG0vcmYgA+p6DiK8WWUJfNNIqQt3xbL0m5p0rJs1LbtoyZKDUjaKSdtyXiZoWiIl6Z3rdD57i31YwUOehJWA4RPEwb4Z3i8q4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Nr804s7bVZfIa+qC30gqcZLNaKUWavbsiBabftnI6F0=; b=aNntHFAppziSqZsdYpL/VKIFrru9TAYyQ2yhggMHL00Cf/Dx/xNO+FhHJ+in9Vi3HIcLC0VKlVekr4kSjQPEOWRX7jeK5hbN3ne2GrEpEheAtgjk+pivzhJIhlVK2xV5y0T1+eCNP/7mEDyHDL7LVfGapwuL7RMVCSRVL2umtFDUEIdO9JfGUigJBxxDqFWxqwEmX5MiI855uMiLyXaYpIkqQ9xMvbppWPBY1IJnMagT1vZATqO/q4QLWpzCMk2ajJnRhsYGwFiI9wrcPz3mTSbkrIB07wxZ7fSrBeCyT8kdk6N1gBy8BK1n4YX585D3qipH9STqpdGZhOjc23otaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nr804s7bVZfIa+qC30gqcZLNaKUWavbsiBabftnI6F0=; b=qixR3QS7CAPO1Mvxbh5ot4cVL1+XDPOehs08RJXb+GsSQQ3Z5jc4icKfW/WjqG8CAA+j0zjPdcPWl6DyT07gSCRPgv7ZgJwuPZN4tTr1JhexY/qmoHmYvA/NlnZA1DRLuCYg9bNOjsatzFDHCk8hm+vpf5pTyIYcsXH1GQy5bg0= Received: from DUZPR01CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::12) by GV2PR08MB8584.eurprd08.prod.outlook.com (2603:10a6:150:b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 10:02:33 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::e3) by DUZPR01CA0022.outlook.office365.com (2603:10a6:10:46b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Fri, 14 Apr 2023 10:02:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:33 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:30 +0000 Received: from localhost.localdomain (10.57.20.128) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Fri, 14 Apr 2023 10:02:30 +0000 From: Luca Vizzarro To: CC: Luca Vizzarro , Kevin Brodsky , Szabolcs Nagy , Theodore Ts'o , David Laight , Mark Rutland , Alexander Viro , "Christian Brauner" , Jeff Layton , Chuck Lever , , Andrew Morton , Subject: [PATCH 4/5] memfd: Pass argument of memfd_fcntl as int Date: Fri, 14 Apr 2023 11:02:11 +0100 Message-ID: <20230414100212.766118-5-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414100212.766118-1-Luca.Vizzarro@arm.com> References: <20230414100212.766118-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|GV2PR08MB8584:EE_|DBAEUR03FT048:EE_|DU0PR08MB9273:EE_ X-MS-Office365-Filtering-Correlation-Id: 70c7ee73-c262-45bd-a43b-08db3ccf6349 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: NfstKygHOFO6Qbt7ULPkPAhyzyB8ozKjpamoecJqixtbwzcCaTAyHXp6wAdo69MQtFRMMuOMwjQnUgUd7xa4cjudQAJVHvRVQcWfuSca/R1y9VNgVx/GTSyoc9Cf3H9xbshxbcEN4OINcN4i7k4KldVxIwyiVhU4WjGza505OnHvSQ1W85Y8qSRbkgCuPDzL+m7Dpqh7byDbpb3z9S5bhyKcNVjwdLSe7t6rhETdHHLafLyyPKJKLvs34NytmL3hkEsMMTP4U7cW8ndArKIXyqIbfIRM78JPxC0j7zMwmhM4E0RBM+iAVUwUsYby7tVfDEGJnK7u6f7P7J/K5Mx9IaQnfw2qQe8hmShXjX+dYt3H044bi4JxF7GIGm4ktQCvOvm8eD4eTORbDYWs2rvFJ2eAcW4r3agQJsaqjR/rw7Z+fHxkbiLkK9QIk6OOQGjLoGa72GOf6IXeT2P39GB+BLXt59p+gqXCku0bXHNgxGDGuSta6XqgGR7AYbgFLHnN6SxHm6EkR4OGIRVgwVp/1pcJGPnB3oiTZOsJZrCoe0AIabkuqrXrDVdLxYuLXse6ye6KSaqVmTs/KgftPb6US9o4uPBiSq3HcNXJz3Tboh9k3puR3fGZ4REn60LWvEyRNQ0I9R3KowXbRknG8LbQXJbu3OcnL4uT/8/imKHoFbUZjho/nSL4IEMZNA2QdQYNxYydsnwkGQpBuVbks5cSqQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(376002)(136003)(39860400002)(451199021)(36840700001)(46966006)(2906002)(7416002)(70586007)(8676002)(70206006)(8936002)(5660300002)(478600001)(41300700001)(316002)(40480700001)(82740400003)(83380400001)(426003)(336012)(36756003)(54906003)(4326008)(6916009)(186003)(86362001)(6666004)(26005)(81166007)(1076003)(2616005)(82310400005)(36860700001)(356005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8584 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a77acf33-23a4-4461-d76d-08db3ccf5dda X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PDUBdm5welz0M0Cv0zmjhMn2jtR7CzyN+KFYGB+I+L2Tcu3xbReycNC159LQ9mMbIbwRgDzf6hQUF9a6Wv6Zp1KxrzjbvT9eblVXmguSHD8++XzocT8SfGzKjGyoicBxCGvaLzkfL+UgbE1/qMuKB36FvP9+5ejCoOG2tg4x/6YwHguKa0pd3Gbwnc/yM3WP0iU0cUtSVTZE7tBfyKBDRQruZzCz2lHqCrrXsH+3YL0Q4WfUL3S2iczzACLcTfW1IWxpy4EClOK/8zduRRi/GyZMq7KCPjqNtPxzLsD9Yt5GNAyj6IIQ/8Dyksym4l7lnM27QAHGzR9Xv2C5Z+8X9JhsUUkhSLNZHd+s7xlHvGquoYR4cftSrU6cmWLdaO0z3fkh/oviNH2x0vNpwcd6G4h0TRty5IOboDSX4IP2lJdiGzmaJVGy+IxLEROrVUdSHUdCpZ0PYyBGyE5bj5f5n1k5o0h4liUAQPixLchlJsyYarqCPE5LhfehbzcifkFRZy0iBPU36RHyv/c6rPR2ZY7Yb5fpEOvApUIl6tePmYk0/E7UGdROQRQY8g5itpknII1n5N1LvQep86DnJ26v2R4CoL3dnMWHxkbEPw2Q+ugU1NQBSo8DxiC9UMym8JKT7jPrXpOPmzzsp2kAmRWmKU1igX9T/tO+Jj7lm6aLxxpMpVff8dWeGofubBEtt/B0GTRjuYobaOE6aQLmfLuqAg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199021)(40470700004)(46966006)(36840700001)(478600001)(6666004)(1076003)(36756003)(83380400001)(47076005)(81166007)(86362001)(82740400003)(40480700001)(36860700001)(2616005)(2906002)(336012)(450100002)(5660300002)(316002)(26005)(186003)(54906003)(4326008)(107886003)(8676002)(40460700003)(8936002)(41300700001)(6916009)(82310400005)(70586007)(70206006)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 10:02:42.3630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70c7ee73-c262-45bd-a43b-08db3ccf6349 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9273 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The interface for fcntl expects the argument passed for the command F_ADD_SEALS 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. This commit changes the signature of all the related and helper functions so that they treat the argument as int instead of long. Cc: Kevin Brodsky Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: linux-fsdevel@vger.kernel.org Cc: Andrew Morton Cc: linux-mm@kvack.org Signed-off-by: Luca Vizzarro --- include/linux/memfd.h | 4 ++-- mm/memfd.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/include/linux/memfd.h b/include/linux/memfd.h index 4f1600413f91..e7abf6fa4c52 100644 --- a/include/linux/memfd.h +++ b/include/linux/memfd.h @@ -5,9 +5,9 @@ #include #ifdef CONFIG_MEMFD_CREATE -extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long= arg); +extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int = arg); #else -static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned lo= ng a) +static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned in= t a) { return -EINVAL; } diff --git a/mm/memfd.c b/mm/memfd.c index a0a7a37e8177..69b90c31d38c 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -243,16 +243,12 @@ static int memfd_get_seals(struct file *file) return seals ? *seals : -EINVAL; } -long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg) +long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg) { long error; switch (cmd) { case F_ADD_SEALS: - /* disallow upper 32bit */ - if (arg > UINT_MAX) - return -EINVAL; - error =3D memfd_add_seals(file, arg); break; case F_GET_SEALS: -- 2.34.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you. From nobody Thu Dec 18 18:51:18 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBF7CC77B76 for ; Fri, 14 Apr 2023 10:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjDNKC5 (ORCPT ); Fri, 14 Apr 2023 06:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjDNKCs (ORCPT ); Fri, 14 Apr 2023 06:02:48 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2079.outbound.protection.outlook.com [40.107.13.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465C77DB6; Fri, 14 Apr 2023 03:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uXThXgzbpE2PttY3ewrOzQKxE1UlmTlLnI5hp/7CtmM=; b=IARNfGAuYAWUVvJ3ZiVh3mZcMRPHs+yzw+D5Hqaf9THoMKbTbWQOiH+WK/8m3JZ8sE+XExIaA4NXj94cwF2MPYJDlFWvVbygYw95q+uygFk3rc81Bb5eZ1OyQxFaN8GcsyNwBDwfAhRVURKMei/hP60pODCnWvI8SemsuqkXmI4= Received: from DU2PR04CA0168.eurprd04.prod.outlook.com (2603:10a6:10:2b0::23) by AS8PR08MB9979.eurprd08.prod.outlook.com (2603:10a6:20b:633::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Fri, 14 Apr 2023 10:02:43 +0000 Received: from DBAEUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b0:cafe::c6) by DU2PR04CA0168.outlook.office365.com (2603:10a6:10:2b0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 10:02:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT064.mail.protection.outlook.com (100.127.143.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.10 via Frontend Transport; Fri, 14 Apr 2023 10:02:43 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Fri, 14 Apr 2023 10:02:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 39e72d5079958af0 X-CR-MTA-TID: 64aa7808 Received: from ba243dce12c3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 49866A54-A50C-4952-97A7-F18F90F8217E.1; Fri, 14 Apr 2023 10:02:36 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ba243dce12c3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 10:02:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnR98YkOWYhPXZzTsj7jjPFapiXqqcwub3xqqL7AAs2t2VxYMVT2bHQZiXJkHJYlUzzrqbV6Ym2ifTJEo2FaN/Hu33NoYfpnlOMQlFFb63X5Z54Uay/lleJMdQwY60KSf2MRNr8PZpY3Oi8CXqCC4kbMloNQX0KNillRPX4uvFyf3L4hn68QLHUN8srrfXIYT4MeX4ez9CqCgNoiheBB5INvseVW/M4V0f4MX0jGmOPsLTeAVCYeFTxnVXRKhUT/ph7Msq59VOyRS0MllJQoEh/jStiWJ0qugs27k8gWV40YN9rvvrCT4meucbrCdKo6URmPyQoPV0RiA1MVXPFr4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uXThXgzbpE2PttY3ewrOzQKxE1UlmTlLnI5hp/7CtmM=; b=DbNjEzBE515VnUbUdr4xiJVBK00ccnZzbM3IQhhA9bueKkt//zuc3ZIZGP9dSXuMWZSbzD0Gwb9TUfnsRtS5gB5oodx/lGRYUPWlXmexGYZNJpelQVmKHM4QHtTRBeD0tZe6Q0DFxZsTjVZS4YPg7IAFPQbib/IF3kp1RfX7z/d1S8SgkoiRGgX2Kk+w63hc8OYohiAt+zOtTFF29MIwbKb2sM0ogQjyMLGhMUDXsVAvgek29Z1oESGcQgJgPe877k71zlXBUg//uhHLUhxpboVAZUVNs7+AKMF221yMeP3Uj6rquDsctOOD6H0ZQwVJtghlh+7XQPkPpvzyTIZ4Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uXThXgzbpE2PttY3ewrOzQKxE1UlmTlLnI5hp/7CtmM=; b=IARNfGAuYAWUVvJ3ZiVh3mZcMRPHs+yzw+D5Hqaf9THoMKbTbWQOiH+WK/8m3JZ8sE+XExIaA4NXj94cwF2MPYJDlFWvVbygYw95q+uygFk3rc81Bb5eZ1OyQxFaN8GcsyNwBDwfAhRVURKMei/hP60pODCnWvI8SemsuqkXmI4= Received: from DUZPR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::7) by GV1PR08MB8353.eurprd08.prod.outlook.com (2603:10a6:150:a3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 10:02:34 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::8e) by DUZPR01CA0028.outlook.office365.com (2603:10a6:10:46b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Fri, 14 Apr 2023 10:02:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.30 via Frontend Transport; Fri, 14 Apr 2023 10:02:33 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 14 Apr 2023 10:02:31 +0000 Received: from localhost.localdomain (10.57.20.128) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Fri, 14 Apr 2023 10:02:30 +0000 From: Luca Vizzarro To: CC: Luca Vizzarro , Kevin Brodsky , Szabolcs Nagy , Theodore Ts'o , David Laight , Mark Rutland , Alexander Viro , "Christian Brauner" , Jeff Layton , Chuck Lever , , Jan Kara , Amir Goldstein Subject: [PATCH 5/5] dnotify: Pass argument of fcntl_dirnotify as int Date: Fri, 14 Apr 2023 11:02:12 +0100 Message-ID: <20230414100212.766118-6-Luca.Vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414100212.766118-1-Luca.Vizzarro@arm.com> References: <20230414100212.766118-1-Luca.Vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|GV1PR08MB8353:EE_|DBAEUR03FT064:EE_|AS8PR08MB9979:EE_ X-MS-Office365-Filtering-Correlation-Id: ecbc9dfe-47e2-4dfd-4401-08db3ccf63d5 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: M9WQw0GoJIf/7je9lWbREJsGpT3zbjbrlAdBuHJfEEFk0K97OnXwmiQi3Lbb2jBi9qGXRKglhqNg1uSwSBgUjiGwzYm1a7yl1wM3oCagNg49Yb40X4upSHUJ3HZHxvJcln0lrPhq9EuVBBzdOhqv8nVBNGa3qFGSGKudAoMdqjWKCtP0oIejNACN7B9LDvUsEGFMr7BWfa3fN5b1S3pcyTb5SajmosepdYnuqWqj4q2WNDP6uybkicRZyfm8oqAHxRnYvXB9+qOTgZStvLn+BE9DBfjnsH14LXwCOrNvxmPe/bYRbWomtc6/99WYGso+beGMmpWLKL+PD8BzxlSiDqhp0meKzVQ13sApW5AgZ1O6Gin+x4q9UEan0Ik7WDWBEIu+C6SkFslw15X+z76QJI/kvuU1rLQXeKo+DTU9UMKhq3CKj8okxjeBDhIoMbOv8jyfaxhQMAAYU3BEMh95+1Snf9wn9AFZPP+E4obXIypXudzUj7imrYfy+FTFT3eguqhKDrLI6xues6XEHq4S4p7X9yV9XMgbVrCSVP3gtqXazmE8qR9eyKxNzgj6pFXFHpVuzGU07n8z8q7W8kA3gRvlK3t0IlPxqozjWG43syQxqnNK2ECLOQcNvT8TDnd40LC0TsBgC2bTvN4q1iODwQBX5RlPdtT/nyiKeailT+3XsexfzvBfbS9ejO1d25C0bMwxMLehA6oSpHOdcITQ/Q== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199021)(36840700001)(46966006)(478600001)(86362001)(54906003)(36860700001)(36756003)(47076005)(2616005)(336012)(83380400001)(26005)(40480700001)(1076003)(82740400003)(6666004)(186003)(82310400005)(81166007)(316002)(6916009)(356005)(4326008)(2906002)(70206006)(70586007)(426003)(8936002)(8676002)(7416002)(5660300002)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8353 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 41483d6d-1376-48ad-4826-08db3ccf5e2e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HIpaDfYjtD51eEk8FYXjZ9m9cT4NmczaCZ5TNos/WdCWROrptKin0souGJs9dckIJSvCeqWjTRXjQbY7qvx3kct1Be15AYVI9wBmpHJcQjLKiX5Lahv5nB1I3LN2mr6lPvRaZWczzxYoYu4Sk5snO3APrqvnPREN59HSsB1SgnAwhl4HInqDVecDQ/StIhJDL6vC5k66XTOhjBlvLaaZ3Suuy796QVhgLFntJ3y8TOQVjznI43GC2enMMomdWDyysJsYQMyaoJPpclBY5fj3zatkEsW5JyudMTByEYJfnpmj1dLg440QocqA3mZhm6eJ0rq78PUa3yfB4cDgrYi8JAMh2SldYjhJOjPGyaeFNDAExgOv7WJYWok0Ll11KJOOcsxsoovXwOvdwaH2GBKiLowMIo39EoFyyHFFPUDy1ckz2+mlHQ60FTcM52mUlHuwcItsiWz5eMUlpHe4aF7aV7k091jRd8wrYMYk/1iEFXzwrdRGhi1CWe36wdQLOcucXoshGLLCRHvQmYU+D/Kyt5XCOPlTwtaOHhTUvOUen2jQbYPYTGDj0FZVHxlNMKGLWLClBqT72Avt9+Dc57lHXwrDaw+ZZstBHS9MYNFWmA3KSwbRhkaIJZSrxezbVRVNctKyt7MWrEHMcd/TLGoiixihQTzdNwQ3AVfAjv+U42E42rJwACap1P67lPbhVugcmObLnSKcB/72zpAqfid/dQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(336012)(426003)(5660300002)(86362001)(8936002)(2616005)(70586007)(6916009)(83380400001)(450100002)(8676002)(40480700001)(2906002)(4326008)(70206006)(47076005)(107886003)(81166007)(82740400003)(36756003)(36860700001)(26005)(186003)(82310400005)(1076003)(40460700003)(54906003)(316002)(6666004)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 10:02:43.3718 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecbc9dfe-47e2-4dfd-4401-08db3ccf63d5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9979 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The interface for fcntl expects the argument passed for the command F_DIRNOTIFY 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: Kevin Brodsky Cc: Szabolcs Nagy Cc: "Theodore Ts'o" Cc: David Laight Cc: Mark Rutland Cc: Alexander Viro Cc: Christian Brauner Cc: Jeff Layton Cc: Chuck Lever Cc: linux-fsdevel@vger.kernel.org Cc: Jan Kara Cc: Amir Goldstein Signed-off-by: Luca Vizzarro Acked-by: Jan Kara --- fs/notify/dnotify/dnotify.c | 4 ++-- include/linux/dnotify.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 190aa717fa32..ebdcc25df0f7 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c @@ -199,7 +199,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id) } /* this conversion is done only at watch creation */ -static __u32 convert_arg(unsigned long arg) +static __u32 convert_arg(unsigned int arg) { __u32 new_mask =3D FS_EVENT_ON_CHILD; @@ -258,7 +258,7 @@ static int attach_dn(struct dnotify_struct *dn, struct = dnotify_mark *dn_mark, * up here. Allocate both a mark for fsnotify to add and a dnotify_struct= to be * attached to the fsnotify_mark. */ -int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) +int fcntl_dirnotify(int fd, struct file *filp, unsigned int arg) { struct dnotify_mark *new_dn_mark, *dn_mark; struct fsnotify_mark *new_fsn_mark, *fsn_mark; diff --git a/include/linux/dnotify.h b/include/linux/dnotify.h index b1d26f9f1c9f..9f183a679277 100644 --- a/include/linux/dnotify.h +++ b/include/linux/dnotify.h @@ -30,7 +30,7 @@ struct dnotify_struct { FS_MOVED_FROM | FS_MOVED_TO) extern void dnotify_flush(struct file *, fl_owner_t); -extern int fcntl_dirnotify(int, struct file *, unsigned long); +extern int fcntl_dirnotify(int, struct file *, unsigned int); #else @@ -38,7 +38,7 @@ static inline void dnotify_flush(struct file *filp, fl_ow= ner_t id) { } -static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned long= arg) +static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned int = arg) { return -EINVAL; } -- 2.34.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.