From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 2EE683126B2 for ; Thu, 23 Apr 2026 19:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776973238; cv=none; b=Y4YIKuPqyG+ziSpph1YG/A1oiXcgXGPWgPnsT4/R1C+6F6kwFa2Z7Dyluk7scoxq57BQDHL3C6Zq3XFEwRGSvqPYREZZHH0bV8n4EYOQ+PxCYzq3oThgM592wkYokIMX8Xx/gQEFrz1Mgtt2ASo6lnc6RRUMq0+TFpn+cy+CfuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776973238; c=relaxed/simple; bh=uSmNUzCcUkpq69l0Rj2lwKmCiZNeK4BS59+r5nm2lgE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X5MXo7C03TL4Ow7US5L+ZiJPXBADkFayVXaD6LwZ0WTPmhO/NFaQdd7l6Y0MBHaXtUbO3i2JU/vXZfXxC7ufgb47vSardlXSvpoW31bHSpzMNdXWXqDZWe8pwKSUmGjVLB20ocOaIWDwYFhE8c4ort9yVl7B3ZMT8eY4uj+RX8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=CwvajtMS; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="CwvajtMS" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-8aca2726f61so84419316d6.0 for ; Thu, 23 Apr 2026 12:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776973236; x=1777578036; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ywhNUw5afTsHJeNfdg8jvvwxHAfTKlNaeu8aKrUx6Uo=; b=CwvajtMSt0aUkGMaEgQzbNIAf2VWi+dKzJDUjz7YqtJDTX1eHfmtfqvEyqnY+MJDtV 8/IbBOS20Q8flVc+5kPGy9H05KBl9LGY+/Odom9BDRXvH+vvVpx4t6oPWYHVxRvNYFYQ b4kRTcnZm5xLUlxmswIJgDmwns/Lf4DT9TMWPAZcRJoBSKmY1c/GQgrTc8pVGmrBHXwx Ru1oYsgnD8GKwb4pOdmfBh49uaOgQMQsHNexTn0aS+MKqoNkDia3gw5O2qjCugdngZAc IjolktIE1CPcfU7PmWsyGaVbwm4ncJGHya3HZLxn+ThKp3QWyf+B+foUbWiaWHW/wZXg O02A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776973236; x=1777578036; h=in-reply-to:content-transfer-encoding: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=ywhNUw5afTsHJeNfdg8jvvwxHAfTKlNaeu8aKrUx6Uo=; b=QJjlfSpGdyyEJTOssF02LIyvgjGvj8PdGVaFNkM+CORGHFobTJywxUpYRd0Qjb0hwL ZedB/GmiW4oJ7pyuJXEHh8AWfgTIP+uOWxd+/IqQu+1ZULBL8o79eAnlJ+3RI6SeC5NF 5pnqJJuy4SMmAqAiJe+u6vogH6fNERoXQGnEn/ezUN/RHr3X+dV5lqZ63xqKyPRnhKeT vPR/3CqPZj69hxPSQuuDWUpqlo26jOeWpy21jVpV6Kdzs8cStWHzSZgir9cp3+YUt7Ok JZUR/ZTaM5IkYVzqhoO5OWfucotSejfH/mYo/1tFyD3Edk8D1mcA6dzh2P1Xkgw3CB65 0bqg== X-Forwarded-Encrypted: i=1; AFNElJ8N0EBdWdhxKr8d5H9Uqv45USYnofDXdh8toaHumKbwaohsJCj6uEA1voVL5nz59WaQ1deXTZbUMdNVMH8=@vger.kernel.org X-Gm-Message-State: AOJu0YzlltcwKnhEt/DXY73OMEcdaU0HzZhPpW07PZwwi2HILn2R/BQv 4HsNLgZN+vDJrBkogZ5ZHVjDN2QO2zXd9sszggnZWRozhfAkcLsnK4kmi32NVKmRhwM= X-Gm-Gg: AeBDiesUZqpAAbBMqyWcOXL8H8i9vXjYWXx3SP1KQsEz82JO1cxbIcv+/zKes7r/Lue z22vsqPlw3OTdp2TBbNWspAwUdmnXn6Tallx+pwRFCuMBuhQ7NIY4S6+gE+KAPeb5h7jrFjRpap rLikLWsSfKHYAiSq+mdmm8LR1ca/j0+Vg/XSuIxAUteYj/VJwFL7mcFKPsaNgJ1714tsF1w5lRW D7pz1+rOwP8mPxrN+rsnryLcXP2GsYW4w1G8tLYowH52d/DWDLMtQ2MJPCrX+TVoFGKMX6cCf/E yznkvVZ70B2PIVEbQHTS3692/KA5o3VTwoUiuOo1DxRQBJ9ZCVsNJ2IX3NlEcRiUEPFHKUfiIfE p2RryR/Zf/n/LWAYPj1K8PYHbVnsfY70CI4NWBxB+XczOGp6SZferNLSMsXQD+jMbUYAlFIpIO9 ipsW2dMuzRTxx0rrj0x87U3O03yh3ka6lY1W5hgBy++yU4gewQpMMjQHlS/sSunQ== X-Received: by 2002:a05:6214:508b:b0:8b0:2fbd:8e28 with SMTP id 6a1803df08f44-8b02fbd96e0mr428937976d6.5.1776973236104; Thu, 23 Apr 2026 12:40:36 -0700 (PDT) Received: from plex ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b031f65a27sm157757466d6.16.2026.04.23.12.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2026 12:40:35 -0700 (PDT) Date: Thu, 23 Apr 2026 19:40:34 +0000 From: Pasha Tatashin To: David Matlack Cc: Pasha Tatashin , linux-kernel@vger.kernel.org, Andrew Morton , Mike Rapoport , Pratyush Yadav , Samiullah Khawaja Subject: Re: [PATCH 1/2] liveupdate: Use refcount_t for FLB reference counts Message-ID: References: <20260423174032.3140399-1-dmatlack@google.com> <20260423174032.3140399-2-dmatlack@google.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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 04-23 11:49, David Matlack wrote: > On Thu, Apr 23, 2026 at 11:11 AM Pasha Tatashin > wrote: > > On 04-23 17:40, David Matlack wrote: > > > > @@ -126,8 +126,10 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb) > > > } > > > private->outgoing.data = args.data; > > > private->outgoing.obj = args.obj; > > > + refcount_set(&private->outgoing.count, 1); > > > + } else { > > > + refcount_inc(&private->outgoing.count); > > > } > > > - private->outgoing.count++; > > > > It should be: refcount_inc(&private->outgoing.count); for both > > cases, as it was before. > > Calling refcount_inc() when the refcount is 0 triggers the > REFCOUNT_ADD_UAF warning. Oh you are right, sigh, in this case what you have is OK. > > > Additionally, please add refcount_set(&private->outgoing.count, 0) to > > luo_flb_get_private, where the rest of the private fields are > > initialized. > > Will do. No need to do this... > > > In general, I prefer to avoid refcount_set() because it breaks > > continuity and makes debugging hard. It should only be used only during > > initialization, so moving it to where the other fields are initialized > > is the correct approach. Reviewed-by: Pasha Tatashin