From owner-svn-src-head@freebsd.org Thu Feb 25 07:54:28 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 83D7AAB3F14; Thu, 25 Feb 2016 07:54:28 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-yw0-f172.google.com (mail-yw0-f172.google.com [209.85.161.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E294D47; Thu, 25 Feb 2016 07:54:27 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-yw0-f172.google.com with SMTP id e63so36467450ywc.3; Wed, 24 Feb 2016 23:54:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=sXG9uxo3mMSmhaRFXpiwGADjMO1SCJtPEvko5/up624=; b=Zjt0KP4IxrY2tfY9dtWrhHGIbjiAuid6wIr4C7C4cq+J1tUmkCs+TapxfwALMtcLnx Fh2waTCEKP9jyePmTFJJCIFeA+vY2qJVgzAjAXiKcUAKw1a71nqaFF7JI3+mMXRpbHLN 0S2bT5hx6YD8HMBmugigc+4QyEUFeYPolOXQbCaShezll7zYqjA38UrtQBOQQ1EAQEda JPmyIfqpzlwMX9WYn4sdfX3JFGfiQaA/yXJFy+bxWT5pgmL8D6vNj3Ra2Rg2nWSZi+vf zHMOzpumpvrmT1fRkIddSX2G2sPMu6Nhv742Cd82qMZ+fSd1sYnBIRhSaTE+3opTOfXx QSdg== X-Gm-Message-State: AG10YOTjrdcLKb8XleO6YCAk5lzPk7bMmW1iMcHx0OAPhCiT1cJcZlZY5Zdf8s/GT7MHew== X-Received: by 10.129.75.197 with SMTP id y188mr24345174ywa.291.1456386476377; Wed, 24 Feb 2016 23:47:56 -0800 (PST) Received: from mail-yw0-f175.google.com (mail-yw0-f175.google.com. [209.85.161.175]) by smtp.gmail.com with ESMTPSA id g187sm5165895ywd.51.2016.02.24.23.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2016 23:47:56 -0800 (PST) Received: by mail-yw0-f175.google.com with SMTP id e63so36372214ywc.3; Wed, 24 Feb 2016 23:47:55 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.129.105.3 with SMTP id e3mr22161692ywc.237.1456386475780; Wed, 24 Feb 2016 23:47:55 -0800 (PST) Reply-To: cem@FreeBSD.org Received: by 10.37.115.82 with HTTP; Wed, 24 Feb 2016 23:47:55 -0800 (PST) In-Reply-To: References: <201602250733.u1P7Xxoh041746@repo.freebsd.org> Date: Wed, 24 Feb 2016 23:47:55 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r296025 - head/sys/netpfil/pf From: Conrad Meyer To: Adrian Chadd Cc: Kristof Provost , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2016 07:54:28 -0000 On Wed, Feb 24, 2016 at 11:41 PM, Adrian Chadd wrote: > .. what's capping totlen so one doesn't run out of memory? There was a DoS vector before (user controlled io->pfrio_size) and basically the same DoS vector now (either of io->pfrio_size or io->pfrio_size2). This change isn't a regression. Still, it should be fixed. Best, Conrad > On 24 February 2016 at 23:33, Kristof Provost wrote: >> ... >> Modified: head/sys/netpfil/pf/pf_ioctl.c >> ============================================================================== >> --- head/sys/netpfil/pf/pf_ioctl.c Thu Feb 25 07:03:10 2016 (r296024) >> +++ head/sys/netpfil/pf/pf_ioctl.c Thu Feb 25 07:33:59 2016 (r296025) >> @@ -2718,13 +2718,14 @@ DIOCCHANGEADDR_error: >> case DIOCRSETADDRS: { >> struct pfioc_table *io = (struct pfioc_table *)addr; >> struct pfr_addr *pfras; >> - size_t totlen; >> + size_t totlen, count; >> >> if (io->pfrio_esize != sizeof(struct pfr_addr)) { >> error = ENODEV; >> break; >> } >> - totlen = io->pfrio_size * sizeof(struct pfr_addr); >> + count = max(io->pfrio_size, io->pfrio_size2); >> + totlen = count * sizeof(struct pfr_addr); >> pfras = malloc(totlen, M_TEMP, M_WAITOK); >> error = copyin(io->pfrio_buffer, pfras, totlen); >> if (error) { >> >