From owner-freebsd-current@freebsd.org Sun Sep 22 00:44:11 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3B0AEB8F0 for ; Sun, 22 Sep 2019 00:44:11 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46bTGy4wGRz4801 for ; Sun, 22 Sep 2019 00:44:10 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-qt1-x833.google.com with SMTP id r5so13139668qtd.0 for ; Sat, 21 Sep 2019 17:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Q89rC283m/VhlPtWeBidUOffL9uoyXNOAvPpFTBpIz8=; b=FJ2RtTdgdzBFaqfRBn7KX4Wskwcs8eHmWKYrgq1/ejCL32XFJC5UONYUzz9mThm0qK HzijUuWi2OPUIVKB3hHmWxXBiA3VYV+VE6pFxqsT2XTCiH/vwleVSrtog2Mwusc8E5lF 6wwhuKMEsq45TDZirSeuLfVi49QeXc6KYz1EePZtz19ydIL8E0oWYD+gupV2KDSC2AKH RWzXDJKCZbOPPZ2cfGQxjcVOrv78UPVoAkI9JHEVaH8p3ZRvIbhAuMWwmC529wfLGspB X9izYBOJaiS6aRxEvL6Q/JO2+QHbzovSMvS/WCQ8OE3BJ6iTPpO5GE1npyVAMHSdRrZu 8EPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Q89rC283m/VhlPtWeBidUOffL9uoyXNOAvPpFTBpIz8=; b=PQ0Ll3KZs9ptpBI+pqSsQdiuaGoY8iwSZk6JvUGRMxv6eLA5LBjBNXHrhTIZFqDht8 gSdhdzWZEwFCKP90TouPEGxqWRr6bXGpQc42F0in4FOrqE255u4ShkzvuZisr98hUV9n qQ8CIz8hqfw5LdouaOgFpuOTCAIEIzWor+mVe9jwXe6htdOjxIXhDpZR4ja4CwVn15dv +s/achfkpbcGNhpkLdNmbNiHBG2ILqxkkZJwoqt0xEYOtJNs6DbifSoTqeh4UjKEkjj/ XOCAV0FVrxu0N86pAvkWfH+fDotf8b4HyptwxgIDksGnk3piJ7kSTpReVzJwYmUyN/r+ WSUQ== X-Gm-Message-State: APjAAAUusVGfEBSxWTA5RRHRdBOxDj5hU2x4v4tou9ntLVyI0ZksjF8Q Jqdebul6wtBY6gN0UisgW6Y7KLIy2X6nemaQoMjkokTS X-Google-Smtp-Source: APXvYqyCkMJwmwyaz7iVZ4+qQ39ZYhU4vYGNTfoNVSZBnhXYcnfv8sWM+dfDbTbwR5Av6dnNf++XGc8nnNtE6PgD/Mo= X-Received: by 2002:ac8:51:: with SMTP id i17mr10918363qtg.283.1569113049027; Sat, 21 Sep 2019 17:44:09 -0700 (PDT) MIME-Version: 1.0 From: Ryan Stone Date: Sat, 21 Sep 2019 20:43:58 -0400 Message-ID: Subject: ktrace/kdump give incorrect message on unlinkat() failure due to capabilities To: FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46bTGy4wGRz4801 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=FJ2RtTdg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rysto32@gmail.com designates 2607:f8b0:4864:20::833 as permitted sender) smtp.mailfrom=rysto32@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(0.00)[ip: (-9.31), ipnet: 2607:f8b0::/32(-2.64), asn: 15169(-2.20), country: US(-0.05)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[3.3.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Sep 2019 00:44:11 -0000 I have written a short test program that runs unlinkat(2) in capability mode and fails due to not having the write capabilities: https://people.freebsd.org/~rstone/src/unlink.c If I run the binary under ktrace and look at the kdump output, it gives the following incorrect output: 43775 unlink CALL unlinkat(0x3,0x7fffffffe995,0) 43775 unlink NAMI "from.QAUlAA0" 43775 unlink CAP operation requires CAP_LOOKUP, descriptor holds CAP_LOOKUP 43775 unlink RET unlinkat -1 errno 93 Capabilities insufficient The message should instead say that the operation requires CAP_UNLINKAT. Looking at sys/capsicum.h, I suspect that the problem is related to the strange definition of CAP_UNLINKAT: #define CAP_UNLINKAT (CAP_LOOKUP | 0x0000000010000000ULL) I have observed the same problem with renameat(2) and CAP_RENAMEAT_SOURCE and CAP_RENAMEAT_TARGET: https://people.freebsd.org/~rstone/src/rename.c