From owner-freebsd-arch@FreeBSD.ORG Tue Nov 13 19:46:12 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2CDB351 for ; Tue, 13 Nov 2012 19:46:12 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 277158FC14 for ; Tue, 13 Nov 2012 19:46:11 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id gg13so2679058lbb.13 for ; Tue, 13 Nov 2012 11:46:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=FeV55i27cAnUapNuu97uL63MrIJimePMl1n2FcMbfP4=; b=OEnwP4G1yBkqmsX1V2BIYoO/iM5bKUXCqxRJwcjJt0L4A2ZV+mjmHf+VP4MUAft1KK SaYm2/JVQTSaFfCfmtN1tlqbkfsn6rhoO9X9RzV20NcJdBHbOVqrdtQ+0dcWE3ge+yTc 3Rlvu95qNnPQQkq37TIL0RfJgfff9fWlGpw08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=FeV55i27cAnUapNuu97uL63MrIJimePMl1n2FcMbfP4=; b=KFnFOCNIS+9DO68SSU4M3tRy4CdG3CiCmFx2fwLyD7MhfQRz4W2KBLbTTKJjsPNYde bjKMQFQNRgcak3+6hgo9Gq+asvCHFh+/xxuRhAcYJerwaLh0O5hSQG50UD+uqWSNl97g 1VcN6BBoduIWQKL5H4wWGuTLWB7CH1T7EdUnl2hoLMqwM6cKGBWlpBv7jsqc5OYMS6Po 18eTFcuhe4DUp+SflJ663Z9rjUNMvfc8wJcPpfRq1OEN3XCU8cb6IZdW3s9hxm0v2Pns AvzaeqL9vDwtPn2XzQl5ruYaO1g5+OQivrY+xCbeG2Lj2/zbCIDFwJw/rXXUDLn45biI n4sQ== Received: by 10.112.85.199 with SMTP id j7mr9708238lbz.69.1352835971034; Tue, 13 Nov 2012 11:46:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.25.166 with HTTP; Tue, 13 Nov 2012 11:45:40 -0800 (PST) In-Reply-To: <20121113183412.GA75103@ithaqua.etoilebsd.net> References: <20121113111806.GE62533@ithaqua.etoilebsd.net> <20121113115034.GJ73505@kib.kiev.ua> <20121113183412.GA75103@ithaqua.etoilebsd.net> From: Eitan Adler Date: Tue, 13 Nov 2012 14:45:40 -0500 Message-ID: Subject: Re: Increasing MAXLOGNAME from 17 to 33 To: Baptiste Daroussin Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQnnjtmnfZcDDU4W2OvJwRfq74cGZb9CJ13PGMrvw9t7GsSHUrVkUfhMF7W70y5XbG2C3AR5 Cc: Konstantin Belousov , arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2012 19:46:12 -0000 On 13 November 2012 13:34, Baptiste Daroussin wrote: > On Tue, Nov 13, 2012 at 01:50:34PM +0200, Konstantin Belousov wrote: > > After auditing base, it seems like this patch is enough > http://people.freebsd.org/~bapt/maxlogname-33.diff I'm not sure, but doesn't access to p->p_session need to be under a lock? Something like (although the duplicate unlocking code is annoying): diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 53af793..8a97994 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2081,6 +2081,11 @@ sys_getlogin(struct thread *td, struct getlogin_args *uap) uap->namelen = MAXLOGNAME; PROC_LOCK(p); SESS_LOCK(p->p_session); + if (strlen(p->p_session->s_login) + 1 > uap->namelen) { + SESS_UNLOCK(p->p_session); + PROC_UNLOCK(p); + return (ERANGE); + } bcopy(p->p_session->s_login, login, uap->namelen); SESS_UNLOCK(p->p_session); PROC_UNLOCK(p); -- Eitan Adler