From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (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 670421F3BAC for ; Thu, 23 Apr 2026 01:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776909576; cv=none; b=X/CcrAE0tn83fkyR/WcqwYJQc1E7UYHzTISypGNypnev0NDw4mRqu6uLBxCKgQw9HCPeIFyjvenfD6NHLe/cSlBBfdxLW+cLH5F2LJ0WadBTDlvlRmXeFZfx0E+ngAwYAGPbw8YAvMahRMguOOOIhWYcFIOVd2k+R49/KRohbKw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776909576; c=relaxed/simple; bh=Lterwony2FtJvjP1BuB8aBl1R1VftyjEEpqcp+6Ekhs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kqD77hNQ64rlqiiAAr9MJ0E6nAJEFKKu6IobDtMd97cQ6YO6xuXcp3O74UgDpJZuj2GtWtY+1GP4JaaFMEqiE1i4B3+8/xZHiJSrJ6avM7Zddq+V2woV3pjsBjSnHI4wCtU/uzk/VCXwGcBZa8seY0JPZEwSQu9u1oqMbwfHWxI= 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=AKkN10sb; arc=none smtp.client-ip=74.125.82.175 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="AKkN10sb" Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-2b6b0500e06so9869166eec.1 for ; Wed, 22 Apr 2026 18:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776909575; x=1777514375; 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=rDeKDbl3FkCpnF1llZ8KN55wot3WZsG6pj/Ef7jrG+g=; b=AKkN10sbZyYz8UJClUc6Iulml1n0Od2UXmKmGodrRa00BKkl6zdQmlQ2olNux2ArVy 0ZG3Mto6IXXjiQp92vhIyKhffojUooSpxMe3p0A5688/ryr59Hz40bBqHPCkOBx1x9tt JDJTvOHbCcBcAllEa6HTksCUo+vUpQWZ5MSse/q7j0reQHrWjt/dE6TYlZWaql/jNXV3 LwtfxLbhPcaFIlQH3+d27KJhnLdUefpIOaYTT0OHQlAIwQqjVLzaznbVjRsIVQRGtcST fnqLRtrv7SpaXJagNijAqLBmZtE31yzHFoMmlawHiji+5G85Taod0ywIN/c4GUdtEzJw vKDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776909575; x=1777514375; 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=rDeKDbl3FkCpnF1llZ8KN55wot3WZsG6pj/Ef7jrG+g=; b=CjvttaWlD1Ijm4k3sEyJV/nQyeO3OybAP2GayKBErP0bxA/SBO0E/N9EpjFg38Gikz zyy1VBuzLpOWR9SCMOKm8Ob5L3rVskIn/QbodvbUFM8DsB8PXJOY/GmDRKIcMNTdTv/2 raohGc8YTI72MEKg5UJxbRWFNkBIiIRxq54U7W3JMMNewd4gRPfYcwfsHXfuzTaE1wJU HXtDl5/29SFF0ssuieF+G5FI5EYVHyhS6LJWF1D+ZyFGHwTYOI2yvw01Hlp/gP4b/Ucc ILy7DlTRFSICIagBe1Wmd8s7z9d95ZkVSc8+C0AilKfH+NR7VF0yWRNyD/AFlfhmp3q1 Xdqg== X-Forwarded-Encrypted: i=1; AFNElJ+uFHHGI51tJV3A8ytGLUc5wjs03TSZl8ZTkurb+mEL4+GMmx6s3se5Z7zXShzPQZaMQT6BfXgT9Pz017Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyoZt8kmpR00wFJ9VquPQ8zvu4bUVT+hrR5N7i2zyzFw+lc7oeX rR40JbY+6odHXp6KN7lqU1CDSBf6CNjyR4xk3cKlna1I53TbiQeKBaHt X-Gm-Gg: AeBDiet6aTQRvujFaljyzbxMwGf9HJyUnQYYW4G9oFJ36Di5IsiLBNMGwL2o/gKMXkw 80MnqP8MgDgDL2ew53W9HybP083g4jgQshPK6/IBfkupxPqOUz1nWK/XxTqwDlqzIjxc70Yz/Sh NN1aB8eMN98baeTd5pfHZ38wmjlN7KBbcK6SeO312fZMuJq0pk6ap7iesMCu5/UtLregpntUeVc uzUxbtGySFRsYtPSn96wlKIO7xxoeUEIGATvyvURI5fmkex61Yf2qGyW8S4r1w/ht3FCU0aHVWk dMU0RybjFvOVKWXiVqXf+T1OtsoNN3rzPJwaSQYdJ55ZvW9GzrGR08rf1ACkunfM7hpeL+ak0Bs PzERxxb6NGZfsWBu1bCobkrO/Bw/uaCPyLffzAAibAhioklz1y4WITVHIQuMXC9ZOs5CXAC+WiR P0LVGnH7K4e1SkZRVBKb75qnOY7yZqWD6ihzqATx7VKLEgD8peY1S6Uf+qQBIfIuegzBNl3g4bA h4= X-Received: by 2002:a05:7301:1f01:b0:2c7:5a7b:e8c0 with SMTP id 5a478bee46e88-2e4657714d1mr13182745eec.12.1776909574457; Wed, 22 Apr 2026 18:59:34 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:2359:5fa4:9c29:41b1]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2e53a4a80c7sm32163227eec.10.2026.04.22.18.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 18:59:33 -0700 (PDT) Date: Wed, 22 Apr 2026 18:59:31 -0700 From: Dmitry Torokhov To: Greg Kroah-Hartman Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable Subject: Re: [PATCH 2/2] Input: synaptics-rmi4 - use u32 for reg_size to avoid sign extension into item->reg_size Message-ID: References: <2026042044-amuser-tantrum-73af@gregkh> <2026042046-clad-aspect-e8f9@gregkh> 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: <2026042046-clad-aspect-e8f9@gregkh> On Mon, Apr 20, 2026 at 08:59:46PM +0200, Greg Kroah-Hartman wrote: > rmi_read_register_desc() builds the 4-byte register size from device > bytes: > > reg_size = struct_buf[offset] | > (struct_buf[offset + 1] << 8) | > (struct_buf[offset + 2] << 16) | > (struct_buf[offset + 3] << 24); > > struct_buf is u8 *, so each byte is promoted to int before the shift. A > device that supplies a top byte with bit 7 set (e.g. 00 00 00 00 00 00 > 80 in struct_buf to reach the 4-byte path with offset+3 = 0x80) makes > (0x80 << 24) overflow into the int sign bit, and the OR result is > negative. reg_size is then assigned to item->reg_size, which is > unsigned long, so the negative int sign-extends to a value near > ULONG_MAX. > > After this, bad things happen when numbers start wrapping and buffers > are allocatged based on those numbers, and then accessed based on those > buffers assuming to be a sane size (bigger or smaller). > > Fix this all up by just properly making reg_size be a u32. Shouldn't it be replaced with get_unaligned_le32() instead? Thanks. -- Dmitry