From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.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 75E0C3A7F57 for ; Tue, 23 Jun 2026 05:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782192247; cv=none; b=PqjH6pDO6I/hKpBoo8lAAeVY5Y1pVJme+xuDsatBuKsrrLn2Wx4f9H2mvybygLyP3Oz/HROPFZww7hw97T7gzzkgZOyl5tE4H4NsZFPvQB11humPaGc7tc0ws9YcOaqGb+IyU67PGBEuQnmhWgYCIImp3lT0HQTUo7ag82FXm+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782192247; c=relaxed/simple; bh=4Blk7sBC5Pyt2qRm+LBFR++263IVBnMbyxzxLBYAARk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OQdpXyyQSENwh2fY0BmQNrXRNGMPAhYOu5u61/9HV08ANcUwHZ0Vr2SO96LKmDUZ62Is/w0v8rfERlFAuckPTrvV/6MMWAyx7xttdDRqazZ+OqZXlqcKwRw5/cGHVGaLsfVSWxIMhzUKSWuzuwUL6rHxKyxRLWaeC6yuSRYoJ4o= 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=Jn6ujqjp; arc=none smtp.client-ip=74.125.82.47 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="Jn6ujqjp" Received: by mail-dl1-f47.google.com with SMTP id a92af1059eb24-1363fe80fe8so7309007c88.0 for ; Mon, 22 Jun 2026 22:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782192245; x=1782797045; 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=zlgnE36nEB31kjx0F0SU25BmzIL5DnY8cGWLmeitAjk=; b=Jn6ujqjpE5EFgsR66Rd/oFS3lJIDKGT1zSiDxbvjKG01wr0RXfpzWl3+F9AMAyiJnr RILzT8YzUOjjRwkTg7fmlDZB6b7vFHxELQ0l1sBQ0N41DUYFWM6GLZGfTMO9Aq2Ae33P QykowD/ibgmDY80EhqSY6OmfsENI45tdAAIvNacwt/HtS5qsP4e663DSI4xyENg0u0Jw nkAh9x310Om0Us1lK0cRGWWu6WfeKtmtG5f42kbz9Pj/ZwJxTPFLq4Ag7jJNLBj1cW+D 09eimbQOuqU4pYeZGbVTRdIt9MSE/SsIUT8y6YudrB7f7Xu47D/Gp8bQEW7QoOWgLTdC oXiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782192245; x=1782797045; 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=zlgnE36nEB31kjx0F0SU25BmzIL5DnY8cGWLmeitAjk=; b=CBp71CLFf3l9y5iTEcbv41GFkKt/mWUf3i6uPmeAhJ0HXVxhEGbUNOBCwrUCVXJomT FR49z283zrTSXummnXknUoTLyU09x/UtZussxm2rciQ5m44SFofP0EJ3IwnxsPA0s1jL 6w+DIbwwr4jjBcbpiKG5aR/I3e0FsMX7lVT5VXfcMRh6Og7ADKOx7rrKwDgsNeZaE5zs rkaRIfkSupW4Qr1MAC7s99K4uDZ+vOO2ok8FlGMFzvUY7bTbrVwvoVSBNcfeXcQ6E2FH zLIc0GOlOm6g+w7s5sZOMPZ0VhVRDS/HzSFVcUSyBBJcCpn/hJBC0ht6q0AZ3oqhGjzs EE3w== X-Forwarded-Encrypted: i=1; AFNElJ+BcArtPNn22L653AAQq0+lEKS2lvyyseHxWs6Zz9B9mq62ZuUYI0Au+rIBVvtpiKtenqhxPLq86ls77qc=@vger.kernel.org X-Gm-Message-State: AOJu0YxELxfwECqwU3WNrXqYurfZ4+5E+WxMNIwL6kQRZ3Rx3q9A/iV2 /jbGxuxUzuY2vBkrhD3ZMMqf4Ea1te6gGNnDBSlZ0PaMPOAAtOcS0/5r X-Gm-Gg: AfdE7cncbm1AyVdoouMSwpgmGTbgJBKu//j2P1z5WFISzLNbGgYpcYMZL4MB2mKqcyp YL/7miUNxliu8ub/o76wMf1XVSObkGkGdJax3aYLuyV+O14AQcGhPQpTV2a4Go4Ici2zvnIuDri P4XSu9uWV+df8ky0aF+YVQgxAvjA0Hm4YeczJTWXaEMaFBYsfMT4kE3MkGVj2cwtyRVsf+P0T7Y vTLlKq2kbV7QMXKd7c1JiqVJ+/3Pnoo9oGQWAu4uIdhWw1kvmUBhY9VmcFY8dM3Y40udpBUVn1t azcwQB1Y5zUlTdiuJ9z6qPDFIznVNlPFZHZ0KmSPb8lQY/jov8HpuYjf8tpEufdxPzXd+HLJI4A OGKtoQ04gwNIFyFDmQJaETY3grBtfd8hU7upKH0LgrwxzynAOGVZVvljl01g26YOOlXF3IjEbTU /q1eELOuYwOZw3v16GQCiiZ6E8srUCubNiUmKCAt3de3Ou5ScZUvdUMQ== X-Received: by 2002:a05:7022:6093:b0:136:ff02:d00b with SMTP id a92af1059eb24-139a38806e9mr10415016c88.25.1782192245424; Mon, 22 Jun 2026 22:24:05 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:7d8d:3bdf:d563:1911]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-139adca1b00sm10508406c88.2.2026.06.22.22.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 22:24:04 -0700 (PDT) Date: Mon, 22 Jun 2026 22:24:01 -0700 From: Dmitry Torokhov To: Wolfram Sang Cc: Wolfram Sang , itewqq , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Bryam Vargas Subject: Re: [PATCH] i2c: smbus: make i2c_smbus_read_block_data() safer Message-ID: References: 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 Thu, Oct 17, 2024 at 05:28:48PM -0700, Dmitry Torokhov wrote: > i2c_smbus_read_block_data() is dangerous to use because it may deliver > up to I2C_SMBUS_BLOCK_MAX (32) bytes, which may be surprising to the > caller. Callers tend to allocate buffers of sizes big enough to hold > data from a well-behaving device and do not expect that > i2c_smbus_read_block_data() may attempt to write more data than > expected. > > To make i2c_smbus_read_block_data() safer to use change it so that > it accepts size of the supplied buffer as another argument and ensure > that it will not copy more data than the size of the buffer. > > To allow users to gradually transition to the new API employ some > macro trickery allowing calling i2c_smbus_read_block_data() with either > 3 or 4 arguments. When called with 3 arguments it is assumed that > the buffer size is I2C_SMBUS_BLOCK_MAX bytes. Once everyone is > transitioned to the 4 argument form the macros should be removed. > > Signed-off-by: Dmitry Torokhov Wolfram, any chance we could get this in? I am getting patches for OOB access because of the unexpected behavior and I'd like to fix them without doing extra memcpy(). Thanks. -- Dmitry