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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 29 Jun 2021 21:18:34 -0700
From:   Bart Van Assche <bvanassche@....org>
To:     Martin Kepplinger <martin.kepplinger@...i.sm>
Cc:     jejb@...ux.ibm.com, linux-kernel@...r.kernel.org,
        linux-pm@...r.kernel.org, linux-scsi@...r.kernel.org,
        martin.petersen@...cle.com, stern@...land.harvard.edu
Subject: Re: [PATCH v4 2/3] scsi: sd: send REQUEST SENSE for
 BLIST_MEDIA_CHANGE devices in runtime_resume()

On 6/28/21 6:34 AM, Martin Kepplinger wrote:
> +static int sd_resume_runtime(struct device *dev)
> +{
> +	struct scsi_disk *sdkp = dev_get_drvdata(dev);
> +	struct scsi_device *sdp;
> +	int timeout, retries, res;
> +	struct scsi_sense_hdr my_sshdr;

Since the sense data is ignored, consider removing the "my_sshdr"
declaration and passing NULL as sense pointer to scsi_execute().

> +	if (!sdkp)	/* E.g.: runtime resume at the start of sd_probe() */
> +		return 0;

Are you sure that this code is necessary? There is an
scsi_autopm_get_device(sdp) call at the start of sd_probe() and
scsi_autopm_put_device(sdp) call at the end of sd_probe(). In other
words, no runtime suspend will happen between the
device_initialize(&sdkp->dev) call in sd_probe() and the
dev_set_drvdata(dev, sdkp) call in the same function.

> +	if (sdp->sdev_bflags & BLIST_MEDIA_CHANGE) {
> +		for (retries = 3; retries > 0; --retries) {
> +			unsigned char cmd[10] = { 0 };
> +
> +			cmd[0] = REQUEST_SENSE;

Please define the CDB as follows:

	static const u8 cmd[10] = { REQUEST_SENSE };

> +			/*
> +			 * Leave the rest of the command zero to indicate
> +			 * flush everything.
> +			 */

Shouldn't this comment appear above the CDB definition? Also, what does
"flush everything" mean? According to SPC sense data is discarded from
the device while processing REQUEST SENSE, no matter what the value of
the ALLOCATION LENGTH parameter in that command is. From SPC-6: "the
REQUEST SENSE command with any allocation length clears the sense data."

> +			res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL,
> +					   &my_sshdr, timeout,
> +					   sdkp->max_retries, 0, RQF_PM, NULL);

Only one level of retries please. Can sdkp->max_retries be changed into 1?

Thanks,

Bart.

Powered by blists - more mailing lists