From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8020444AB73 for ; Tue, 11 Aug 2026 20:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786480890; cv=none; b=V0oCQusUdGEtgpSZLQVBqxGb/HgNjQDjdWtLbY5pmJbTdFKAJModHqBI2bSJOpKVRrb8tLkgOD9qSeoox1Y5FvrvkUHQdgNF2VXu0t7B3Cvbzl5TS4uBh0BKY5+SKtDncyM6ftdQComYBr7ljQV6rnmLYocCe1FoPEsB3UgW7KI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786480890; c=relaxed/simple; bh=p2h9krMxZkoZc/3Sp+Bf7UgOmB7A/VM67RM5yQWAkTo=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uaJ4lMJKVIbY+8yienUkDuzL1QGmVYcqXxjOdxhYgPynvfwLclUOgLhMYA9mRYYmdrk0TY5imAFjoh89fNHWMAmRqc8RfRCmDF0mXf/qGroEyt4A/z79zYm0aj0Fomr8F9hwrrYMEX3ekrIOqYdpIsMbuSuUGPY4lu+n9R9fp/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=H6DzY8Yo; arc=none smtp.client-ip=209.85.215.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H6DzY8Yo" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cb835525b10so234774a12.2 for ; Tue, 11 Aug 2026 13:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786480888; x=1787085688; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HJ+kHjelH5pg9wQKl1OmAN9lbWOp3U72jOs17+JTkO0=; b=H6DzY8Yo6UYDicWd5kT3DeBZV3YQu9eVquU3hGXkinNgDFxzTXrLlK/lUsaAB6Zv3t f/O2EV1eY0Nos6s0GOxJ3k2RXkXALfdBpm8dlbJ1oRKnWfpF/Z+zfBKyHCTeecYyvvLW tPZr9pNypCQeMF5ihWTB7Wy8t3OtjZgDKeqzkI6YP/YyA3FJBjv8d7+LeKKaEW3S56Y0 cx2zXwU2Y/x3X/3LRfELzejMHb3k+8ug4FweGNt1HrhkGfhyhRYgz88BiRgd8NdtW35j wG8ckMdIapeM/k944b67DjtX4tVGWHIETGq9xM3Of+zVzSyBBEsAYHlT6qlTnhFnyPMr irfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786480888; x=1787085688; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HJ+kHjelH5pg9wQKl1OmAN9lbWOp3U72jOs17+JTkO0=; b=FkjMQmIBEyI+l3zjWjQAXvYlznG6FgEOUa2AphY9zy91wJTrR5Mf2+GD+/VgWAHyw1 f6Bc8JHVf/szJ9/ciOtMNONOfKHMiwhBe7c1ixffwwCb/JPgyLoewSznnLlGeWolbH77 KGdFusZM8hHg4gZdNsBQ5RWDpDluWV+8dWokXUwlXBJBOC2ZbeTinyP2NCw4v3mJGpmY WG8u6jX917Eq8rdx19qANEjGvi5Elj94M/3926fGJUMm77uKvZE337Ox7WtbaZAujmPM zctQ4p//qac/MeqMkxL36OCIvgcfuxyAzPkc+T1A7ZSb6wmq8P1vV3k3a1qgx+nEbLA7 RZmA== X-Forwarded-Encrypted: i=1; AHgh+Rpa/RJKc7myy3eFjSX4GSzK01fwcZVTxTGjRw6ccmEuuEEQEGrrJdgm0jnm1biY/v3xpy3iqss1eheIOkE=@vger.kernel.org X-Gm-Message-State: AOJu0YyP/P5KwmktGPNoGSJ/HKS2JPfFqv6a0oDJEx3Vo2u48uDn5Beh XUh1V9S+X686jfh0DKuAAP6EAzm5Nfan01L9HLzD48MkJovhiFDOgnm3x1btdi5qjDYPTfcYKlu +orlQS3atiPjvx0B8aw== X-Received: from pgvq11.prod.google.com ([2002:a65:624b:0:b0:c9b:f0c9:631a]) (user=tjmercier job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:bea6:b0:3c1:b9c:4890 with SMTP id adf61e73a8af0-3cc2ba60c41mr7899605637.22.1786480887687; Tue, 11 Aug 2026 13:41:27 -0700 (PDT) Date: Tue, 11 Aug 2026 13:41:23 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Message-ID: <20260811204123.3198370-1-tjmercier@google.com> Subject: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY From: "T.J. Mercier" To: sumit.semwal@linaro.org, benjamin.gaignard@collabora.com, Brian.Starkey@arm.com, jstultz@google.com, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Cc: christian.koenig@amd.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "T.J. Mercier" Content-Type: text/plain; charset="UTF-8" Write permissions on the /dev/dma_heap/* device files are not required to issue ioctls and allocate dmabufs. Applications should be opening these file as O_RDONLY. The BPF dmabuf_iter selftest already does this. [1] Users are pointing to these selftests as examples of how use dmabuf, and encountering permission errors on systems where write permissions are not available on /dev/dma_heap/*. Apply the principle of least privilege to selftests which open dmabuf heaps by removing the write access mode and using O_RDONLY for the open() instead. The same is true for the vgem test using /dev/dri/card. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49 Signed-off-by: T.J. Mercier --- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index fc9694fc4e89..45b420e37c97 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -48,7 +48,7 @@ static int open_vgem(void) snprintf(name, 80, "%s%u", drmstr, i); - fd = open(name, O_RDWR); + fd = open(name, O_RDONLY); if (fd < 0) continue; @@ -96,7 +96,7 @@ static int dmabuf_heap_open(char *name) if (ret < 0) ksft_exit_fail_msg("snprintf failed! %d\n", ret); - fd = open(buf, O_RDWR); + fd = open(buf, O_RDONLY); if (fd < 0) ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno)); base-commit: 9a11db68872055e6ead919bad04d6330851c522d -- 2.55.0.679.g6767b8d81c-goog