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: 13881888 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D8041D0E2F; Thu, 21 Nov 2024 11:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732188148; cv=none; b=Wg+mPSeoz/5OvMwRGcbRxauVSz54La3PCbaqvNtCw7XBjpEJ9RsrF0AD18zw2bCSqYfXgH9kuZygK/qxEeFxxb+pXCAOASXjORRZIXvnK9rXPYK/B/cSdKtR/J6GPrLrhwOmres45tzEWQsJNVB5BmuFIm22dKbx+CetYpz/+8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732188148; c=relaxed/simple; bh=lh0DE46HKoFCeEKv9mz1OBWHLLuYhGNXls/80tR2Xmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FWPjv3PoBvUJfSzMGkVy1+IlUYUkriboO/YhezFG9Ct/X6qpTGUshc+vM7ok6AYQykSFSUlKerGFOaZy7OfN5gqj74gFrLRrNuywLjP2iUUdxNMkBgV2DBIcaMQTuLeTudd8hxtaMEEzlucIJXu7TBFo1GJPKICqSOIv7nuYJXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=iREK+iQI; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=7xNbZGvk; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=iREK+iQI; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=7xNbZGvk; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="iREK+iQI"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="7xNbZGvk"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="iREK+iQI"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="7xNbZGvk" 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== Authentication-Results: smtp-out2.suse.de; none 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> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,toxicpanda.com,kernel.org,linux-foundation.org,ZenIV.linux.org.uk,vger.kernel.org,kvack.org,suse.cz]; R_RATELIMIT(0.00)[to_ip_from(RLdu9otajk16idfrkma9mbkf9b)]; DBL_BLOCKED_OPENRESOLVER(0.00)[msgid.link:url,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -6.80 X-Spam-Flag: NO 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);