From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 280363CD8A9 for ; Mon, 8 Jun 2026 14:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928187; cv=none; b=pPerhqd8/Chwc587Q5vYX34BtgrA32qzcwcYay0PhJW7uMZC10yN7f3s6BynSiddAHQ1PC08Vt4qq6tXKHlegQsi9d0e2ZWHOkTPnPPGL+CD5pqNbXTtF6JOVnzsV+eyO9etd2I4gnGow71Cb+M7wMk5bgRKBlXdHkKJqLefvYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928187; c=relaxed/simple; bh=pXxvwbkYE2gjq7WR0Q7VjUVPyJ/OJ1GYbzDCAvTm7HE=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=NeUlUGBZbj3B2jFmRG4RVFGJ4OFEa7SlW+YwPhSFxUJTVOGb3p/ROxF5S/0mNNeHZ0HDbXZr0rE69rsFaCuxhQCCPYlfvonAcXW+0bImvTPYbaLTJF5O9slnjH6IQxHcl5KN+pgZQtPArNgJz5oiMCGdgzBfFSQqVFRvo0z7s4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bgUqzUnU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bgUqzUnU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780928185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6IbKKv69rHubHYnpBtSzGnIX3RFsZKJvIpaQT7dPb/o=; b=bgUqzUnUxhW4w52mMjO3ZxQEKLnJlbQCfEARjJ+i9d6Bsc7MgOm0xvNW9/YEjpLMH3ZFiz h9IKK/W03cxPXqcWpUXFGCsZGmjbptiuR5qhCwh5DXzbQOQ4/0QDiC0q3yTjlsEgtL6jBU F2zn0oU3ek06I1UmraIdYWBFYbDkxMg= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-32-XZOSR7YAMfGGV9YUwUbQ4w-1; Mon, 08 Jun 2026 10:16:21 -0400 X-MC-Unique: XZOSR7YAMfGGV9YUwUbQ4w-1 X-Mimecast-MFC-AGG-ID: XZOSR7YAMfGGV9YUwUbQ4w_1780928180 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 683D21955F29; Mon, 8 Jun 2026 14:16:20 +0000 (UTC) Received: from [10.44.50.170] (unknown [10.44.50.170]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C2491800583; Mon, 8 Jun 2026 14:16:18 +0000 (UTC) Date: Mon, 8 Jun 2026 16:16:14 +0200 (CEST) From: Mikulas Patocka To: Samuel Moelius cc: Alasdair Kergon , Mike Snitzer , Benjamin Marzinski , Heinz Mauelshagen , "open list:DEVICE-MAPPER (LVM)" , open list Subject: Re: [PATCH] dm ebs: drop dirty bufio state when discarding blocks In-Reply-To: <20260603175151.25026-1-sam.moelius@trailofbits.com> Message-ID: References: <20260603175151.25026-1-sam.moelius@trailofbits.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On Wed, 3 Jun 2026, Samuel Moelius wrote: > dm-ebs can discard a block while a dirty dm-bufio buffer for the > same block is still cached. If that buffer is later written back, > stale data can be written over the discarded state. > > That resurrects data that userspace explicitly discarded and breaks > the expected discard semantics of the target. > > Invalidate or clean the matching bufio state when processing discards > so that old dirty buffers cannot be written back after the discard. > > Assisted-by: Codex:gpt-5.5-cyber-preview > Signed-off-by: Samuel Moelius > --- > drivers/md/dm-ebs-target.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c > index 1e52bde48b91..9fece535a0b3 100644 > --- a/drivers/md/dm-ebs-target.c > +++ b/drivers/md/dm-ebs-target.c > @@ -212,8 +212,12 @@ static void __ebs_process_bios(struct work_struct *ws) > write = true; > r = __ebs_rw_bio(ec, REQ_OP_WRITE, bio); > } else if (bio_op(bio) == REQ_OP_DISCARD) { > - __ebs_forget_bio(ec, bio); > - r = __ebs_discard_bio(ec, bio); > + if (write) > + r = dm_bufio_write_dirty_buffers(ec->bufio); > + if (!r) { > + __ebs_forget_bio(ec, bio); > + r = __ebs_discard_bio(ec, bio); > + } > } > > if (r < 0) Hi There's a bug in the patch - when the "write" variable is false, "r" is equal to -EIO, thus __ebs_forget_bio and __ebs_discard_bio is skipped at all. If dm_bufio_write_dirty_buffers returns non-zero, the error is erroneously reported on the discard bio (that is innocent) and not on the write bios that triggered the error. Mikulas