Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2184737iof; Tue, 7 Jun 2022 22:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt0di/uEm3MhsQ6pjU3asaI/7GZumOP6cpO5DWxM5YxXSeUl/0+oaWklRnqoMB8/OCo0i4 X-Received: by 2002:a17:90a:5409:b0:1e8:664e:41dd with SMTP id z9-20020a17090a540900b001e8664e41ddmr19922168pjh.173.1654666239330; Tue, 07 Jun 2022 22:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666239; cv=none; d=google.com; s=arc-20160816; b=tN6DJ9a/K3eyvZXCoMsVCS7rochUDPIEEidAN0BPe5kOWe0KinK6rmXKy7jR4aHW3k 7/wUKcwqQe8kmP1i2YnsjaK4+ba0UOgFaNDEgudzLjg8I1MBUrMUUithl/pLecgqWfGh QUsSYm7UWZ+6l77GFKv+6hUDAxXhB3Gbyw91MQSRLJXmux1z6g4TFlW09yhT6NnE658Y rkD4HDJewvinGepg6BqvSsu6F11MG8vrqNpxHqX2QcRZEe2ceDcF7rQ3Ycx9VnzHKNr8 yaqOut7slHAhKVEopYYEh98Ql4WXX1OP1gzogLCJhaMJQW/3Df9uHHmIAm5GRy0I5v8B 76yQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NR+mzzp4tsojyxurtM5E60aYa6/V+v0QEMg/Cb5ouzc=; b=WuhNp8k7QsGyoMtWXltakJzdQNm5+xFkzzD3M7BULpJgEeE6Nm4KlfT6ZMEhEF1LDm pAazZjkOyze/SSpxw6HSeSrWMHhyZbADSIS1n1enkNNYMOrGsMROtX3Rzp0NYBPJUnWa pz4CMQBYV27slqxa/BSF1AoyMgEhbNUfeuwcaYImSrElmIX9oRsuXi0RgL70no8jyXum 9O/1MPiyoODjtNDpH/flwd1pUUm8NJgOR3WD+R215oVFwJ0aeqJz16lsfSde+HePjOP6 NprzI6/A4mTzENOS9tcCjat7qY+IsvF6tG+kjhmC3hAdTapYLsgOBeR7dNQuKSWn0kIf tZ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=saI9Iqda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id jf13-20020a170903268d00b0016370e98895si26625270plb.244.2022.06.07.22.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:30:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=saI9Iqda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC73348BD1F; Tue, 7 Jun 2022 21:57:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386244AbiFGWsm (ORCPT + 99 others); Tue, 7 Jun 2022 18:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381273AbiFGVkX (ORCPT ); Tue, 7 Jun 2022 17:40:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72229D246B; Tue, 7 Jun 2022 12:06:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A88FB617DA; Tue, 7 Jun 2022 19:06:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3F5EC385A2; Tue, 7 Jun 2022 19:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628764; bh=yKK7k0M0r6ya0Q01dbp5puq55CSX9bPhZH3Pqas7Iw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=saI9Iqda+o2/6hkPJDEKTFBYjF816vtI+qV/4iBF8M4sLArdQmmeHxZqsrHuES52c hQ/p1a1Dq9Z803xXB+0GtcgMJe3bC9iNRU25zLDh1KJcEK1c+PE9gKSqI9y5DZCuLz Fa2PAssPxmv3uV6ewZjJBWai2oHXZipYTfKrh6Vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , syzbot+1a247e36149ffd709a9b@syzkaller.appspotmail.com Subject: [PATCH 5.18 446/879] media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init Date: Tue, 7 Jun 2022 18:59:24 +0200 Message-Id: <20220607165015.817223140@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Pavel Skripkin [ Upstream commit 471bec68457aaf981add77b4f590d65dd7da1059 ] Syzbot reported that -1 is used as array index. The problem was in missing validation check. hdw->unit_number is initialized with -1 and then if init table walk fails this value remains unchanged. Since code blindly uses this member for array indexing adding sanity check is the easiest fix for that. hdw->workpoll initialization moved upper to prevent warning in __flush_work. Reported-and-tested-by: syzbot+1a247e36149ffd709a9b@syzkaller.appspotmail.com Fixes: d855497edbfb ("V4L/DVB (4228a): pvrusb2 to kernel 2.6.18") Signed-off-by: Pavel Skripkin Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index cd7b118d5929..a9666373af6b 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -2569,6 +2569,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, } while (0); mutex_unlock(&pvr2_unit_mtx); + INIT_WORK(&hdw->workpoll, pvr2_hdw_worker_poll); + + if (hdw->unit_number == -1) + goto fail; + cnt1 = 0; cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); cnt1 += cnt2; @@ -2580,8 +2585,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; hdw->name[cnt1] = 0; - INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); - pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s", hdw->unit_number,hdw->name); -- 2.35.1