From patchwork Thu Apr 15 23:17:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Du Cheng X-Patchwork-Id: 12206287 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A11AC433ED for ; Thu, 15 Apr 2021 23:17:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CE5F61131 for ; Thu, 15 Apr 2021 23:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236766AbhDOXSM (ORCPT ); Thu, 15 Apr 2021 19:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234735AbhDOXSM (ORCPT ); Thu, 15 Apr 2021 19:18:12 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD053C061574 for ; Thu, 15 Apr 2021 16:17:48 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id x21-20020a17090a5315b029012c4a622e4aso13562873pjh.2 for ; Thu, 15 Apr 2021 16:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2wP/QU0/zKQlRBFRQMpbxzixxwIL3kjPTqa4L7CrPMQ=; b=CrViFpiTiifoMjo+Wkz33IlK1rMzyweMfBcT69b7ChfG99FJX4OmVu0y32c+FkIxWv D/CFRui3h53E0ywSnUpVnUQTF7QBJyaixQh0kNOh+NDiOSa/ljxNOCVI+OdyR9ER0G2x W+OJai/3UYflHmP2pg/luXp82QJiWzENSfW1Zx4nkgsB2zqsysoYwas8spW7LKADrSv2 vzw/eAN6oncwn70LzkSjlQwWX+omgP+REsnpscaEXE3AkUxMrmiIghCsZxLmMhKQ7wPt zmyu950146UAQWhiYQq6qeN2oxeflalfeB3QKlDF8Ot7yPm8Cx8YiYIq+Q3a4HWz4ayN ae2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2wP/QU0/zKQlRBFRQMpbxzixxwIL3kjPTqa4L7CrPMQ=; b=a97dxtW4kZXIsbjFrvYiarTLeXZPRXtPCbjHl114GIRoFk1oWeyYuOptBbzgmT/U9H HUuaUYpkOffaEFL6wo7SoNUs56LzmHsjXp97l/VfJmH6lIBl1Tg8pbltoUMnbty0oGt4 a0dtuaBh7SBCbKoWNZQGHnJOw41+lZ1+/Yw7+vzU+viMDz8mNDS3qNYJGcX2J9zY8Wms cRxVfxaBEy+0gkhwyPepyW8hxVJDlCQhAqk1TYGF/ySL5fmKcIK9j85oUXFnskOV3yjH v6zX3BS3F5cSBc29XJSI7CJrb8sK6u0WwrjA+2zqz6IORxiccFp4NAoV+v1XywuMTaxS QcQA== X-Gm-Message-State: AOAM530JKXkqyeQ/zdO7pNVQiMpy6vlyE9FN+sZ7jqz1uic6lc9lLZTy unKMKMu2nWDeSZQGGMJ+FJg= X-Google-Smtp-Source: ABdhPJyMIEcapySXUtRIc2gQ8VyM9tCygk/vlcqVghz1mZFWpDP/NE2sQeq3qTN0lSdljKwXw1h0Cw== X-Received: by 2002:a17:90b:1198:: with SMTP id gk24mr6458448pjb.73.1618528668347; Thu, 15 Apr 2021 16:17:48 -0700 (PDT) Received: from nuc.wg.ducheng.me ([202.133.196.154]) by smtp.gmail.com with ESMTPSA id a6sm3225936pfc.61.2021.04.15.16.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 16:17:47 -0700 (PDT) From: Du Cheng To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: netdev@vger.kernel.org, Shuah Khan , Greg Kroah-Hartman , eric.dumazet@gmail.com, Du Cheng , syzbot+d50710fd0873a9c6b40c@syzkaller.appspotmail.com Subject: [PATCH v3] net: sched: tapr: prevent cycle_time == 0 in parse_taprio_schedule Date: Fri, 16 Apr 2021 07:17:42 +0800 Message-Id: <20210415231742.12952-1-ducheng2@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is a reproducible sequence from the userland that will trigger a WARN_ON() condition in taprio_get_start_time, which causes kernel to panic if configured as "panic_on_warn". Catch this during initialisation in parse_taprio_schedule to prevent this condition. Reported as bug on syzkaller: https://syzkaller.appspot.com/bug?extid=d50710fd0873a9c6b40c Reported-by: syzbot+d50710fd0873a9c6b40c@syzkaller.appspotmail.com Signed-off-by: Du Cheng --- changelog v1: Discussion https://lore.kernel.org/netdev/YHfwUmFODUHx8G5W@carbon/T/ v2: fix typo https://lore.kernel.org/netdev/20210415075953.83508-2-ducheng2@gmail.com/T/ v3: catch the condition in parse_taprio_schedule instead net/sched/sch_taprio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 8287894541e3..abd6b176383c 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -901,6 +901,10 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb, list_for_each_entry(entry, &new->entries, list) cycle = ktime_add_ns(cycle, entry->interval); + + if (!cycle) + return -EINVAL; + new->cycle_time = cycle; }