From patchwork Sat Jul 8 16:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Shurong X-Patchwork-Id: 700763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF144EB64DA for ; Sat, 8 Jul 2023 16:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbjGHQC2 (ORCPT ); Sat, 8 Jul 2023 12:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjGHQC1 (ORCPT ); Sat, 8 Jul 2023 12:02:27 -0400 X-Greylist: delayed 2289 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 08 Jul 2023 09:02:25 PDT Received: from out203-205-251-80.mail.qq.com (out203-205-251-80.mail.qq.com [203.205.251.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F08A1B9; Sat, 8 Jul 2023 09:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1688832143; bh=BA1iN7Rl5xAhdeMCiTPReGHnDwGFaZmO5OqvBbRDsxI=; h=From:To:Cc:Subject:Date; b=wFQ9PKVMQx+QvQAmdMiOOdf0ZI4CG934RALerVBXY7b4hXODaoOHQr4BlEa0R4CjE ZhIsSGOZLPS05Kq1ttSqeV5CKjv8W2q/OlPyhpstFtJnPC9WDxFj7YIUHpHf06Q+2d FxQHKQmyQ7J+OdhjGfpoYPiP5F68mpdU+Bz5BWOg= Received: from KernelDevBox.byted.org ([180.184.51.70]) by newxmesmtplogicsvrszc2-0.qq.com (NewEsmtp) with SMTP id 95158D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ayW0k7Dfu9xEO21b6MFM/kVQTgxXNgngzpQ== X-QQ-XMRINFO: NI4Ajvh11aEj8Xl/2s1/T8w= From: Zhang Shurong To: crope@iki.fi Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Shurong Subject: [PATCH] media: anysee: fix null-ptr-deref in anysee_master_xfer Date: Sun, 9 Jul 2023 00:02:20 +0800 X-OQ-MSGID: <20230708160220.3755131-1-zhang_shurong@foxmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In anysee_master_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach anysee_master_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash. Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()") Signed-off-by: Zhang Shurong --- drivers/media/usb/dvb-usb-v2/anysee.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c index aa45b5d263f6..12c16f09a808 100644 --- a/drivers/media/usb/dvb-usb-v2/anysee.c +++ b/drivers/media/usb/dvb-usb-v2/anysee.c @@ -202,7 +202,7 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, while (i < num) { if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { - if (msg[i].len > 2 || msg[i+1].len > 60) { + if (msg[i].len != 2 || msg[i+1].len > 60) { ret = -EOPNOTSUPP; break; }