Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abhishek Bapat" <abhishekbapat@google.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/4] alloc_tag: Introduce IOCTLs to toggle allocation tracepoints
Date: Wed, 07 Oct 2026 22:51:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-163425@kernel.org> (raw)
In-Reply-To: <1f77364a04d0ae20cf07efaca779756f92ec39f6.1791410886.git.abhishekbapat@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] abi: UAPI struct layout mismatch for 32-bit compat userspace breaks IOCTLs
--

commit 8d88f08e2268b0340428c21059f2534d77368ca5
Author: Abhishek Bapat <abhishekbapat@google.com>

alloc_tag: Introduce IOCTLs to toggle allocation tracepoints

Introduce a new IOCTL (ALLOCINFO_IOC_TOGGLE_TRACE) to selectively
toggle tracing on allocation call sites. Userspace tools can use the
existing filtering mechanism to specify the set of tags to toggle
tracing for.

> diff --git a/include/uapi/linux/alloc_tag.h b/include/uapi/linux/alloc_tag.h
> index 7d4618bea0434..dafcba2f7e2c1 100644
> --- a/include/uapi/linux/alloc_tag.h
> +++ b/include/uapi/linux/alloc_tag.h
> @@ -85,9 +85,20 @@ struct allocinfo_get_at {
>  	struct allocinfo_tag_data data;
>  };
>  
> +struct allocinfo_toggle_traces {
> +	/* inputs */
> +	/*
> +	 * Tags matching the filter are toggled; an empty mask selects all tags.
> +	 * Size criteria are checked once, against the tag's size at call time.
> +	 */
> +	struct allocinfo_filter filter;

[Severity: Medium]
The new struct allocinfo_toggle_traces embeds struct allocinfo_filter.
Does this struct layout introduce a UAPI mismatch regression for 32-bit compat
userspace?

The struct allocinfo_filter contains struct allocinfo_tag (196 bytes)
directly followed by __u64 min_size:

include/uapi/linux/alloc_tag.h:
struct allocinfo_filter {
	__u64 mask;
	struct allocinfo_tag fields;
	__u64 min_size;
	...
};

On 32-bit architectures like i386, __u64 has a 4-byte alignment requirement,
placing min_size at offset 204. On 64-bit architectures, __u64 has an
8-byte alignment requirement, inserting 4 bytes of padding and placing
min_size at offset 208.

Because of this size disparity (236 bytes vs 240 bytes for
struct allocinfo_toggle_traces), the IOCTL command number generated by
_IOW() in userspace will differ between 32-bit and 64-bit builds.

Since the pre-existing allocinfo_compat_ioctl() directly passes the 32-bit
IOCTL command number to the native allocinfo_ioctl() switch statement
without translation:

mm/alloc_tag.c:allocinfo_compat_ioctl() {
	return allocinfo_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
}

Won't the new ALLOCINFO_IOC_TOGGLE_TRACE command fall through to default
in allocinfo_ioctl() and return -ENOIOCTLCMD, breaking the feature for
32-bit userspace tools on 64-bit kernels?

> +	__u64 enable;
> +};
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791410885.git.abhishekbapat@google.com?part=2

  reply	other threads:[~2026-10-07 22:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 22:39 [PATCH v2 0/4] alloc_tag: Introduce selective tracing for MAP Abhishek Bapat
2026-10-07 22:39 ` [PATCH v2 1/4] alloc_tag: Add trace events for tracing allocations Abhishek Bapat
2026-10-07 22:40 ` [PATCH v2 2/4] alloc_tag: Introduce IOCTLs to toggle allocation tracepoints Abhishek Bapat
2026-10-07 22:51   ` sashiko-bot [this message]
2026-10-07 22:40 ` [PATCH v2 3/4] alloc_tag: Extend allocinfo_filter to support tracing queries Abhishek Bapat
2026-10-07 22:47   ` sashiko-bot
2026-10-07 22:40 ` [PATCH v2 4/4] alloc_tag: Add a test for trace state toggle and filtering Abhishek Bapat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-163425@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abhishekbapat@google.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox