From owner-svn-src-all@freebsd.org Sat May 21 01:04:44 2016 Return-Path: Delivered-To: svn-src-all@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 36BA8B430E6; Sat, 21 May 2016 01:04:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) (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 F3E341C1F; Sat, 21 May 2016 01:04:43 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f180.google.com with SMTP id t40so70188454ioi.0; Fri, 20 May 2016 18:04:43 -0700 (PDT) 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; bh=NQYqncRcd+vuXZbm03D3fR67BqjvCM+o7ZcS7XpiNko=; b=Mn0UyGuS6OUx1xNC9cKyoD4i1Q0krFYAYmqSrAxzokKJz2OeAsdmISLLg+dIA4HSB9 znqEy7FEXapQDo4cEplmnjZnsQ6Ob9TNPkIYOdtuc8ebGhUhVqPPDI+Rt4y6CB5y86Py gvtdMPMGGPvq46oMbUI7RhDMYQcC139q9TV39YGHKUXLdE3mjvLdsSW4Faz8dpDSCEVg 2cxdQ9GwVX21V+tvEVjnbLNE4X9qaPdEY/M/kIAqoivOkLsL4X9w+b79H0UVs1/uT9dZ 5giziUsCE2H/sIbTF3ykG62u4LoNjkU+41bWJqm2fvmtPwRy8L5A9CM1XyQckEZATFpf IywQ== X-Gm-Message-State: AOPr4FUyli0qCxYhnkz9LAk1DU7PQYVEetJmM37+wLwxG9cbs+VmnO0txRZt4PKbCAz6Gw== X-Received: by 10.107.9.97 with SMTP id j94mr3681485ioi.50.1463788925649; Fri, 20 May 2016 17:02:05 -0700 (PDT) Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com. [209.85.213.176]) by smtp.gmail.com with ESMTPSA id u66sm179977itc.21.2016.05.20.17.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 May 2016 17:02:05 -0700 (PDT) Received: by mail-ig0-f176.google.com with SMTP id c3so397453igl.0; Fri, 20 May 2016 17:02:05 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.4.101 with SMTP id j5mr5234652igj.8.1463788924935; Fri, 20 May 2016 17:02:04 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.36.205.70 with HTTP; Fri, 20 May 2016 17:02:04 -0700 (PDT) In-Reply-To: <20160521081930.I1098@besplex.bde.org> References: <201605201950.u4KJoWA5028092@repo.freebsd.org> <20160521081930.I1098@besplex.bde.org> Date: Fri, 20 May 2016 17:02:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r300332 - in head/sys: amd64/amd64 i386/i386 From: Conrad Meyer To: Bruce Evans Cc: Konstantin Belousov , 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-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2016 01:04:44 -0000 On Fri, May 20, 2016 at 4:02 PM, Bruce Evans wrote: > On Fri, 20 May 2016, Konstantin Belousov wrote: > >> --- head/sys/i386/i386/sys_machdep.c Fri May 20 19:46:25 2016 >> (r300331) >> +++ head/sys/i386/i386/sys_machdep.c Fri May 20 19:50:32 2016 >> (r300332) >> @@ -315,8 +315,9 @@ i386_set_ioperm(td, uap) >> struct thread *td; >> struct i386_ioperm_args *uap; >> { >> - int i, error; >> char *iomap; >> + u_int i; >> + int error; >> >> if ((error = priv_check(td, PRIV_IO)) != 0) >> return (error); >> @@ -334,7 +335,8 @@ i386_set_ioperm(td, uap) >> return (error); >> iomap = (char *)td->td_pcb->pcb_ext->ext_iomap; >> >> - if (uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY) >> + if (uap->start > uap->start + uap->length || >> + uap->start + uap->length > IOPAGES * PAGE_SIZE * NBBY) >> return (EINVAL); >> >> for (i = uap->start; i < uap->start + uap->length; i++) { > > > I don't like using u_int for a small index. Why not? Indices are by definition non-negative so the fit seems natural. > After the bounds checking > fix, the range fits in a small signed integer. However, uap->start > and uap->length already use bad type u_int, so it is natural to keep > using that type. What's bad about it? Thanks, Conrad