From owner-freebsd-bugs@FreeBSD.ORG Wed May 14 22:10:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CD88CAE5 for ; Wed, 14 May 2014 22:10:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A91482FCF for ; Wed, 14 May 2014 22:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4EMA00P049313 for ; Wed, 14 May 2014 22:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4EMA0Ua049307; Wed, 14 May 2014 22:10:00 GMT (envelope-from gnats) Resent-Date: Wed, 14 May 2014 22:10:00 GMT Resent-Message-Id: <201405142210.s4EMA0Ua049307@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 605E4A5C for ; Wed, 14 May 2014 22:04:19 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 327572F90 for ; Wed, 14 May 2014 22:04:19 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s4EM4Ip5088405 for ; Wed, 14 May 2014 22:04:18 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s4EM4Ihq088404; Wed, 14 May 2014 22:04:18 GMT (envelope-from nobody) Message-Id: <201405142204.s4EM4Ihq088404@cgiserv.freebsd.org> Date: Wed, 14 May 2014 22:04:18 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/189821: nice(3) on FreeBSD returns EACCES instead of EPERM when provided negative prio's; is not compatible with Linux/NetBSD/POSIX X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 22:10:01 -0000 >Number: 189821 >Category: kern >Synopsis: nice(3) on FreeBSD returns EACCES instead of EPERM when provided negative prio's; is not compatible with Linux/NetBSD/POSIX >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 14 22:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 11.0-CURRENT >Organization: n/a >Environment: >Description: The t_nice testcase from NetBSD fails when testing out negative priorities set with nice(3) because it's more or less a pass-through to setpriority(2). If one provides a negative priority to nice(3)/setpriority, it will return EACCES, not EPERM. Linux/NetBSD/POSIX requires EPERM (before fix): # kyua test t_nice t_nice:nice_err -> failed: /usr/src/lib/libc/tests/gen/t_nice.c:85: Expected errno 1, got 13, in nice(i) == -1 [0.006s] t_nice:nice_priority -> passed [0.022s] t_nice:nice_root -> passed [0.005s] t_nice:nice_thread -> passed [0.007s] 3/4 passed (1 failed) Committed action 42 After fix: # env LD_PRELOAD=/usr/obj/usr/src/lib/libc/libc.so.7 kyua test t_nice t_nice:nice_err -> passed [0.005s] t_nice:nice_priority -> passed [0.039s] t_nice:nice_root -> passed [0.006s] t_nice:nice_thread -> passed [0.007s] 4/4 passed (0 failed) Committed action 43 More discussion can be found here: https://github.com/yaneurabeya/freebsd/commit/0e07e7cd2d690af70a725cb869b4679d5d05cbc0#diff-414e52a1b185ec7b1c19140f302d99f8L82 >How-To-Repeat: % sudo /bin/sh sh % pw useradd notprivileged % cat > test_unprivileged_negative_priority_with_nice.c < #include #include #include #include int main(void) { if (geteuid() == 0) { printf("is root\n"); return (1); } assert(nice(-1) == -1); assert(errno == EPERM); return (0); } EOF % cc -o test_unprivileged_negative_priority_with_nice test_unprivileged_negative_priority_with_nice.c % sudo -u notprivileged ./test_unprivileged_negative_priority_with_nice % pw userdel notprivileged >Fix: See: https://github.com/yaneurabeya/freebsd/pull/6 >Release-Note: >Audit-Trail: >Unformatted: