From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 8973D3909A4 for ; Mon, 22 Jun 2026 08:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782117841; cv=none; b=MeUtiLOyRtFraywnaXIQhbGpkDmbcy11Tk+yb65+1Z2vcSqMZaGHZNrkXlCadqU/3/eyUES4FSTw846jgj0yrdHRM0fUDZi7etzLo7jj6uBjYuFbFTymcA9IttZiwbn6YVrhFg7UeI2WXTsBwqFwQVqBUMEv2FFEDsgcRFQohVU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782117841; c=relaxed/simple; bh=g0gRsy6zFiomxjase+ZA4WZlkxxDYp7gD/XOpVGQPhg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=heoUq0wS/gongLMF/ApQMVoXWRej9SinfzeV1HeM5psTTec8JtuAUH5Vz7Gp5Nc68R2F8PeU8NK4CMlHmOu1WVv2uwhjP21B6x37VpqSyW56cagQCHpB0bFA2ZFcAsbAbTGliekSTAhjOxBZ7WazJn8O/5TThsx3f+rF+cFGMAg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ThoQw3BS; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ThoQw3BS" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-bebb72b845aso656291466b.3 for ; Mon, 22 Jun 2026 01:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782117839; x=1782722639; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LR7honTOmyUatu9A73ADWJH5CaZ3n+G3Y/QkgDQI0TY=; b=ThoQw3BSct7YEZiR7/itBivH0CsJCVR1/ZJzjQJ0XshobWSBDKaJVnXNgCyf4l8e02 BBdJwRCnZ30rKHwCHpquivQ11ATqTfNJJTwMo+yaeS97IXPyxWJDIwTivVeteZ1L8jFQ XPLPbu3Am31sBmezRRziogyEd13tBTE4/14qjKxuSkxdRZu5N3NxjS8JEZMm7ydnzpm1 hNyUxrrlOcTrPwChHtJHTRZWRYcD5nyt/fG75saz7Goxod23zwfuyn8LlKt4QS1sMaFK DIb7d2EVn3Fra/E45tDaSGj2mQEJsoyMKhTkV6CsasJYzUBYsGEliL0lf9fp5wFN87fv g0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782117839; x=1782722639; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LR7honTOmyUatu9A73ADWJH5CaZ3n+G3Y/QkgDQI0TY=; b=F+TglQ+tkBvXs1vU+wdaaEzFHHXU0msuPcckyIZtp2L2bcmq1K6cVEj8ueETMnn/mC rgTsM6V7XGyzpyjp1pVS2VIJ0q941Ro8II9iFRnYqyhQgy8uB4PTXjGfQlIAdArcDsVI jnsiufAJyxURTLfqk0TKjNs8sgMS7BklqhAbxuEoY4w7w5uJWHj1LOj4YuaODQXMvAIj xFI0aPA/Izy2nI3gbaMKCBNOagahPb9sHB8wLz5c56XRnzLnLqmQO3TP09yo745SaQch NfnFZ3SM8An3FXjgUTOJ/5RArNMkAeDB0NAqJenZoRTeuSt1XiEA4rS+xw4L+fgd3EPR jDXg== X-Forwarded-Encrypted: i=1; AFNElJ8jdS7wU3361lRNf4q4xFpp5GHaODqB0s49C38uF4JA+wlSAHb68+GLPVNTlE8xNBDwSd4Pg/fGTKUePBA=@vger.kernel.org X-Gm-Message-State: AOJu0YwFxlPDSH4lKGf/1NiNHEyMt/7FTVSl8lfRi+k9dCO1dsIvYXlk LLEFnilY1IJUVFCPv3zpP1Y10OIKrrjGX/0kIxjyXd3X2+tguStApWs4 X-Gm-Gg: AfdE7ck9ZRmxtJWREc6WtvvXBXpq0CT04+3WDuby/ymmH2XB85S9YIjjbhKRKP4szDe lFiTxy4P8Bo9Il95xaWc3QB4tY+y5LCq9itBPOWJn7E0nyqW4APpHIiKpTHZimCFcLHuF0daHLQ mhUT6DQgk/s+swp9VuFkJJk1hMHJeBhOif3N3//E9ICUbMI3TUjeDNba5QGDs53ultu7VuFGAHw BUgCe5PhwNyRSapIyVDC2KpOrqT1fXLii66wqaWJujY+yIK1nHtn2dR6DENHiUgJ7yKfdD6VcZ9 0cAB6Cc1nu8bD6ilIxSqaJqzJ6Lvje1FdGaHHLQKaDgh6Dj75M2bAFty14RX0SKPVeekPogCAW2 IX1lXdLJfWiMHpb3jPMjptduQMCn6o/k3tfE2jX02UpYSmccQLpAiTuIr2uY20zpjcGtNgGr3Uy vrVIC8qcES X-Received: by 2002:a17:907:c12:b0:bfe:ed35:e859 with SMTP id a640c23a62f3a-c09904f9097mr699871766b.53.1782117838777; Mon, 22 Jun 2026 01:43:58 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c5ef8eb38sm313992266b.28.2026.06.22.01.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 01:43:58 -0700 (PDT) Date: Mon, 22 Jun 2026 11:43:54 +0300 From: Dan Carpenter To: Sajal Gupta Cc: linux-raid@vger.kernel.org, song@kernel.org, yukuai3@huawei.com, tomasz.majchrzak@intel.com, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, me@brighamcampbell.com, linux-kernel-mentees@lists.linux.dev Subject: Re: [PATCH] md/raid5-ppl: convert pending_flushes from atomic_t to refcount_t Message-ID: References: <20260622080656.22786-1-sajal2005gupta@gmail.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 Content-Disposition: inline In-Reply-To: On Mon, Jun 22, 2026 at 11:42:01AM +0300, Dan Carpenter wrote: > On Mon, Jun 22, 2026 at 01:34:32PM +0530, Sajal Gupta wrote: > > The old atomic_t based counter allowed ppl_do_flush() to continue using io > > after it could already have been freed by ppl_io_unit_finished(), leading > > to a use-after-free. > > > > Convert pending_flushes from atomic_t to refcount_t with a proper ownership > > model. The creator holds a reference for the duration of ppl_do_flush(), > > and each submitted flush bio holds a reference until its endio callback > > runs. This makes the io lifetime explicit and removes the need for the > > second loop in ppl_do_flush(). > > > > Fixes: 1532d9e87e8b ("raid5-ppl: PPL support for disks with write-back cache enabled") > > Reported-by: Dan Carpenter > > Closes: https://lore.kernel.org/all/ajJF2wKYWRk4GGCK@stanley.mountain/ > > Signed-off-by: Sajal Gupta > > --- > > Have you tested this at all because it doesn't seem at all correct to > me... How I imagined this would work would be: patch 1: add a break statement to fix the use after free patch 2: s/atomic_t/recount_t/ The difference between atomic_t and refcount_t is that refount_t warns about overflows and underflows. regards, dan carpenter