From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f54.google.com (mail-yx1-f54.google.com [74.125.224.54]) (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 A21923D16E8 for ; Fri, 1 May 2026 15:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777650458; cv=none; b=a+PGihZRWsrDQybL7Zk+sXxUl+qbNaUXsIRsbB6b0cudm7AJOu7gzZSuxr4J/9wxzUZejlpfY0pXdtkssFH8nXseAQAMcZhCsxmWSsPwQ7mlVXe6cVVzULS2PyeUGd2DKw0SngxUhiCSJxL2kV7lGSgEEX2+SWFi08iqaY6TCdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777650458; c=relaxed/simple; bh=dBGR5oPl4LoWOunaVjYZCakcMx8qQA1CoWvrOZzKoSs=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=t06f8s3I2u55WCwZrqGIHnWtW886gH0qZOHwp3L4bciHUZuuoLUQdR5Nv4x9Zbjs/MjMuHVRep/d3VysCxsiBS5quyDIcWRIaGXogRDkbxgaA7Ocq7TmZnuGcSxCEu7QnhtKVTwvLR2fZUDrIxt6jLcFRivc8BOulwNd85kbHHE= 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=ELMcQCy6; arc=none smtp.client-ip=74.125.224.54 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="ELMcQCy6" Received: by mail-yx1-f54.google.com with SMTP id 956f58d0204a3-65c305f381eso839813d50.3 for ; Fri, 01 May 2026 08:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777650455; x=1778255255; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dBGR5oPl4LoWOunaVjYZCakcMx8qQA1CoWvrOZzKoSs=; b=ELMcQCy6f7L/zKidIkIoxSDUNbqgxOSHA2O41VS9Z/ETcozHdtY4C6Dui6TGnot7mq KipSjJfOtbd4KK3ZZ0yc5lzdZh8iOA0VFdq9VJUSv5b7vDo1Muv2FOsdRcYa5BQo3+c3 kqmN86Tajg/yljkpNaZoTpssqvQxDggtz61mU47gJ2HT8oR++7xhzNJ0ggUEk9xLCVbw EHXarEgat9Zf4CMtkJRV8mqymWE0sLeJCNiKCYKO5QIWWhVbiC1JWfG/kw+WoIJypZre Y71f0iQX9A82C/W52oDSH54fvyHmUTCvtV6FcSkai9uzPDtM5uQbnoUHQGXf2TsxgQDj Ys3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777650455; x=1778255255; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dBGR5oPl4LoWOunaVjYZCakcMx8qQA1CoWvrOZzKoSs=; b=oqJ2MligoXxf3uvZJZ+WfLdaoeI8Xy9mUPVfW+0kH3rqh3SRL9SEO5QBOkdyiugdky ny7WjhZaYE54EYb52+uLo4Yq7yVN1W5Pyzx4/v0nUH826abKl0WgxrscIa++E1jFjvFp fqufntEdtQmMAIqwTBPHWHmdajEafXmduSxiklLbh/xWoLQtD2RU+LfzjVVB84h2XagG 7jlmHiHzUOmxFYs9Ix782QrTruID8xTpV7dQVYZQTQzPe4TLS+OWDylRrgHGPXroshOz 1gnEJOCq9Wt+ka+y4hIwhOsesU8KqRRY0YBagSnOnep3MAn1GWvefDekdoJxechy28yh OHQg== X-Forwarded-Encrypted: i=1; AFNElJ+vPGOLFB1wbhJLhN1PrJTehfVCY28tRWyeZ7a09LBKD+NpopzegISCsGKHbgMLw5TrLadHQgViX4e7l9g=@vger.kernel.org X-Gm-Message-State: AOJu0YxErOrdWf+MXv7M2d6AxxUhW7iFC3au+DABUeGy6WeuXla6/Iex 0WbFKMcQrsA6QABB9IRYQS60ivsJnjKzvNrbX+wRuDyBzHfmCDeddmJ0 X-Gm-Gg: AeBDietK8If52PyTCMWO7tGgPZx4SAf6S1kGZfCsDIKlbGmAWl9GrRv1S9XAOsvDisF 2r8dOu99ApAzVvNsfPLvdB4ffLmHKAb1pUGfJjdMrVGVlPBZRLtPL+DukjblfIHfOlANE9XybDt Ja4JDu6bqy2V9Ahmj/Mni9mMcmgUIDDSAP87yDnSwbGGZGX/mmLwf82Y9uB6ADQ4uTdeWMl2hEy gHvgQNpjKZggCm/WeVLcsAetv0V5aXT5kA0ktmm/ysPhn6T1m+zTshjDdlx2ANYTieblcoC8A9I RJAnbmXTMqVq9ztHBpDFQFaDHj4Tmw8kdoWq6cbc2l5/GD+QgiyeqLUTKSto6UNYaDoCj0dN5r3 doC74Aza+TUe6m4qy0lAduxX0sXoY7Ug2OhbHp8KlyNnze7T7aoE4r1qM+TxWyTeO2rcy5aqef+ 9WCrD8Y+mDb0Ga6or3AHTOR3U38cNbJwFiw3rMiAICjebZa90= X-Received: by 2002:a05:690e:c46:b0:656:fc53:12df with SMTP id 956f58d0204a3-65c18fc1132mr7545311d50.56.1777650454958; Fri, 01 May 2026 08:47:34 -0700 (PDT) Received: from localhost ([208.185.137.148]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-65c2e1a1700sm1333297d50.6.2026.05.01.08.47.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2026 08:47:34 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 01 May 2026 10:47:33 -0500 Message-Id: Cc: "Jonathan Cameron" , "David Lechner" , =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , "Lars-Peter Clausen" , "Arnaud Pouliquen" , "Mark Brown" , , , "sashiko" Subject: Re: [PATCH v2] iio: buffer: hw-consumer: fix use-after-free in error path From: "Maxwell Doose" To: "Joshua Crofts" , "Felix Gu" X-Mailer: aerc 0.21.0 References: <20260430-iio-buf-v2-1-84c2231dea5e@gmail.com> In-Reply-To: On Fri May 1, 2026 at 9:19 AM CDT, Joshua Crofts wrote: > On Thu, 30 Apr 2026 at 15:29, Felix Gu wrote: >> >> In the err_put_buffers cleanup path of iio_hw_consumer_alloc(), the code >> was using list_for_each_entry() to iterate through buffers while calling >> iio_buffer_put() which can free the current buffer if refcount drops to = 0. >> The list_for_each_entry() loop macro then evaluates buf->head.next to >> continue iteration, accessing the freed buffer. >> >> Fix this by using list_for_each_entry_safe(). >> >> Fixes: 48b66f8f936f ("iio: Add hardware consumer buffer support") >> Reported-by: sashiko >> Closes: https://sashiko.dev/#/patchset/20260427-iio_buf-v1-1-2bbdac84464= 7%40gmail.com > > FYI, Sashiko reported 2 additional regressions (neither introduced by > your patches), one of them critical. Maybe another patch would be good? > > https://sashiko.dev/#/patchset/20260430-iio-buf-v2-1-84c2231dea5e%40gmail= .com?part=3D1 > I think one of the issues raised by sashiko has an active patch: https://lore.kernel.org/linux-iio/20260427-iio_buf-v1-1-2bbdac844647@gmail.= com/ and I think they were waiting for Nuno to review it, since they noted they were on a "wild goose chase". Thus the only issue raised by sashiko that would still need a patch would be the OOB issue, but I haven't looked at its explaination thoroughly to see if it's hallucinating. Anyways this one should still be good to merge. best regards, maxwell > -- > Kind regards > > CJD