From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 8FD263DEAE7 for ; Thu, 9 Apr 2026 15:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775748319; cv=none; b=C8DdvsFehjVYEBiWNJdxN6N0OxPKaS07BXaRzhBjX68vKFyvaktDI3YJn7Rvokb3WsL0I0xl+vBy7O4nBGs6L0oj1hDT06Anan5nSz0RruI0P9uIFpSiF/29tPeIrt+Rt3JwMMvtu8P6F3L8UlHSlpUDLdxl76jA8FL4VnMTISU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775748319; c=relaxed/simple; bh=AGjnYjPqVLDifeRVC4/yNZFHk+1e358dreo3JoaGM/A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BXCT2JyQ2IJn0vp+E92Gq5NsiKKJceKPnksMnUiYKKlrCrxVRuHUl5+53uHyz0W29lLLhB4qt402KYbfsYXqXw1JLy4flPNSnwIb0Q+iKEcbGGtFRrff/MGxqciXUYwWnrpwUEWCvricPfBYOFPccoSAF1lst+Y1VtF+pocAfqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b=GoPqFCB8; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b="GoPqFCB8" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-7d9bba96f7dso571780a34.1 for ; Thu, 09 Apr 2026 08:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1775748316; x=1776353116; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FN9TaQKqyBYuIUQ0wOlXr8V4u8AjLHkSQhs9XX2t4Bw=; b=GoPqFCB8oXKhKcGkFVVrBxA2ACtu6QbFh9sxSrU0YXjfmeoTQthI7n3YSsfJXGR4rR ku4DduN5CUfHYKJW3plSWwN2o4Zy/40DSbabyoEgo4ruOZ/4p7vWZWajgPCFqy04hwRf KWd/mLIevu0B0cuvUXQOgy/gVGYcUe8jcmG2cIesgKYZNequkEJv0FpNfytGBeyDE1ER nHBladWUYIHaHT2PKcrQczMlSWYr1+OqGQznAmsqqD9zbXjT9yFzhmxLHam0tpytAxzy 2QiIAwJxQKt50lIVYhUlRkXdy/fVeHJhmTHCHUCU9vT0kecVz/CNwgFZSaURIwTRKY3C XnmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775748316; x=1776353116; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FN9TaQKqyBYuIUQ0wOlXr8V4u8AjLHkSQhs9XX2t4Bw=; b=KC37D2OuimLAZ/O2WljRrF6D7CWMPnIraVcfTuzmCxpCCmkZUqush2gRLtTUCu66MF 3pBVAK1X60KKUVfxlQrvu0TJ0nWiQp7GMT4MUie6XWsKZ8ArKzU6D4dX2ynDtvsaYDi9 J8II5wBftVoGCwvKh0GRMkcl95Q0nQB0utZZQD2zAkEv4rram2XAtlkF1LNWKwhNpAVc w2EmI9BPlL8gbzOTfxwazA2/JGJtdzCCkWSuQu6sXQOnXqDl2XEkwSCe0itg/88vpDCY d/QTxE/4OqYwaQUL3yRs99Z2MPu1WKoSQ0i1twXhpGJxSrmKkkioImgmF2uuP6icui8x /zvA== X-Gm-Message-State: AOJu0YyYB0Lcr8pTYzJC2jE2MtfD0k8rOUAYw8AhMhzHC6TIGm0nu2f5 RhX+/5EblRVFZ/XBNqQHkVNpog5f0Yi1yhGK2jWQcFsJLMn/BoSwF0JphJ/zZ/FSfCc= X-Gm-Gg: AeBDiesoHPhAMaqcakXZXV7svKCQwVdT0N5qF3WZCmO8R+iG2l+dTs3o+zqDnYHrWUZ P89pU3jzJIs6tES+aB4QVAeCT25RJbpe9FFY+Zgzt9Orzkz1Utjoiw/UVnF6sjFZW+akBsbkmFI 6BblmKTIuKhnxI1MjhvbXewL/jk2ErREvFyo9Qc6IwnFx5F9Mn7sAYXZ6PKI/U9X1fRLkEMKUR/ nVb3tdcL/9KOJdM6ETFzorLVqU7CQq1FgrdVzQ8khyeXinZJ3xmOUDwkNscSRvqQh2LxVyGy0Z3 LtUj0aLsFbhoGGVZkGOM5hO3bm1ThAN/og846orWVhyYzCDZfQy6HohltwxSvfo6MiCD/1JcB8V 4FE68tFp2VRjMMnbGuQyeR0lf7OZnqXV5/vEV7GxHMdNfpxUctnL1gh8go9AVwW9Iba5adE31+d nbYJUrLdi6H1pKgpkUzoX3Ae0JvoU42T9h3/DfoVY858LF1mtwpFYxTynU154cjOAwVandpnBTM 4xxdqy1s8eP X-Received: by 2002:a05:6820:134c:b0:684:7d3b:4378 with SMTP id 006d021491bc7-68a605ebc5cmr1959172eaf.4.1775748316533; Thu, 09 Apr 2026 08:25:16 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:a548:cf0c:d054:fd01? ([2600:8803:e7e4:500:a548:cf0c:d054:fd01]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-68bc491592csm120eaf.5.2026.04.09.08.25.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2026 08:25:16 -0700 (PDT) Message-ID: <590ff995-00c6-44d5-bc24-d4cc2b7547cd@baylibre.com> Date: Thu, 9 Apr 2026 10:25:15 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] iio: imu: st_lsm6dsx: fix stack leak in tagged FIFO buffer To: Greg Kroah-Hartman , linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lorenzo Bianconi , Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , stable References: <2026040947-overhang-fax-02d0@gregkh> <2026040949-ferment-reload-abcd@gregkh> Content-Language: en-US From: David Lechner In-Reply-To: <2026040949-ferment-reload-abcd@gregkh> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/9/26 8:40 AM, Greg Kroah-Hartman wrote: > The tagged FIFO path declares iio_buff on the stack with __aligned(8) > but no initializer, but there is a hole in the structure, which will > then leak to userspace as ST_LSM6DSX_SAMPLE_SIZE bytes (6) will be > copied, but the space between that and the timestamp are not > initialized. > > Commit c14edb4d0bdc ("iio:imu:st_lsm6dsx Fix alignment and data leak > issues") moved the untagged FIFO path to a kzalloc'd buffer in hw->scan, > but for the tagged path it only added the alignment qualifier and not > the initializer :( > > Fix this by just zero-initializing the structure on the stack. > Reviewed-by: David Lechner > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > index 5b28a3ffcc3d..48291203d1cd 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c > @@ -609,7 +609,7 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw) > * must be passed a buffer that is aligned to 8 bytes so > * as to allow insertion of a naturally aligned timestamp. > */ > - u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE] __aligned(8); > + u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE] __aligned(8) = { }; Looks like a case where we could follow this up with a patch to use IIO_DECLARE_BUF_WITH_TS(). > u8 tag; > bool reset_ts = false; > int i, err, read_len;