lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202210020306.98ADsU6A-lkp@intel.com>
Date:   Sun, 2 Oct 2022 03:47:18 +0800
From:   kernel test robot <lkp@...el.com>
To:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Matti Vaittinen <mazziesaccount@...il.com>
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        Cosmin Tanislav <cosmin.tanislav@...log.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Michael Hennerich <Michael.Hennerich@...log.com>,
        Jonathan Cameron <jic23@...nel.org>,
        Eugen Hristev <eugen.hristev@...rochip.com>,
        Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Claudiu Beznea <claudiu.beznea@...rochip.com>,
        Alexandru Ardelean <alexandru.ardelean@...log.com>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Miaoqian Lin <linmq006@...il.com>,
        Miquel Raynal <miquel.raynal@...tlin.com>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>,
        Mihail Chindris <mihail.chindris@...log.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 2/2] iio: Fix unsafe buffer attributes

Hi Matti,

I love your patch! Yet something to improve:

[auto build test ERROR on v6.0-rc7]
[also build test ERROR on linus/master]
[cannot apply to jic23-iio/togreg next-20220930]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matti-Vaittinen/iio-Add-IIO_STATIC_CONST_DEVICE_ATTR/20220930-191558
base:    f76349cf41451c5c42a99f18a9163377e4b364ff
config: i386-randconfig-a006
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/71aecc2b7a59a431f1a4ca7f6e4670f6ca889cb0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Matti-Vaittinen/iio-Add-IIO_STATIC_CONST_DEVICE_ATTR/20220930-191558
        git checkout 71aecc2b7a59a431f1a4ca7f6e4670f6ca889cb0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

All errors (new ones prefixed by >>):

>> drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c:336:14: error: incompatible pointer types passing 'const struct attribute *[3]' to parameter of type 'const struct iio_dev_attr **' [-Werror,-Wincompatible-pointer-types]
                                                                 cros_ec_sensor_fifo_attributes);
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/iio/kfifo_buf.h:17:37: note: passing argument to parameter 'buffer_attrs' here
                                       const struct iio_dev_attr **buffer_attrs);
                                                                   ^
   1 error generated.


vim +336 drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c

aa984f1ba4a477 Gwendal Grignou        2020-03-27  228  
d9452adcc5b485 Gwendal Grignou        2020-03-27  229  /**
d9452adcc5b485 Gwendal Grignou        2020-03-27  230   * cros_ec_sensors_core_init() - basic initialization of the core structure
0b4ae3f6d1210c Gwendal Grignou        2022-07-11  231   * @pdev:		platform device created for the sensor
d9452adcc5b485 Gwendal Grignou        2020-03-27  232   * @indio_dev:		iio device structure of the device
d9452adcc5b485 Gwendal Grignou        2020-03-27  233   * @physical_device:	true if the device refers to a physical device
aa984f1ba4a477 Gwendal Grignou        2020-03-27  234   * @trigger_capture:    function pointer to call buffer is triggered,
aa984f1ba4a477 Gwendal Grignou        2020-03-27  235   *    for backward compatibility.
d9452adcc5b485 Gwendal Grignou        2020-03-27  236   *
d9452adcc5b485 Gwendal Grignou        2020-03-27  237   * Return: 0 on success, -errno on failure.
d9452adcc5b485 Gwendal Grignou        2020-03-27  238   */
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  239  int cros_ec_sensors_core_init(struct platform_device *pdev,
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  240  			      struct iio_dev *indio_dev,
aa984f1ba4a477 Gwendal Grignou        2020-03-27  241  			      bool physical_device,
0b4ae3f6d1210c Gwendal Grignou        2022-07-11  242  			      cros_ec_sensors_capture_t trigger_capture)
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  243  {
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  244  	struct device *dev = &pdev->dev;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  245  	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
d60ac88a62df71 Gwendal Grignou        2019-11-19  246  	struct cros_ec_sensorhub *sensor_hub = dev_get_drvdata(dev->parent);
d60ac88a62df71 Gwendal Grignou        2019-11-19  247  	struct cros_ec_dev *ec = sensor_hub->ec;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  248  	struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
56e4f2dda23c6d Gwendal Grignou        2020-06-30  249  	u32 ver_mask, temp;
317a0ebe53f465 Gwendal Grignou        2020-03-27  250  	int frequencies[ARRAY_SIZE(state->frequencies) / 2] = { 0 };
22087c850e8e56 Gwendal Grignou        2019-08-26  251  	int ret, i;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  252  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  253  	platform_set_drvdata(pdev, indio_dev);
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  254  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  255  	state->ec = ec->ec_dev;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  256  	state->msg = devm_kzalloc(&pdev->dev,
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  257  				max((u16)sizeof(struct ec_params_motion_sense),
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  258  				state->ec->max_response), GFP_KERNEL);
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  259  	if (!state->msg)
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  260  		return -ENOMEM;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  261  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  262  	state->resp = (struct ec_response_motion_sense *)state->msg->data;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  263  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  264  	mutex_init(&state->cmd_lock);
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  265  
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  266  	ret = cros_ec_get_host_cmd_version_mask(state->ec,
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  267  						ec->cmd_offset,
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  268  						EC_CMD_MOTION_SENSE_CMD,
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  269  						&ver_mask);
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  270  	if (ret < 0)
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  271  		return ret;
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  272  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  273  	/* Set up the host command structure. */
3cf9df00957fb2 Fabien Lahoudere       2019-07-02  274  	state->msg->version = fls(ver_mask) - 1;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  275  	state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  276  	state->msg->outsize = sizeof(struct ec_params_motion_sense);
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  277  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  278  	indio_dev->name = pdev->name;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  279  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  280  	if (physical_device) {
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  281  		enum motionsensor_location loc;
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  282  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  283  		state->param.cmd = MOTIONSENSE_CMD_INFO;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  284  		state->param.info.sensor_num = sensor_platform->sensor_num;
f53199c0bc6265 Gwendal Grignou        2019-07-18  285  		ret = cros_ec_motion_send_host_cmd(state, 0);
f53199c0bc6265 Gwendal Grignou        2019-07-18  286  		if (ret) {
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  287  			dev_warn(dev, "Can not access sensor info\n");
f53199c0bc6265 Gwendal Grignou        2019-07-18  288  			return ret;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  289  		}
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  290  		state->type = state->resp->info.type;
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  291  		loc = state->resp->info.location;
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  292  		if (loc == MOTIONSENSE_LOC_BASE)
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  293  			indio_dev->label = "accel-base";
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  294  		else if (loc == MOTIONSENSE_LOC_LID)
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  295  			indio_dev->label = "accel-display";
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  296  		else if (loc == MOTIONSENSE_LOC_CAMERA)
7cbb6681d7e5b8 Gwendal Grignou        2022-04-27  297  			indio_dev->label = "accel-camera";
12bf745c9afb67 Gwendal Grignou        2019-07-15  298  
12bf745c9afb67 Gwendal Grignou        2019-07-15  299  		/* Set sign vector, only used for backward compatibility. */
12bf745c9afb67 Gwendal Grignou        2019-07-15  300  		memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  301  
22087c850e8e56 Gwendal Grignou        2019-08-26  302  		for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
22087c850e8e56 Gwendal Grignou        2019-08-26  303  			state->calib[i].scale = MOTION_SENSE_DEFAULT_SCALE;
22087c850e8e56 Gwendal Grignou        2019-08-26  304  
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  305  		/* 0 is a correct value used to stop the device */
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  306  		if (state->msg->version < 3) {
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  307  			get_default_min_max_freq(state->resp->info.type,
317a0ebe53f465 Gwendal Grignou        2020-03-27  308  						 &frequencies[1],
317a0ebe53f465 Gwendal Grignou        2020-03-27  309  						 &frequencies[2],
cb87556068146d Gwendal Grignou        2020-03-27  310  						 &state->fifo_max_event_count);
56e4f2dda23c6d Gwendal Grignou        2020-06-30  311  		} else {
56e4f2dda23c6d Gwendal Grignou        2020-06-30  312  			if (state->resp->info_3.max_frequency == 0) {
56e4f2dda23c6d Gwendal Grignou        2020-06-30  313  				get_default_min_max_freq(state->resp->info.type,
56e4f2dda23c6d Gwendal Grignou        2020-06-30  314  							 &frequencies[1],
56e4f2dda23c6d Gwendal Grignou        2020-06-30  315  							 &frequencies[2],
56e4f2dda23c6d Gwendal Grignou        2020-06-30  316  							 &temp);
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  317  			} else {
317a0ebe53f465 Gwendal Grignou        2020-03-27  318  				frequencies[1] = state->resp->info_3.min_frequency;
317a0ebe53f465 Gwendal Grignou        2020-03-27  319  				frequencies[2] = state->resp->info_3.max_frequency;
56e4f2dda23c6d Gwendal Grignou        2020-06-30  320  			}
56e4f2dda23c6d Gwendal Grignou        2020-06-30  321  			state->fifo_max_event_count = state->resp->info_3.fifo_max_event_count;
ae7b02ad2f32d3 Fabien Lahoudere       2019-07-16  322  		}
317a0ebe53f465 Gwendal Grignou        2020-03-27  323  		for (i = 0; i < ARRAY_SIZE(frequencies); i++) {
317a0ebe53f465 Gwendal Grignou        2020-03-27  324  			state->frequencies[2 * i] = frequencies[i] / 1000;
317a0ebe53f465 Gwendal Grignou        2020-03-27  325  			state->frequencies[2 * i + 1] =
317a0ebe53f465 Gwendal Grignou        2020-03-27  326  				(frequencies[i] % 1000) * 1000;
317a0ebe53f465 Gwendal Grignou        2020-03-27  327  		}
aa984f1ba4a477 Gwendal Grignou        2020-03-27  328  
aa984f1ba4a477 Gwendal Grignou        2020-03-27  329  		if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
aa984f1ba4a477 Gwendal Grignou        2020-03-27  330  			/*
aa984f1ba4a477 Gwendal Grignou        2020-03-27  331  			 * Create a software buffer, feed by the EC FIFO.
aa984f1ba4a477 Gwendal Grignou        2020-03-27  332  			 * We can not use trigger here, as events are generated
aa984f1ba4a477 Gwendal Grignou        2020-03-27  333  			 * as soon as sample_frequency is set.
aa984f1ba4a477 Gwendal Grignou        2020-03-27  334  			 */
f67c6c73cb07a4 Miquel Raynal          2022-02-07  335  			ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, NULL,
80346b2b55fcbb Gwendal Grignou        2021-03-18 @336  							      cros_ec_sensor_fifo_attributes);
17395ce299211a Alexandru Ardelean     2021-02-15  337  			if (ret)
17395ce299211a Alexandru Ardelean     2021-02-15  338  				return ret;
aa984f1ba4a477 Gwendal Grignou        2020-03-27  339  
aa984f1ba4a477 Gwendal Grignou        2020-03-27  340  			/* Timestamp coming from FIFO are in ns since boot. */
aa984f1ba4a477 Gwendal Grignou        2020-03-27  341  			ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
aa984f1ba4a477 Gwendal Grignou        2020-03-27  342  			if (ret)
aa984f1ba4a477 Gwendal Grignou        2020-03-27  343  				return ret;
165aea80e2e2c7 Alexandru Ardelean     2020-09-29  344  
80346b2b55fcbb Gwendal Grignou        2021-03-18  345  		} else {
aa984f1ba4a477 Gwendal Grignou        2020-03-27  346  			/*
aa984f1ba4a477 Gwendal Grignou        2020-03-27  347  			 * The only way to get samples in buffer is to set a
d18ffd83745a74 Keyur Patel            2020-06-09  348  			 * software trigger (systrig, hrtimer).
aa984f1ba4a477 Gwendal Grignou        2020-03-27  349  			 */
80346b2b55fcbb Gwendal Grignou        2021-03-18  350  			ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
80346b2b55fcbb Gwendal Grignou        2021-03-18  351  					NULL, trigger_capture, NULL);
aa984f1ba4a477 Gwendal Grignou        2020-03-27  352  			if (ret)
aa984f1ba4a477 Gwendal Grignou        2020-03-27  353  				return ret;
aa984f1ba4a477 Gwendal Grignou        2020-03-27  354  		}
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  355  	}
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  356  
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  357  	return 0;
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  358  }
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  359  EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
974e6f02e27e1b Enric Balletbo i Serra 2016-08-01  360  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (149873 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ