Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5328369ybi; Sat, 20 Jul 2019 17:28:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAUyw3ehs/BQ54jb2Tb0CnsUxpI5ABIqCZRXVf8lJmS1gSPQOLHBc952tlzsFxSXb/QEQj X-Received: by 2002:a65:448a:: with SMTP id l10mr38145609pgq.327.1563668897089; Sat, 20 Jul 2019 17:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563668897; cv=none; d=google.com; s=arc-20160816; b=IgtiBcc57dplHOnL7epMmjV+kWSyRjgDJrLEn46dI1XtsRceIV1IHtxaX0ojxEAGpA 21OTCl6d3FjGkIj+cgFAUfeQ1HySMRQqf+budSe565hKgkZeS6rnsVnsls1VaR9X+Vfl YjHnN7IcMGH1Ld/hGRMnqBVBvToWj1vPLKCBIJkoAJqSTdGYXbwO1ENYu0Lbb5mG948w 4x8WrftiUFZ59mdxw4GjKPS2xfj4gc2bGkfhCj8ASuiJdOZsb2DjakSHFXO6QRT0G3Mh XALmVWVffivPTZQc1hg5fQ7BkeTxcISYKntQScOL8nufbPp2fS7jIBL0JWTZh/z7EZAh GDtg== 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; bh=0TM+9Xj4ptFvQbloJca6at6ecTEM4ci2Dd+Gt5lOkKo=; b=ByvrgYfN7AOxo08N/oAJ9mlGqyRpIVN0nJaI+6tPA9UJQLoFgeFENWeaYoTNZtAWy2 2vR/k5ylcA1VbUD7Z2WAGLXFRIOCzyydg+6eehWifDBa/GqS6+fJFeNw+lc0fChlril5 pXnvkIO71nwUfFiafJsauGXAYsXp+4buIX3Z8bK6YXnZ11hNhv23UXfhc6Asrnla4mOG FcLjasxdtQk8TVrZkiRGz7hffY6XDv6W7191I6TOGzSHcnHmURAqpdP+bLVk62HrW9Wp NnWbxqk4GMdqBtgvemlgZl9t1K6YLRFeB2L7BWCCFLxHgnsQx/owPSE+PuPMCUdrigh1 rjqg== 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 v5si9786149pgs.285.2019.07.20.17.27.27; Sat, 20 Jul 2019 17:28:17 -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 S1726276AbfGUA0k (ORCPT + 99 others); Sat, 20 Jul 2019 20:26:40 -0400 Received: from Chamillionaire.breakpoint.cc ([193.142.43.52]:48930 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbfGUA0k (ORCPT ); Sat, 20 Jul 2019 20:26:40 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1hozgF-0001k4-W7; Sun, 21 Jul 2019 02:26:24 +0200 Date: Sun, 21 Jul 2019 02:26:23 +0200 From: Florian Westphal To: Wenwen Wang Cc: Wenwen Wang , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , "open list:NETFILTER" , "open list:NETFILTER" , "moderated list:ETHERNET BRIDGE" , "open list:ETHERNET BRIDGE" , open list Subject: Re: [PATCH] netfilter: ebtables: compat: fix a memory leak bug Message-ID: <20190721002623.27wac36rkwa5v5lg@breakpoint.cc> References: <1563625366-3602-1-git-send-email-wang6495@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1563625366-3602-1-git-send-email-wang6495@umn.edu> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wenwen Wang wrote: > From: Wenwen Wang > > In compat_do_replace(), a temporary buffer is allocated through vmalloc() > to hold entries copied from the user space. The buffer address is firstly > saved to 'newinfo->entries', and later on assigned to 'entries_tmp'. Then > the entries in this temporary buffer is copied to the internal kernel > structure through compat_copy_entries(). If this copy process fails, > compat_do_replace() should be terminated. However, the allocated temporary > buffer is not freed on this path, leading to a memory leak. > > To fix the bug, free the buffer before returning from compat_do_replace(). > > Signed-off-by: Wenwen Wang Reviewed-by: Florian Westphal