Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp846012pja; Wed, 1 Apr 2020 09:44:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvRkvRIaxC8bnMANDvp0xAc96XtgLqpPAFg3ZSw7zhbUA1nsU4/FVvqb459kPHXO9WIELxd X-Received: by 2002:a9d:6303:: with SMTP id q3mr17977338otk.296.1585759498088; Wed, 01 Apr 2020 09:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585759498; cv=none; d=google.com; s=arc-20160816; b=wTdC8mHDfZ0uy5ZEnyYeGki9ALuiKu+h8yAWiEFFb26mQmP1zr5hO4ebxN9sg70v6u wJ440aicFi+gSJqXTNyqWWPj8qPZBMelKOsKaxicH7628FMP2i22nC89GC/IRGPWuufh DWBbvYgk2sL/+MpWuI3BuvniYK3u0qWGQyq+bJxDLKT5EW8TpG3ur13Mgr+RxBoLkwI5 QPhaUGHx84Ayf9HPyNpUpOiinUAu3yr5ElIARRWw6j+CC2IKd2bs7ufTioG/65qXNmaW J2rOdh4uyZlb1MWXCmzT7TJ0Ktn63uyn3hosAra7TPFqscxp+NSH37hCuOoe8/myZPRZ FiAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bFFBk4X40SynEYCByczcIKhft+Iw2SNP7YnXVEtnRKM=; b=FaIzsDyJTb+QU2Q88GAbO9U8yql+2LTYdwcArwnYqugRxdMMklZceRRVLPfZ75f1Ze oNPpqZ4FzrUWS/OHmN40mewLT+6uYoYm/QnCM5DLYv0rDgkTq2n4AV3NZ0yeZJNQ/Jfl tNkJMx8x96GD1ZNDfz1pWtl31fis+kui5gH7nsbBKsbj+2W5xZrNHNnp7GhJtA2I1Wlr EZ5OC0sfC9JALP7tQdZC4vVILVXbqChe46vhPiEqOZ7sId9oMZKN553zskLwBHWE08gw lvqm2+0YnoUxd9+aTI82kp04Lnss0YKbe1wleqH9J+99mGnMZObXnoxM8vO1E8gqov3v cSQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwPMGLjh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15si1033056oos.59.2020.04.01.09.44.45; Wed, 01 Apr 2020 09:44:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwPMGLjh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389439AbgDAQnG (ORCPT + 99 others); Wed, 1 Apr 2020 12:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:43802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgDAQnF (ORCPT ); Wed, 1 Apr 2020 12:43:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1BA74206F8; Wed, 1 Apr 2020 16:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759383; bh=7mfy4fSdxAxVX+fr5TtvWmNH7XNHRqCj0umSIz4FlwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwPMGLjh20LZGpJ3sSjvYAzFoCunczjHsCrzaKQ9KnQctxk5RCW6pT3lAErIcbjg1 5qSQ5+xm3jkQQPrBX7tw2vwr/0oxYPFE78OMH5ygHi+2HPcJW/OjfBNSbndtraEdqT y+mFLc2CJMgVt8BhmFD1kAb7BAV4GrxlfDayyghQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamal Hadi Salim , Jiri Pirko , John Fastabend , Cong Wang , "David S. Miller" , syzbot+f9b32aaacd60305d9687@syzkaller.appspotmail.com, syzbot+2f8c233f131943d6056d@syzkaller.appspotmail.com, syzbot+9c2df9fd5e9445b74e01@syzkaller.appspotmail.com Subject: [PATCH 4.14 062/148] net_sched: cls_route: remove the right filter from hashtable Date: Wed, 1 Apr 2020 18:17:34 +0200 Message-Id: <20200401161559.395807151@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit ef299cc3fa1a9e1288665a9fdc8bff55629fd359 ] route4_change() allocates a new filter and copies values from the old one. After the new filter is inserted into the hash table, the old filter should be removed and freed, as the final step of the update. However, the current code mistakenly removes the new one. This looks apparently wrong to me, and it causes double "free" and use-after-free too, as reported by syzbot. Reported-and-tested-by: syzbot+f9b32aaacd60305d9687@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+2f8c233f131943d6056d@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+9c2df9fd5e9445b74e01@syzkaller.appspotmail.com Fixes: 1109c00547fc ("net: sched: RCU cls_route") Cc: Jamal Hadi Salim Cc: Jiri Pirko Cc: John Fastabend Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_route.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -539,8 +539,8 @@ static int route4_change(struct net *net fp = &b->ht[h]; for (pfp = rtnl_dereference(*fp); pfp; fp = &pfp->next, pfp = rtnl_dereference(*fp)) { - if (pfp == f) { - *fp = f->next; + if (pfp == fold) { + rcu_assign_pointer(*fp, fold->next); break; } }