Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp690779rwe; Fri, 14 Apr 2023 08:29:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bX93t5xjEgised4jgjNe7DVyCuwIdkgdNGIOHiRm104vvL0s7F5pg0QzejtPp8Lt/tWWnt X-Received: by 2002:a17:90a:654a:b0:234:d78:9b4c with SMTP id f10-20020a17090a654a00b002340d789b4cmr6184856pjs.18.1681486150286; Fri, 14 Apr 2023 08:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681486150; cv=none; d=google.com; s=arc-20160816; b=l68nenetExLsps8dr2zbDSeiPdELUPBi8kM3lLLARBQVgnYgkPJ0COndVocDTmAvcl QVVgfo3kRoqlfYPd/3ug3NvvJJGq+8J2cnSKam+ZoUmGKpEnpdVkBJPxWSg79ut34LlW NVKD1XRJcSHp3zks1rlj5JmNHPKFHOWLbzYwuYnJjlRJs72bVSHJc0fSQKZb8zK3TxPz bq8KYhP8DLpPDnOyseC1Piml/5UahaybYw1WkK1vxIRQHoA2ZQFP+UAn9VYFkNMKra8d MUVVI6joqQMLfxVqVHrLjdkhXUOhkA9n0HD0vdzUx6PanuRRUkxIfNvK5hbTRoDb9tVs 0Y2Q== 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=t/Z7YK3Rnq5GwRw0PQZA10DU5AoINJvyB5YqtZYTzaA=; b=dAqGJb0xmUFpFNubNuWG+WixadcYjOaXwhQgu+P4OP9Fwahie9bEThjox90OyUXvCL DJ5ZD5eX02TujOCtE/74R1dwLiIHaAeYmYRrLIOhTMEHPClEJstZl/1n6KhIdjx08YDj LdQvx/P5TcJi4lrcEu7CqqQt2eKN1gJ29U4RDYxZKIyGvbt9hz0CwAJL03viSCs+S4i2 1qcjdxRtvKPxS4SagOUD/bMCe9kMC2rrfkC9n97WS2vvrvM3UDl6uFWZhnRdjmWp5Ofr NDs6cgQSmait60yZXC+aevdAD8FhxC+vGbMEpVk12FwHJhtK+QtzuV+uWClm1CtoPZOq s3eA== 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 h6-20020a170902704600b0019e6763b110si4562283plt.232.2023.04.14.08.28.55; Fri, 14 Apr 2023 08:29:10 -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 S231261AbjDNP1S (ORCPT + 99 others); Fri, 14 Apr 2023 11:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjDNP1D (ORCPT ); Fri, 14 Apr 2023 11:27:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F0073CC39; Fri, 14 Apr 2023 08:26:32 -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 B11A41758; Fri, 14 Apr 2023 08:26:07 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2F1813F6C4; Fri, 14 Apr 2023 08:25:21 -0700 (PDT) From: Luca Vizzarro To: linux-kernel@vger.kernel.org Cc: Luca Vizzarro , Jan Kara , Amir Goldstein , 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 5/5] dnotify: Pass argument of fcntl_dirnotify as int Date: Fri, 14 Apr 2023 16:24:59 +0100 Message-Id: <20230414152459.816046-6-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_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: Jan Kara Cc: Amir Goldstein 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 Acked-by: Jan Kara Signed-off-by: Luca Vizzarro --- 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 = 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_owner_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