Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp2930798rwl; Sat, 5 Nov 2022 14:17:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5PqreWvbPax55LAw1xQdk9xlIX4tbF8MihsApv9UFv9vxe1ab9tmA+EQK/8oPCyHsI8T5s X-Received: by 2002:a63:77c4:0:b0:438:6d6d:70ba with SMTP id s187-20020a6377c4000000b004386d6d70bamr562053pgc.198.1667683034308; Sat, 05 Nov 2022 14:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667683034; cv=none; d=google.com; s=arc-20160816; b=yk+VO+I/jnDxFnJAeQD4MHNZzjFOIBSk693kSTfo1sp+1DE8+ExgNshQP26Vp9wPwl OUkxzVWCfk5PJXJj02v4PLAIlWN2/2e7xcJo9z9/yvWo09/sD1M8wq5OUHa/K/KG3pvM E9xC+UaJnMcakVc4aIY2VWEuSXHwk8JS8Yw+OzAKk4YGBuq/lbih2eFy6PltjyxjXkWH jrqJLMg+OuRUAm3Mhot0b4ETbr2SPME2K1HBDe9Zss/4+QvCIEmzPbK8H1uwVOx5ZGT4 cnmTxUiBOJmj60AvM7fiSeBVEQGd+GexqIn6dtUP0pO+axqI5y/AQKv3QRGQuGq/ArhB WpCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LiMUaNhBUJOR9OA8ZtBEVhMz3WyIU1kHl60F6lstO3A=; b=mfI4mvKAr0t9KGDGJe3JgjD7eFXlomytQd8dK+VC1VWjtdr4ZaZLPwEZxV1W9o9pLE DPNEzwhISadROWqQhqt7autmRbUloPt4aevT0iSAp6YkS6Jv8TNcV5oXa5aWVI84a5pT gPF9tlJR9CfzmZ6JJY3XQEeBavWVayeIgIJY7GzmMgzPmPEChowgoFt6I+UKZCGDKOk5 hFT6RNYHWRLix4wUKVH5x6Sj1lO9YWAKCBtda4AuaPdxFao9geu4r9iRYATpI5ZLRLnC JABTcymLdgZsMBJx8N8gGWaEibN5V0tySKbketBAKpwsTZDtcgPqjlHasfWPOQ54QZ9a foDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H8kCc5kN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a63500d000000b0046ea4ef43ffsi4686820pgb.375.2022.11.05.14.17.00; Sat, 05 Nov 2022 14:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H8kCc5kN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbiKEVOW (ORCPT + 97 others); Sat, 5 Nov 2022 17:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbiKEVNs (ORCPT ); Sat, 5 Nov 2022 17:13:48 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04D1B1408C; Sat, 5 Nov 2022 14:13:43 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id b2so21347788eja.6; Sat, 05 Nov 2022 14:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LiMUaNhBUJOR9OA8ZtBEVhMz3WyIU1kHl60F6lstO3A=; b=H8kCc5kNdiDaLwfV1szOsGC3FQvFMahJRrhpAgTYfawIDxtKT+Xp8X8ToVoz3iouul q8Ojdb5ihW44WlIpYghJ8qKS2JT56hkBcBrKUHRUj/+jdqxzPp19jj9uJ0IGMjCVYRdV syjVZD2dH4UlAHF0SwuBJ4mzggx8/W5ab5Ht+PXqyy6SRiT1kpEWRe9nTwSanzOTgxhK 5tGmUSApfw2l8WIm0VoJoxib7NY7/R+mIzIka3YXX7xF/eUCsLywnyego0qC5OEftt1l vfLVfjjFrJlITzfVIMitnJm5/SJeiorgI2Ih0OuunsYZAlgV5+Ed0XauXRQeK3l+tm6r RErQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiMUaNhBUJOR9OA8ZtBEVhMz3WyIU1kHl60F6lstO3A=; b=8C4igtjOtQXqWz1A+l3YWyXphrai7GYTwzq1MhiquFFRsEnxuTS7gS2eEpvwNa+8xV Rpt9QYmCXGMkFLHSjAHeHkYTYYTBtveYIq7/01PvX7PmvG58vh1i+eH9fNjwqPXRe6Po fye05EXJYz2RakHd78aq3/5Enx3nGUWSrtUqUQszp6IfuC8HhZQi4darPoYbFSxMS/qp 8M7xGf+XFlmSjMPLbhNfkUZAoQckEOHBFh9tvaDUQmyMOA3oCVPKYTWmOxGW8OSNV7SY pRTFQpT6jrPfJB4CT1xhGoKcHYiIh0cfbypeCFFWTCXLRMDE8bw2gIoePjNqHCCesiHL TWGw== X-Gm-Message-State: ACrzQf2Xgn3mygNQir76pyWgXnrXAZyqTm1Uy4ZcYhxA/E1hwfhuOmH+ iw743D3KMIAsXOwVY/4TKoM= X-Received: by 2002:a17:906:8a6c:b0:7a8:2f09:d88d with SMTP id hy12-20020a1709068a6c00b007a82f09d88dmr40191568ejc.49.1667682821568; Sat, 05 Nov 2022 14:13:41 -0700 (PDT) Received: from michael-VirtualBox.. (89-138-220-136.bb.netvision.net.il. [89.138.220.136]) by smtp.googlemail.com with ESMTPSA id ta19-20020a1709078c1300b0073d796a1043sm1323502ejc.123.2022.11.05.14.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 14:13:41 -0700 (PDT) From: Michael Zaidman To: jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Enrik.Berkhan@inka.de, Michael Zaidman Subject: [PATCH v4 11/13] HID: ft260: fix a NULL pointer dereference in ft260_i2c_write Date: Sat, 5 Nov 2022 23:11:49 +0200 Message-Id: <20221105211151.7094-12-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221105211151.7094-1-michael.zaidman@gmail.com> References: <20221105211151.7094-1-michael.zaidman@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The zero-length passed into the ft260_i2c_write() triggered the NULL pointer dereference in the debug message on data[0] access. Since the controller does not support a write of zero length, let's not allow it. Before: $ sudo i2ctransfer -y 13 w0@0x51 Killed After: $ sudo i2ctransfer -y 13 w0@0x51 Error: Sending messages failed: Invalid argument Reported-by: Enrik Berkhan Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index ac133980dfe9..b4f180c8750a 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -409,6 +409,9 @@ static int ft260_i2c_write(struct ft260_device *dev, u8 addr, u8 *data, struct ft260_i2c_write_request_report *rep = (struct ft260_i2c_write_request_report *)dev->write_buf; + if (len < 1) + return -EINVAL; + rep->flag = FT260_FLAG_START; do { -- 2.34.1