checking parameters to variadic printf formatted functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been looking into testing the address_space() pointers in
the current Linux kernel and came up with a case where I am not
sure how this should work (the kernel's __user attribute).

We tested the following cases, In this case sparse correctly
identified the incorrect address space/no-dereference. The first
was not identified:

# define __user  __attribute__((noderef, address_space(1)))

void test(char __user *ptr)
{
	printk("%s\n", ptr);
	printk("%c\n", ptr[0]);
}

I know that there is a gcc printf format attribute to allow
specifying the positions of the format and start of variadic
arguments.

I have had a quick look at the code but have not tried to make
any modifications yet, and would like some feedback or help
before making any:

- Should we automatically warn on possible de-ref (or address space)
  on passing to a variadic function (I think the simplest)

- Is adding support  for __attribute__((format(printf,a,b))) a
  good idea (and if so is anyone looking into this already)

- If adding printf format a good idea, then should we extend it
  to adding a kernel printk style one too (modern kernels seem
  to love extending the printf formatting)

Any help would be appreciated.

--
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux