From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 67206400974 for ; Fri, 17 Jul 2026 16:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.53 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784305796; cv=pass; b=OD8gaIm1FYzPr/NSAmKy+VsXBNHKur9DRShxteywWfEbpXzn9VUMSMDb2RnFAF67NMFQ+lN3XVciv9yS0dIug5WaR7boyO5AYY45H8GQa+5rb/WvhL/wpBlHwgcqlT7dCocFUCflSsg3QT3nIywwS2bYYLJs6Ijyl2azeR8X4sg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784305796; c=relaxed/simple; bh=KEIvrRuiVrT7+dBXuaA0uQ4mV0n5hVwt+9ry5LaCeWc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WokWXr6XEEoUN5J0dMl5/wzWCTgFyFJLR/pplq/cVrg6gNDARtZWyY1cAif1TTok9+DMHG71VfOo4iqwYLeyjI5yCzO7g3XNw1U34xSYSEr2NAL+AlxUWtEiRO2h+qxSFbcWfAioJkDQyomj/VflS8z6CoT5XXjCIqxtlhKD8fE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=azzd97Uh; arc=pass smtp.client-ip=209.85.128.53 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="azzd97Uh" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-493b8d99342so69915e9.1 for ; Fri, 17 Jul 2026 09:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784305793; cv=none; d=google.com; s=arc-20260327; b=gfmsNi80jGhtzbc7JWn1Pgv0IlToilj2grzje1hP8jZ3KHOgAhJzbj+ZqrhyfQvsX7 wzwKEYmeIq0TId0WcHWyLvP0QQdCDCjDljOnTtBzqR2DSWCNTf1pkv/rOr/pxHIhLE2I nJ7lchBiBoC8wrCalJRTVs9qqcfdU4JnC+DDlHcyxgEZ0pZb2r2zUpj1UlC5gN5vx1qa koaomYJ6m6fvw4R3Y5oztleLQVvEHEjIuPUro+XTi493Eo6SAk23unjtR5JJM7D3UVoE vmjlq7nha/RWLy0XvFiPicvuNsX84TeonwyLJ+nG/l9KjKoXPSrMliIp2L6G8xvpjzM3 FkJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J1fiEC3LJWgMWiE+exeLjiuwsjKxQMa3Wx9AO5yvpjU=; fh=kgMactbft0Tg6A9j6xUgV9/b1N5XIOrGTsW45d41EIs=; b=lhl6OkrnpgX8ESvnqUsbQfMGCM4GMetVwE6cEF2o2eVZtmFXEx5ykz0RHZOxjdasql CydKqUR1uAwHi2yqiXzoMfZMcvi3veZ4ZWYpj9IVgh6mg84qcOxdUey4520gTIrczaDY MjpMM0n3yvxuKZFpfQmviuoXnQIA1cfDorIJ6A2StvBClCvamGTboJyr74Ga+An+C6Zh HP5PuodsWXIUU3ofpTLdVV+z8QWtecoFkKnYhCJQC4ISvxKdx85px08W9sl2aV6Qcswa GQ5PvNAIBvNjTTb0K09/pcKdssjU+FiV7RV0pE0zZsbL6DOeBhdU5qisX6pTplXiroMW yP/Q==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784305793; x=1784910593; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=J1fiEC3LJWgMWiE+exeLjiuwsjKxQMa3Wx9AO5yvpjU=; b=azzd97UhRk4GDudHUsml6PbuUSQ/8qXtL/v+QsrQ8C+U+JGlD4zoZZ9/EfcXrgPJ3I Fs/TE80q6YhRcj3REYloQtH/mRXRX1ifItzF2Ge8OwuZyTti4F3CCDYVv92jhXvXrPhd 48gLpFL9cxUn5jUtOk+0ocn3a66wjr5R3YcYdMPRaEyzAs2O3Yx5Kx90CuGaH00smq2f FaXDxS85tOUL8WuG3FFGeN3OvOl7g7mcBhzMDPSCMnAaEso9hb7vi/oqxx1GvtANZmJp rdAzN55SUo7rpwLMW1+L94jYxA+FR6URGmEwloPvZlJunWpdo4AMFpy5Omn8dv1CZQYz bZcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784305793; x=1784910593; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=J1fiEC3LJWgMWiE+exeLjiuwsjKxQMa3Wx9AO5yvpjU=; b=YzvHzjIbgO117ddXDYwYtuRw9sxsPp4ppz3CguxGv+MFJZRRP58lDIVdEbDgtVv22t ah3ci2/yR8O8qZqP+rkZaq/xal/j7S4YWSRyH8ErVa/J5UxX1Z+PWFXWBVYdpkEsNtr9 sduqcixO0Vydan6dgAb7mR91KQhBjt7WeQbhjCTQ/YSIoHGkJGtEaCXJQvmP7a2WjXrp h5D+smSY7Nf+o22zDMDl3Ob7k8G2s/0mM2E7Ac0H7TBPD9Z23aIUQF3INvJDYgLdHTgQ TQGTHgKTI5S3sJwqSxc/CQU0yk4IWSQgzm3vtGfszFwfXaLxcP8OLVQOSvkLhBdf+U7c uQMg== X-Forwarded-Encrypted: i=1; AHgh+RrVOZCuHmKUz90RA4o5Va7GKCUFmWmhjJqTJJgsUJWgfPoocV+Gc2G0jobjPAa+z2Rypw1exg3SQGOUq5A=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5Q8HUfD66p51hlWnFQLu9WFx6U25bD2YDIopLmB7o5DxHLoxv yEoDNjAEmXQUGCMOK60lEe/Hq7NtR2UF5XBz5MI4KTk0EERar8nAiu4ZIop+tUUGZ1EnMBp1WFA Ybd6OqVzzg+nypnZ3/3htJkmh/AmdrFDCukpttJ5n X-Gm-Gg: AfdE7clqLYvLuK40TgefuPxu1pqJNRxAHhCwOcPXY6XC7w1lUwMFRRchTnFoZHpMB2K yU5KQ9RPlmRhiqLirGyOorKwAZ5qy5+IWwDhR6JILEAJxmJSJhS7Dq2gNSUBeF0EtikqLTvsM5V teBSObouMIk/IirqEX9kE2065IHzANJZwGsT+53KCjsFeH3sEYaexx71RrFzcYu0NmTzCBURPW+ FRDzqXppLsvlRtzTTndUj5/NaOV68eriE5ZNuIJMEguOZD032MGHyI8IeA6MzUN3ecQcchaoa4B bog30HlMSEkC7vF7kP6UAx6tp6I= X-Received: by 2002:a05:600c:41c5:b0:493:aed4:8d03 with SMTP id 5b1f17b1804b1-4954f623a21mr164335e9.9.1784305792127; Fri, 17 Jul 2026 09:29:52 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260701192210.2997769-1-tjmercier@google.com> In-Reply-To: From: "T.J. Mercier" Date: Fri, 17 Jul 2026 09:29:40 -0700 X-Gm-Features: AUfX_mwkE9srLqf9jV3ClopD-np-tcerODpRpCcyM1eqJKlhjubKKS2HeTkHP3I Message-ID: Subject: Re: [PATCH v2] selftests: Open /dev/udmabuf O_RDONLY To: Shuah Khan Cc: kraxel@redhat.com, vivek.kasireddy@intel.com, kuba@kernel.org, Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Bobby Eshleman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 2, 2026 at 1:53=E2=80=AFPM Bobby Eshleman wrote: > > On Wed, Jul 01, 2026 at 12:22:08PM -0700, T.J. Mercier wrote: > > Write permissions on the /dev/udmabuf device file are not required to > > issue ioctls and allocate udmabufs. Applications should be opening this > > file as O_RDONLY. The BPF dmabuf_iter selftest already does this. [1] > > > > Users are pointing to these selftests as examples of how use udmabuf, > > and encountering permission errors on systems where write permissions > > are not available on /dev/udmabuf. Apply the principle of least > > privilege to selftests which use udmabuf by removing the write access > > mode from drivers/dma-buf/udmabuf.c and drivers/net/hw/ncdevmem.c. > > > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/= tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=3Dv7.1#n49 > > > > Signed-off-by: T.J. Mercier > > --- > > tools/testing/selftests/drivers/dma-buf/udmabuf.c | 2 +- > > tools/testing/selftests/drivers/net/hw/ncdevmem.c | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/= testing/selftests/drivers/dma-buf/udmabuf.c > > index d78aec662586..ced0b95c876c 100644 > > --- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c > > +++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c > > @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) > > ksft_print_header(); > > ksft_set_plan(7); > > > > - devfd =3D open("/dev/udmabuf", O_RDWR); > > + devfd =3D open("/dev/udmabuf", O_RDONLY); > > if (devfd < 0) { > > ksft_print_msg( > > "%s: [skip,no-udmabuf: Unable to access DMA buffe= r device file]\n", > > diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c b/tools/= testing/selftests/drivers/net/hw/ncdevmem.c > > index e098d6534c3c..8114a29692fd 100644 > > --- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c > > +++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c > > @@ -149,7 +149,7 @@ static struct memory_buffer *udmabuf_alloc(size_t s= ize) > > > > ctx->size =3D size; > > > > - ctx->devfd =3D open("/dev/udmabuf", O_RDWR); > > + ctx->devfd =3D open("/dev/udmabuf", O_RDONLY); > > if (ctx->devfd < 0) { > > pr_err("[skip,no-udmabuf: Unable to access DMA buffer dev= ice file]"); > > goto err_free_ctx; > > > > base-commit: fbb7ad31ab376c5101b2ac7205fad0344fd2de60 > > -- > > 2.55.0.rc0.799.gd6f94ed593-goog > > > > Reviewed-by: Bobby Eshleman Thanks Bobby. Shuah, would you mind picking this up?