Re: [PATCH 3/3] media: dvb_frontend: Add commands implementation for compat ioct

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

 



Hi Jaedon,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.15-rc2 next-20171204]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jaedon-Shin/Add-support-compat-in-dvb_frontend-c/20171204-201817
base:   git://linuxtv.org/media_tree.git master
config: x86_64-randconfig-x014-201749 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

>> drivers/media//dvb-core/dvb_frontend.c:1992:4: error: unknown type name 'compat_uptr_t'
       compat_uptr_t reserved2;
       ^~~~~~~~~~~~~
   drivers/media//dvb-core/dvb_frontend.c:2000:2: error: unknown type name 'compat_uptr_t'
     compat_uptr_t props;
     ^~~~~~~~~~~~~
   drivers/media//dvb-core/dvb_frontend.c: In function 'dvb_frontend_handle_compat_ioctl':
   drivers/media//dvb-core/dvb_frontend.c:2018:29: error: implicit declaration of function 'compat_ptr'; did you mean 'complete'? [-Werror=implicit-function-declaration]
      if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
                                ^~~~~~~~~~
                                complete
>> drivers/media//dvb-core/dvb_frontend.c:2018:29: warning: passing argument 2 of 'copy_from_user' makes pointer from integer without a cast [-Wint-conversion]
   In file included from include/linux/poll.h:12:0,
                    from drivers/media//dvb-core/dvb_frontend.c:35:
   include/linux/uaccess.h:144:1: note: expected 'const void *' but argument is of type 'int'
    copy_from_user(void *to, const void __user *from, unsigned long n)
    ^~~~~~~~~~~~~~
>> drivers/media//dvb-core/dvb_frontend.c:2030:21: warning: passing argument 1 of 'memdup_user' makes pointer from integer without a cast [-Wint-conversion]
      tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
                        ^~~~~~~~~~
   In file included from drivers/media//dvb-core/dvb_frontend.c:30:0:
   include/linux/string.h:13:14: note: expected 'const void *' but argument is of type 'int'
    extern void *memdup_user(const void __user *, size_t);
                 ^~~~~~~~~~~
   drivers/media//dvb-core/dvb_frontend.c:2049:29: warning: passing argument 2 of 'copy_from_user' makes pointer from integer without a cast [-Wint-conversion]
      if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
                                ^~~~~~~~~~
   In file included from include/linux/poll.h:12:0,
                    from drivers/media//dvb-core/dvb_frontend.c:35:
   include/linux/uaccess.h:144:1: note: expected 'const void *' but argument is of type 'int'
    copy_from_user(void *to, const void __user *from, unsigned long n)
    ^~~~~~~~~~~~~~
   drivers/media//dvb-core/dvb_frontend.c:2061:21: warning: passing argument 1 of 'memdup_user' makes pointer from integer without a cast [-Wint-conversion]
      tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
                        ^~~~~~~~~~
   In file included from drivers/media//dvb-core/dvb_frontend.c:30:0:
   include/linux/string.h:13:14: note: expected 'const void *' but argument is of type 'int'
    extern void *memdup_user(const void __user *, size_t);
                 ^~~~~~~~~~~
>> drivers/media//dvb-core/dvb_frontend.c:2087:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp,
                       ^
   cc1: some warnings being treated as errors

vim +/compat_uptr_t +1992 drivers/media//dvb-core/dvb_frontend.c

  1980	
  1981	#ifdef CONFIG_COMPAT
  1982	struct compat_dtv_property {
  1983		__u32 cmd;
  1984		__u32 reserved[3];
  1985		union {
  1986			__u32 data;
  1987			struct dtv_fe_stats st;
  1988			struct {
  1989				__u8 data[32];
  1990				__u32 len;
  1991				__u32 reserved1[3];
> 1992				compat_uptr_t reserved2;
  1993			} buffer;
  1994		} u;
  1995		int result;
  1996	} __attribute__ ((packed));
  1997	
  1998	struct compat_dtv_properties {
  1999		__u32 num;
> 2000		compat_uptr_t props;
  2001	};
  2002	
  2003	#define COMPAT_FE_SET_PROPERTY	   _IOW('o', 82, struct compat_dtv_properties)
  2004	#define COMPAT_FE_GET_PROPERTY	   _IOR('o', 83, struct compat_dtv_properties)
  2005	
  2006	static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,
  2007						    unsigned long arg)
  2008	{
  2009		struct dvb_device *dvbdev = file->private_data;
  2010		struct dvb_frontend *fe = dvbdev->priv;
  2011		struct dvb_frontend_private *fepriv = fe->frontend_priv;
  2012		int i, err = 0;
  2013	
  2014		if (cmd == COMPAT_FE_SET_PROPERTY) {
  2015			struct compat_dtv_properties prop, *tvps = NULL;
  2016			struct compat_dtv_property *tvp = NULL;
  2017	
> 2018			if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
  2019				return -EFAULT;
  2020	
  2021			tvps = ∝
  2022	
  2023			/*
  2024			 * Put an arbitrary limit on the number of messages that can
  2025			 * be sent at once
  2026			 */
  2027			if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
  2028				return -EINVAL;
  2029	
> 2030			tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
  2031			if (IS_ERR(tvp))
  2032				return PTR_ERR(tvp);
  2033	
  2034			for (i = 0; i < tvps->num; i++) {
  2035				err = dtv_property_process_set(fe, file,
  2036								(tvp + i)->cmd,
  2037								(tvp + i)->u.data);
  2038				if (err < 0) {
  2039					kfree(tvp);
  2040					return err;
  2041				}
  2042			}
  2043			kfree(tvp);
  2044		} else if (cmd == COMPAT_FE_GET_PROPERTY) {
  2045			struct compat_dtv_properties prop, *tvps = NULL;
  2046			struct compat_dtv_property *tvp = NULL;
  2047			struct dtv_frontend_properties getp = fe->dtv_property_cache;
  2048	
  2049			if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
  2050				return -EFAULT;
  2051	
  2052			tvps = &prop;
  2053	
  2054			/*
  2055			 * Put an arbitrary limit on the number of messages that can
  2056			 * be sent at once
  2057			 */
  2058			if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
  2059				return -EINVAL;
  2060	
> 2061			tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
  2062			if (IS_ERR(tvp))
  2063				return PTR_ERR(tvp);
  2064	
  2065			/*
  2066			 * Let's use our own copy of property cache, in order to
  2067			 * avoid mangling with DTV zigzag logic, as drivers might
  2068			 * return crap, if they don't check if the data is available
  2069			 * before updating the properties cache.
  2070			 */
  2071			if (fepriv->state != FESTATE_IDLE) {
  2072				err = dtv_get_frontend(fe, &getp, NULL);
  2073				if (err < 0) {
  2074					kfree(tvp);
  2075					return err;
  2076				}
  2077			}
  2078			for (i = 0; i < tvps->num; i++) {
  2079				err = dtv_property_process_get(
  2080				    fe, &getp, (struct dtv_property *)tvp + i, file);
  2081				if (err < 0) {
  2082					kfree(tvp);
  2083					return err;
  2084				}
  2085			}
  2086	
> 2087			if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp,
  2088					 tvps->num * sizeof(struct compat_dtv_property))) {
  2089				kfree(tvp);
  2090				return -EFAULT;
  2091			}
  2092			kfree(tvp);
  2093		}
  2094	
  2095		return err;
  2096	}
  2097	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux