Skip to content

Conversation

@FlorentRevest
Copy link

The origin object is the result of this file on a 6.18 build:

#include <linux/compiler.h>

void test_ubsan_out_of_bounds(void);
void test_ubsan_out_of_bounds(void)
{
	int i = 4, j = 4;
	volatile struct {
		char above[4];
		int arr[4];
		char below[4];
	} data;

	OPTIMIZER_HIDE_VAR(i);
	OPTIMIZER_HIDE_VAR(j);

	data.arr[j] = i;
}

And the patch is:

 void test_ubsan_out_of_bounds(void)
 {
-	int i = 4, j = 4;
+	int i = 4, j = -1; volatile struct { char above[4]; int arr[4];

Since Clang UBSAN generates "unnamed" sections, it exercises these sections changing.

The origin object is the result of this file on a 6.18 build:

	#include <linux/compiler.h>

	void test_ubsan_out_of_bounds(void);
	void test_ubsan_out_of_bounds(void)
	{
		int i = 4, j = 4;
		volatile struct {
			char above[4];
			int arr[4];
			char below[4];
		} data;

		OPTIMIZER_HIDE_VAR(i);
		OPTIMIZER_HIDE_VAR(j);

		data.arr[j] = i;
	}

And the patch is:

	 void test_ubsan_out_of_bounds(void)
	 {
	-	int i = 4, j = 4;
	+	int i = 4, j = -1;
		volatile struct {
			char above[4];
			int arr[4];

Since Clang UBSAN generates "unnamed" sections, it exercises these
sections changing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant