Message ID | 9b3babad8f950d8d3eeba21867782533d4bb1798.1707382595.git.dsterba@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 DD6B36BB22 for <linux-btrfs@vger.kernel.org>; Thu, 8 Feb 2024 09:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707382822; cv=none; b=FyoQUAnjMkyfXN6OQo7URJuucQv7uFLHNYLiHmV/wPZNojZNss7kJGA35svH+iUPXjWyjPlg3TvRVNe1ys3fW6fR8DIPr7HtRKCKDsdYOO4C37wsw8Mejnv0lP+/J2ib9rRMc9GZPUWyjELVWJehQ/ySdkH2A+NT+l3w4g9Ob0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707382822; c=relaxed/simple; bh=iUJNMX0EYDJtSlzExvNrZBZMD2G58hMuOcXS0NQWW2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tYJ6p6m6ywqWcBVbhE3J19Ul7wzyOgVNjyH+a+Hl5aYKhAZ9cOq1oZHzFGCv7hzkhAo5XdicJZjhX5hoB0X0E3vWUERpRpjIkaV4OZl5MQZoKQq/dVTmnKfY50clLBXi8Ej6bkbaCjxofinebxV6iU/tdKIXDggvDXPiBiXfQbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=U8YCaMtV; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=U8YCaMtV; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="U8YCaMtV"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="U8YCaMtV" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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-out1.suse.de (Postfix) with ESMTPS id 26BBD21FD4; Thu, 8 Feb 2024 09:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707382819; 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=WwaQnfy+CaoMk9iDcwKib1ju4BwihYdtuw0T2ODPtzw=; b=U8YCaMtVIRGvSP7LlhLaitYv5AZz1QtkgirHS9A9SaFjwQk0YjU1BtS0YF7Fqrb7fM5zZW GJyD0f2ZGDhRdQ+vt7xKDM29D7BTqB5zpo2hwhcOp+j5o1BMea95sbL3kHwevAQ5z3lAbh 1llNIIwWeVVyViyLKHpUHP/nBRc7XD0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707382819; 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=WwaQnfy+CaoMk9iDcwKib1ju4BwihYdtuw0T2ODPtzw=; b=U8YCaMtVIRGvSP7LlhLaitYv5AZz1QtkgirHS9A9SaFjwQk0YjU1BtS0YF7Fqrb7fM5zZW GJyD0f2ZGDhRdQ+vt7xKDM29D7BTqB5zpo2hwhcOp+j5o1BMea95sbL3kHwevAQ5z3lAbh 1llNIIwWeVVyViyLKHpUHP/nBRc7XD0= 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 15ACE13984; Thu, 8 Feb 2024 09:00:19 +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 QYtJBSOYxGWBDgAAD6G6ig (envelope-from <dsterba@suse.com>); Thu, 08 Feb 2024 09:00:19 +0000 From: David Sterba <dsterba@suse.com> To: linux-btrfs@vger.kernel.org Cc: David Sterba <dsterba@suse.com> Subject: [PATCH 06/14] btrfs: send: handle unexpected data in header buffer in begin_cmd() Date: Thu, 8 Feb 2024 09:59:50 +0100 Message-ID: <9b3babad8f950d8d3eeba21867782533d4bb1798.1707382595.git.dsterba@suse.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <cover.1707382595.git.dsterba@suse.com> References: <cover.1707382595.git.dsterba@suse.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: <linux-btrfs.vger.kernel.org> List-Subscribe: <mailto:linux-btrfs+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-btrfs+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.22 X-Spamd-Result: default: False [-0.22 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.11)[-0.574]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.01)[45.55%] X-Spam-Flag: NO |
Series |
More error handling and BUG_ON cleanups
|
expand
|
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 14ea30850739..1bff7b3008ac 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -776,7 +776,12 @@ static int begin_cmd(struct send_ctx *sctx, int cmd) if (WARN_ON(!sctx->send_buf)) return -EINVAL; - BUG_ON(sctx->send_size); + if (unlikely(sctx->send_size != 0)) { + btrfs_err(sctx->send_root->fs_info, + "send: command header buffer not empty cmd %d offset %llu", + cmd, sctx->send_off); + return -EINVAL; + } sctx->send_size += sizeof(*hdr); hdr = (struct btrfs_cmd_header *)sctx->send_buf;
Change BUG_ON to a proper error handling in the unlikely case of seeing data when the command is started. This is supposed to be reset when the command is finished (send_cmd, send_encoded_extent). Signed-off-by: David Sterba <dsterba@suse.com> --- fs/btrfs/send.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)