Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7152892rwr; Tue, 2 May 2023 10:08:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79nH/iHhpro5+4A/kxXC/yyXT77r5TQNJFavblKTG7gq5pv55FxN/uWTbCQIlPhMBeZkQN X-Received: by 2002:a05:6a20:a5a8:b0:f0:ae73:c58a with SMTP id bc40-20020a056a20a5a800b000f0ae73c58amr19825085pzb.45.1683047335875; Tue, 02 May 2023 10:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683047335; cv=none; d=google.com; s=arc-20160816; b=V9raG5xoZddUNZWnNwwXg4OQhpEN+/vpHtnUtRPnS5XnwyMDN0zQOGTPb/Pb5tN0hd 8jeB/ZnA7kTTNtXQLFf4AnAUYullAwfP1s6D+2rpeaWdkmz/EjA43X4stNp8ERKjLhN6 ZZr3oeWvQ1n0v4AMkog2REbocY5SFntsoUyoUB0Zuk5vcKe1dpQxsmkSS9ZRqtRw3eOe tLcROXWaSBkfzfeQ90lNasOFQrK2N3s7/fz6keQs+rVyv7zpdmUIbwQg/Lslakh/dg72 osUorSsGP5YzfO2/2VbeQn4NL8FeM8npBYx4amwKYqL+O/M4GA/e87awSSmX2e52mQfP tc8A== 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=xbqdNl8h1rl6JFu/pYxFlGTf9KekIUwOgllFPNCblnU=; b=bJlaDVu+4RxPOWX7XcEzys4HANAJu02J9eNRTl3mD7LxjSWPgMH57Qqrd9zRG5yBDh 1kCm3gPaRN6Er+XfBHmYlQMkX9KHYH3ixD8HPi4VtfD31OHgBQQj5JCGlMTbRJFBCZVg ZVwpXyJ1mZ2cTsNvVOPxJwrVJl5XAudosE2olin/ydSHssBMSlxMJHn7IfEwvQMURCib nK+kJKHhUAjRqkCB9mwsg1hV8SQZIrEwzvV3/2ZJxuj5AR27g88gwmJT7/rZIK3QG5N8 70b6ybNz6lLBuhZyeChx/rKhlBR3ovP7j2fn2ZGSpA1ueZ+GDBifHrEhAzUB3aXqdd8B wldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=ZvF3GTNb; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a63f846000000b0051b58fc93b3si31138930pgj.223.2023.05.02.10.08.39; Tue, 02 May 2023 10:08:55 -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=@amazon.com header.s=amazon201209 header.b=ZvF3GTNb; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233977AbjEBRGK (ORCPT + 99 others); Tue, 2 May 2023 13:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbjEBRGJ (ORCPT ); Tue, 2 May 2023 13:06:09 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0996E79; Tue, 2 May 2023 10:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1683047149; x=1714583149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xbqdNl8h1rl6JFu/pYxFlGTf9KekIUwOgllFPNCblnU=; b=ZvF3GTNb/8Zw7xQivs8RTzmwNn8JgxZlxNgunOmP76DKr5Haz2qcrM7w xh3jDfxVFnHRj1qSaHxE4+KkZvh04oq9qugKeCbqumtRzKfFtL3k66MC0 hMEqOTWQ7NGFZAxjFS0p5oI4g8Nntt8efasdxhOEclHh9DR787HMj+r0l U=; X-IronPort-AV: E=Sophos;i="5.99,244,1677542400"; d="scan'208";a="210257010" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-7dc0ecf1.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2023 17:05:36 +0000 Received: from EX19MTAUWB002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-m6i4x-7dc0ecf1.us-east-1.amazon.com (Postfix) with ESMTPS id 10FC281CEB; Tue, 2 May 2023 17:05:29 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 2 May 2023 17:05:28 +0000 Received: from 88665a182662.ant.amazon.com (10.106.100.8) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 2 May 2023 17:05:25 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , , , , , Subject: Re: [PATCH net v2] sctp: fix a potential buffer overflow in sctp_sched_set_sched() Date: Tue, 2 May 2023 10:05:16 -0700 Message-ID: <20230502170516.39760-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230502130316.2680585-1-Ilia.Gavrilov@infotecs.ru> References: <20230502130316.2680585-1-Ilia.Gavrilov@infotecs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.106.100.8] X-ClientProxiedBy: EX19D031UWA002.ant.amazon.com (10.13.139.96) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR 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 From: Gavrilov Ilia Date: Tue, 2 May 2023 13:03:24 +0000 > The 'sched' index value must be checked before accessing an element > of the 'sctp_sched_ops' array. Otherwise, it can lead to buffer overflow. OOB access ? But it's not true because it does not happen in the first place. > > Note that it's harmless since the 'sched' parameter is checked before > calling 'sctp_sched_set_sched'. > > Found by InfoTeCS on behalf of Linux Verification Center > (linuxtesting.org) with SVACE. > > Fixes: 5bbbbe32a431 ("sctp: introduce stream scheduler foundations") > Reviewed-by: Simon Horman > Signed-off-by: Ilia.Gavrilov > --- > V2: > - Change the order of local variables > - Specify the target tree in the subject > net/sctp/stream_sched.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/net/sctp/stream_sched.c b/net/sctp/stream_sched.c > index 330067002deb..4d076a9b8592 100644 > --- a/net/sctp/stream_sched.c > +++ b/net/sctp/stream_sched.c > @@ -146,18 +146,19 @@ static void sctp_sched_free_sched(struct sctp_stream *stream) > int sctp_sched_set_sched(struct sctp_association *asoc, > enum sctp_sched_type sched) > { > - struct sctp_sched_ops *n = sctp_sched_ops[sched]; > struct sctp_sched_ops *old = asoc->outqueue.sched; > struct sctp_datamsg *msg = NULL; > + struct sctp_sched_ops *n; > struct sctp_chunk *ch; > int i, ret = 0; > > - if (old == n) > - return ret; > - > if (sched > SCTP_SS_MAX) > return -EINVAL; I'd just remove this check instead because the same test is done in the caller side, sctp_setsockopt_scheduler(), and this errno is never returned. This unnecessary test confuses a reader like sched could be over SCTP_SS_MAX here. Since the OOB access does not happen, I think this patch should go to net-next without the Fixes tag after the merge window. Thanks, Kuniyuki > > + n = sctp_sched_ops[sched]; > + if (old == n) > + return ret; > + > if (old) > sctp_sched_free_sched(&asoc->stream); > > -- > 2.30.2