Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7264895imm; Tue, 28 Aug 2018 09:01:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ8q1511krBpe16cxNvsinhSe5UvKD1FIMdOugDLt1SDTeVTyE3xBhFpJyTQCc1tI6ltGE6 X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr2181636plp.18.1535472070187; Tue, 28 Aug 2018 09:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535472070; cv=none; d=google.com; s=arc-20160816; b=LiOfS3lrW1qDN6UdoC/yzmQ68D32F2sURH3Bn4+mk0hDLadJJAFTuJnCNwFWEy4DuJ DJ8QyLmE403RpfX9BI0jjfJSYlF4zSdZ4P5+1I8/PqTxIST7+Irvrykxf8qYoJQNDSqX r5iMYFOZi4OqHaEUsbjNgq5OeOGtEB1GGTygxKC6LbR76vXt4ZHOX8ysQcxYcFk3OF5C lpzSV1mlqY+rbixB/mIPG59PCxIgE8dDkAi8WrBFOTAxgh1a9lGZ94AMJ0DcA+gs71sB 97kdi5lWWTNSaoF1jfeGMgV5pwGwNNWrFLLjKAWJDQqF6Mqoj1PoK3Ct0342kx/JOjv3 vIFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=nLPXD9ghxQKVJvoK221ib8DwteLjwTrdpKQoG1p0Kjc=; b=GYIkp8PaPIEZRkP3SvIGqhbACVylMu3Q8KKq1rRBxbdz/B14RnLyE3EeClx1U1zIYz eGVHyLJp9MOdU6DGJZEY/9ticO1L4l3o7NFSz+fMpTLRJSgG0MbTvZXE8Rq9FYTupM4M sCL6ghc8u1xP1KUIK5+hVBHrbYCL5ULruB7wSm0kvVhbxJBHqmhvHjKdEUROw8o46+/V wmGt4ffEiwcwfiOUpA3fTHsdZo52FePF0BoRVb/1VVHIG7PNYr7qA21aTItZzwIgPwpV kmOUd9ASqNZZcem9PmgIx4bAWZd2IqNharJnv3YT/7K9fMCmGsZ7+thjseTreH8oh8A6 IffA== ARC-Authentication-Results: i=1; mx.google.com; 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 w17-v6si1259818plp.335.2018.08.28.09.00.54; Tue, 28 Aug 2018 09:01:10 -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; 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 S1727388AbeH1TwC (ORCPT + 99 others); Tue, 28 Aug 2018 15:52:02 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:58656 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727112AbeH1TwB (ORCPT ); Tue, 28 Aug 2018 15:52:01 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fugP4-0002jR-RF; Tue, 28 Aug 2018 15:59:38 +0000 Date: Tue, 28 Aug 2018 16:59:38 +0100 From: Al Viro To: Cong Wang Cc: Jamal Hadi Salim , Kees Cook , LKML , Jiri Pirko , David Miller , Linux Kernel Network Developers Subject: Re: [PATCH] net: sched: Fix memory exposure from short TCA_U32_SEL Message-ID: <20180828155938.GF6515@ZenIV.linux.org.uk> References: <20180826055801.GA42063@beast> <20180826061534.GT6515@ZenIV.linux.org.uk> <20180826173236.GU6515@ZenIV.linux.org.uk> <20180826225749.GY6515@ZenIV.linux.org.uk> <20180828000310.GE6515@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180828000310.GE6515@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 28, 2018 at 01:03:10AM +0100, Al Viro wrote: > if (tcf_exts_get_net(&n->exts)) > tcf_queue_work(&n->rwork, u32_delete_key_freepf_work); > else > u32_destroy_key(n->tp, n, true); > ... and we hit u32_destroy_key(, , true), which does Speaking of which, we'd better never hit that branch for other reasons - there's no RCU delay between removal of knode from the hash chain and its kfree(). tcf_queue_work() does guarantee such delay (by use of queue_rcu_work()), direct call doesn't... Anyway, whichever branch is taken, the memory corruption problem remains - the comments below are accurate, AFAICS. > Incidentally, if we hit > tcf_queue_work(&n->rwork, u32_delete_key_freepf_work); > instead of u32_destroy_key(), the things don't seem to be any better - we > won't do anything to until rtnl is dropped, so u32_destroy() won't > break on the second pass through the loop - it'll free there and > return. Setting us up for trouble, since when u32_delete_key_freepf_work() > finally gets to u32_destroy_key() we'll have ->ht_down pointing > to freed memory and decrementing its contents...