From patchwork Thu Nov 21 11:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13881871 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FE40D6ED0B for ; Thu, 21 Nov 2024 11:22:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A45616B0082; Thu, 21 Nov 2024 06:22:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71DEC6B0098; Thu, 21 Nov 2024 06:22:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 274BE6B0095; Thu, 21 Nov 2024 06:22:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7AD696B0082 for ; Thu, 21 Nov 2024 06:22:28 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 366A3A0DC8 for ; Thu, 21 Nov 2024 11:22:28 +0000 (UTC) X-FDA: 82809863430.28.2FE4EC9 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf07.hostedemail.com (Postfix) with ESMTP id 211664000C for ; Thu, 21 Nov 2024 11:21:12 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=iREK+iQI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7xNbZGvk; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=iREK+iQI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7xNbZGvk; dmarc=none; spf=pass (imf07.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732188010; a=rsa-sha256; cv=none; b=0nVWH3Rto39u8vfTpJnGxknVmmKgZMGeKjQJcl/S7reCfdDolhu5fvoM3t9N8YRR9eLtLv 17eIpUI24rU3CRpGBV6ZM34UoSflLplaBtiVVC/1FqRzQapWPOB2CDXy8ntuHHsgAVrN0v GM1B2/4SvQN1yt+5YR8zmbGlO1/L3Bs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=iREK+iQI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7xNbZGvk; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=iREK+iQI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7xNbZGvk; dmarc=none; spf=pass (imf07.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732188010; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PbasX8L1DF1kko1XHmpW+FloLNMQ60rGoymVwWu7q3c=; b=R9Cz1d5zZctXORtS6AAAXzpVswuGK0SYUQ9/6A1aQuGawWDbxcFTeTClPFXUGVq5lTVg0D oDjKSi/LcxBv+ZN7zQaTLY5L6/glA3aqyzZocDMuknN+s4dg1JJhMSqQpGRYmPhK5ZwXLy FmgtOIrkaHicgvVv+gizvuKVUm/nHXo= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 43A9A1F7FB; Thu, 21 Nov 2024 11:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbasX8L1DF1kko1XHmpW+FloLNMQ60rGoymVwWu7q3c=; b=iREK+iQIa8VD+IQAsNxaRPH3c+UVPiDRhwYIRkzNdD2gw4dwbeTFdqoUWpAx5D9Qzv9qK6 AGuvIcOe9V9O1GvuQ6houVQT5MsweuLUelPNWgXE8lR86wLCDz4VDLywmdmYXZOiuTgMGi Y1zNquW+yUcyqWRE1il32MYpCxz0tBg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbasX8L1DF1kko1XHmpW+FloLNMQ60rGoymVwWu7q3c=; b=7xNbZGvkIPNsP3Vx/KcTfy6KsIT/whYBpjoJYT1/qSPfrI8OuZWY9bqiMKwJioFG7xuebG +YizzvLMF5Y6NxCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbasX8L1DF1kko1XHmpW+FloLNMQ60rGoymVwWu7q3c=; b=iREK+iQIa8VD+IQAsNxaRPH3c+UVPiDRhwYIRkzNdD2gw4dwbeTFdqoUWpAx5D9Qzv9qK6 AGuvIcOe9V9O1GvuQ6houVQT5MsweuLUelPNWgXE8lR86wLCDz4VDLywmdmYXZOiuTgMGi Y1zNquW+yUcyqWRE1il32MYpCxz0tBg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732188144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbasX8L1DF1kko1XHmpW+FloLNMQ60rGoymVwWu7q3c=; b=7xNbZGvkIPNsP3Vx/KcTfy6KsIT/whYBpjoJYT1/qSPfrI8OuZWY9bqiMKwJioFG7xuebG +YizzvLMF5Y6NxCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2ABC613AC3; Thu, 21 Nov 2024 11:22:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id HYEHCvAXP2ccfwAAD6G6ig (envelope-from ); Thu, 21 Nov 2024 11:22:24 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id DC217A08FA; Thu, 21 Nov 2024 12:22:23 +0100 (CET) From: Jan Kara To: Cc: Amir Goldstein , Josef Bacik , brauner@kernel.org, Linus Torvalds , Al Viro , linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Jan Kara Subject: [PATCH 04/19] fanotify: don't skip extra event info if no info_mode is set Date: Thu, 21 Nov 2024 12:22:03 +0100 Message-Id: <20241121112218.8249-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241121112218.8249-1-jack@suse.cz> References: <20241121112218.8249-1-jack@suse.cz> MIME-Version: 1.0 X-Rspamd-Queue-Id: 211664000C X-Stat-Signature: 6efqz895fm81zke6omn8jc87nqiunz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Z30UeXFwcUIZ9dssYCZY0wMvNDeCtTw4stupZFn53JjzCNlQt2xdpSKuzYOWkj/BiazalDa3h04vK6xvPwncZRFrOZ4ObUzNYCPHTLrhW/B5JtQ5OuJ5RYtBJYLblXdBc+DnRryjTeqR0rU839mitDlmLPyuwEHVl3aqEIyYG9wlkBwRcmvia5zo7VUWIbYBwegEYFjAAd8dSf27r18LbbArbvn/Q1kv3FGgiipyRs46wCG2VpU/FiKjinEUxIENRUpyUE+8lNY6Yv550HkBXDJuU19er+NbTuaprOFCvq7c1km4bDVvurqyGUymjQ/9XpaoALj1dCySaXGgxf3YKZyvR7mJpZ7paA781Tu8/QjDP5IWD0Z/Mh4ikChzzRaKCL2WO0RksBMR1fcR7uzbo9OzT4TJ5EbNahzVesNs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Amir Goldstein Previously we would only include optional information if you requested it via an FAN_ flag at fanotify_init time (FAN_REPORT_FID for example). However this isn't necessary as the event length is encoded in the metadata, and if the user doesn't want to consume the information they don't have to. With the PRE_ACCESS events we will always generate range information, so drop this check in order to allow this extra information to be exported without needing to have another flag. Signed-off-by: Josef Bacik Signed-off-by: Jan Kara Link: https://patch.msgid.link/afcbc4e4139dee076ef1757918b037d3b48c3edb.1731684329.git.josef@toxicpanda.com --- fs/notify/fanotify/fanotify_user.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 83ee591744e9..8dcd46fe6964 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -159,9 +159,6 @@ static size_t fanotify_event_len(unsigned int info_mode, int fh_len; int dot_len = 0; - if (!info_mode) - return event_len; - if (fanotify_is_error_event(event->mask)) event_len += FANOTIFY_ERROR_INFO_LEN; @@ -755,12 +752,10 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, buf += FAN_EVENT_METADATA_LEN; count -= FAN_EVENT_METADATA_LEN; - if (info_mode) { - ret = copy_info_records_to_user(event, info, info_mode, pidfd, - buf, count); - if (ret < 0) - goto out_close_fd; - } + ret = copy_info_records_to_user(event, info, info_mode, pidfd, + buf, count); + if (ret < 0) + goto out_close_fd; if (f) fd_install(fd, f);