From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 D4F943BF675 for ; Mon, 11 May 2026 17:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778519240; cv=none; b=TNbpL5jQvt71H+DAwimPnBnySSaQj4CAACMopOT7Mi6yTaMvo3yHiIo30ozc2ZzYW9kEQL2e1sQTj1RFP9dcXRGWKzCYnnWq8fvyqG7XudW4ZjLxQ2pyFcWoJxWyYX4z/fj87+/27MS4WiNkH9/wGnXmYEGVPQWz6iQlBJOgygA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778519240; c=relaxed/simple; bh=ttyzlAsQV2LCBXMCefThV0JUVjJzRehzxN0uxmPQx3k=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=mldctw5e2YycF0Q0OjwO5qixBPb9Uy1QNbJjwJ0XI5pvdaRh3MYk9cYpKs735UCdBiPbgtivspBdPQzTIdxrwT6K0DD+HcdU6arw0Tr6T1xo5yrFSMkouLeGchABOf73svFlC/PTh4MR/yltsD8bzYQ4eUMdgsdZDqS5lSvtKHY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=an9J+f36; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="an9J+f36" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-40ea36b56b7so3408954fac.3 for ; Mon, 11 May 2026 10:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778519238; x=1779124038; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JuqFpulg8Nqo7DOFhcbTfsrDVhgNxZLwGvrCkArInQA=; b=an9J+f36HD8PwfYW0Ir4GuH815hrAhaeL6N8MUZKQiDRqK1vWyenuvvAXwPim0PZUX PBGKfNzNNBuaByPVVsAgiKV2Iuyh2GBFweD7xiIjZwYf0d9KyrYHlS6J57w5vYXDTx6+ 12z/Y/6KYr1LbyL10cW94Qgn+XfnavmdAZEk+dmJRwZPmRoK/IkqLPNsiRi63hGkahEU H+iG9SUlhESH4uWHmtiJxuFSygMP2N+Sa4u0Xb7M3MnmpDcaeGqrm7LvvMtgX25rv43J F/uJARN3hjZVeQV2R6cVawNxlerQ1J0qfGDXX5cyqN39vNnuDC7taPrEiKmMuEkFcOS3 /5QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778519238; x=1779124038; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JuqFpulg8Nqo7DOFhcbTfsrDVhgNxZLwGvrCkArInQA=; b=L4FW54UinYnzLY06R38VoM3HTpYCvVkYBtn5xyV0Kz5nolRScMk3bf99ETLp2BIxT9 BS8iS4Jt2Zsn+zzGJ8ptCf6xlO6QBvU9z6VXD0rqaZQts3eqsxHd0tAa8AoatTnY5Z3j Fsbw0BpA5BMY7Kdj8WB10QIjsTvrf9OtksoGwxeggfxqudtyr8CS7xu9+EBU7aFoDkFv klqLrzvW3MLsGCH67hIropQy5XtQPYKZ/ij6KMa3pL4dBueq0exHBv5pQASDie8ABHPm 0t0zKiHMmQJZdDmgVPjPZzi6GFR5RZ+iI18U9paHAS9LoWsnBIx5/Ic04TDJ0NYijH7B a4tg== X-Forwarded-Encrypted: i=1; AFNElJ/x4yRKPphvYvM4LfskhhvQF/NTOquUgZ46+kKB9b5j7epSW9Cf5KzkiHkQODwhd4fmfRrntmhMJ9fJYTE=@vger.kernel.org X-Gm-Message-State: AOJu0YySOPAzqG+S45BUwSJ6PTnMEmnXfHAX/9fr+igyh6obRa4WQxwU DH+x/RoeS6f6oPqVP4RJTa+9gzCue6vBLK51gYXr4iw4Kdakx/UmHYRH X-Gm-Gg: Acq92OHlWWMmkxRLXteJoBm1PXmzNmE95iUEsOOAHvjOXH5fDTFrIG6rtUTyZrXwKlC Wl051NhhjkkJ9dlFuihEXBhuD9eiD1OD29lbFC0PxgQhqXjueDBuLPYwPIPIY9dP2T24O/2033m dwG0BFcxn1MrnqA8R6I2srrhbEmWT5+9qrAXeZk848VuQU74YSr5jeyUA67THbsVj9XUR9miPyg zBXvHil5OK+uHkr+pAyPFRbj616sAw5y09zKIxioUGTdE4UrdreqyoOamf/j/uwY2SHKj6LVqGb pQOKpk8w3tg+00ttIJX8msTWLoQtd46VD5xLPS+s89R4vaMLLHP4rQGP7xg+v5J6ed4UuLkW2id q7BiavGUdbSEQPtpk6r2yEDlPjcLpvLr1Bogt9RfLEKe2ae02UXSekxuTadzcGjowy6SCqPYR2O CMArLXFuA5Jt0u+UBvZC381zbOXbrzD8oa3A/D9RDzbl0tGB3NpaB+97IIVrx5gIfBh4WL7+Y4I 8tih76u2ifBWs9FtgDMpUc1J1U= X-Received: by 2002:a05:6870:5119:b0:433:ffeb:4525 with SMTP id 586e51a60fabf-434f66bae6emr15403715fac.26.1778519237637; Mon, 11 May 2026 10:07:17 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:4::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43557109b7dsm9702493fac.5.2026.05.11.10.07.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 May 2026 10:07:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 11 May 2026 10:07:15 -0700 Message-Id: Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH bpf-next v13 6/8] bpf: Add syscall common attributes support for map_create From: "Alexei Starovoitov" To: , , X-Mailer: aerc References: <20260511152817.89191-7-leon.hwang@linux.dev> In-Reply-To: On Mon May 11, 2026 at 9:19 AM PDT, bot+bpf-ci wrote: >> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h >> index 8433430dedb7..c15a4c26a43b 100644 >> --- a/include/linux/bpf_verifier.h >> +++ b/include/linux/bpf_verifier.h > > [ ... ] > >> diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c >> index fd12ad5a0338..62fe6ed18374 100644 >> --- a/kernel/bpf/log.c >> +++ b/kernel/bpf/log.c > > [ ... ] > >> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c >> index 2fa05ba8f161..54b43e16848a 100644 >> --- a/kernel/bpf/syscall.c >> +++ b/kernel/bpf/syscall.c > > [ ... ] > >> @@ -1611,6 +1632,31 @@ static int map_create(union bpf_attr *attr, bpfpt= r_t uattr) >> return err; >> } >> >> +static int map_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_= common_attr *attr_common, >> + bpfptr_t uattr_common, u32 size_common) >> +{ >> + struct bpf_verifier_log *log; >> + struct bpf_log_attr attr_log; >> + int err, ret; >> + >> + log =3D bpf_log_attr_create_vlog(&attr_log, attr_common, uattr_common,= size_common); >> + if (IS_ERR(log)) >> + return PTR_ERR(log); >> + >> + err =3D __map_create(attr, uattr, log); >> + >> + ret =3D bpf_log_attr_finalize(&attr_log, log); >> + if (ret) { >> + if (err >=3D 0) >> + close_fd(err); >> + err =3D ret; > > When bpf_log_attr_finalize() returns an error (say -ENOSPC for log buffer > truncation or -EFAULT for copy_to_user failure) after __map_create() alre= ady > returned a negative error (for example -EINVAL from CHECK_ATTR or -EPERM = from > security checks), does it make sense to overwrite the original map creati= on > error with the log finalization error? > > The result is that userspace receives -ENOSPC or -EFAULT instead of the > actual reason the map creation failed. A user with an undersized log buff= er > might retry with a larger buffer expecting success, when the real issue i= s > that the map creation itself was rejected for a different reason. > > Looking at bpf_check() in kernel/bpf/verifier.c (around the verifier log > finalization), it uses similar logic with 'err =3D ret;' reassignment. Ho= wever, > that doesn't appear to have the preserve-original-error comment that woul= d > clarify the intended behavior for this scenario. I guess sinle line comment wouldn't hurt. > >> + } >> + >> +free: > > Does anything use this free: label? The only exit path before it is the e= arly > return for IS_ERR(log), which correctly returns directly since log is an = error > pointer and doesn't need cleanup. There doesn't seem to be any 'goto free= ;' > statement in the function. > > With -Wunused-label enabled by default in the kernel build (part of -Wall= ), > this will generate a compiler warning. When building with -Werror (common= in > CI configurations and allmodconfig builds), this would break the build. good point. pls fix.