Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13406274pxu; Sun, 3 Jan 2021 13:40:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLkReVXp455iBPtMQwkdeMPnKYpsO3lFnup2l+8oH0K5jW2YjqeQ43Jy+eeOINyR8mw+wK X-Received: by 2002:a17:906:8693:: with SMTP id g19mr67592298ejx.111.1609710010214; Sun, 03 Jan 2021 13:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609710010; cv=none; d=google.com; s=arc-20160816; b=dTmqiVHHYDP6hSuAA0o0uSDtnaYFcgS2iEjoG3nZgI/XX+KSwzbvTnsfPMt4/orClV /2Vod1zcKF1tSlOfSafUokYJbKNGBsAePEkjdFIOhiksVV7EqW1ANk8zuW0UXd0VuEnx U7+318/1TX/qQDgtcBdPyimud1q+2T2FmlSOGXImYDkEs0td+FnSawEjX+ENc+rK+mml rx+pKVtSKhac79p5B6Sv+DM+iVFgwivLm+mp87S4QC+Cxvaz7v6oz8X7VqSjPsSAPPSP MnjES3PSGB+rl0j/FktHgPIBXzLXZUNW1McA473VIx5hGeQzycm1YHl2hzyHi8Uw++9b BktQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hAQqiSxJtI0CjgjDd7toxAGtNKYjL3mvMxiPKbefEjg=; b=xWGAy8kA+enxMmj0+FAR6FFl/wGMCwUliOPuY27CJtBoHq1dVZcm5BA/M6/yZmdlsR Ta8PpM9La/WGUqKGZYfvi39jOP29K9kiiLkVgpO53Cm1HtL0rVc224XJj5U7KioZOzTK jZk7p9PvUD3660aXV7Y48peg24XZ16KRz3YRkNtWzJSlQrGyuOK+2PHy+7WDK4ZU7TrH x/gakeP+SK8AUXdNdj6+5rRPibYLojTt6okgwMFe58c3im2tl7TImi1g6XCa3gZcI0zn jgZsZUmHXcJCbMoKRlXoYnrFUAkktotta1oicLGeoDjZGvp7thkNuZqTiAyfGhzV/UOA +d4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iw5cZa+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw4si27758559ejb.196.2021.01.03.13.39.23; Sun, 03 Jan 2021 13:40:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iw5cZa+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbhACSuh (ORCPT + 99 others); Sun, 3 Jan 2021 13:50:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:46318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbhACSuh (ORCPT ); Sun, 3 Jan 2021 13:50:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1006620936; Sun, 3 Jan 2021 18:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609699796; bh=1hccwkBFs5HyDIu0N8vGlP8CeaDkRThJMMvyqFTI9Vw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Iw5cZa+WHJXQOUWaOVS7eSbkLnPE3jp5berENnZe1BoGwIjrraCVXLL3vEpGa53AL eSlIRUoLr2yQLvVSnW5d9/2USwuWWjFJflheT6JjsgVXKR0qg0E7u8scxOXRYblafa s/64/w7rFqgMd3aucZ4nVY/FhBQm5SkdZwPRxBhfbt3j+y49BvC9rxjZf+Wmmr30ff TCrzZuPj6GCfs7CyZcCU3sFiVE1uKzSGZ2zjwUZ9hZLSwNtMXNVJKgsHb8nhgz36+F AET6LybPo44kuWTqxIJXlMp+G64tfLRHGiuhQ4z3RypYC5aPV8wpfOVPFiTCpUCVdd ExHCneUGRk6Cw== Received: by mail-ot1-f52.google.com with SMTP id 11so24087036oty.9; Sun, 03 Jan 2021 10:49:56 -0800 (PST) X-Gm-Message-State: AOAM5332yNFFBRvPS9xiF0PFi8KluvjSugrcdpRePkwLaQT/Iij6tck+ cNKhNcw9fnekFRbfvZcsPrdMMvkmbbq9hD4ZhVA= X-Received: by 2002:a05:6830:2413:: with SMTP id j19mr52366598ots.251.1609699795399; Sun, 03 Jan 2021 10:49:55 -0800 (PST) MIME-Version: 1.0 References: <20200908213715.3553098-1-arnd@arndb.de> <20200908213715.3553098-2-arnd@arndb.de> <20201231001553.GB16945@home.linuxace.com> <739a3639944f099a76d145eb119b77701f13444d.camel@linux.ibm.com> In-Reply-To: <739a3639944f099a76d145eb119b77701f13444d.camel@linux.ibm.com> From: Arnd Bergmann Date: Sun, 3 Jan 2021 19:49:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] scsi: megaraid_sas: check user-provided offsets To: "James E.J. Bottomley" Cc: Phil Oester , Arnd Bergmann , Kashyap Desai , Sumit Saxena , Shivasharan S , "Martin K. Petersen" , Christoph Hellwig , "# 3.4.x" , Anand Lodnoor , Chandrakanth Patil , Hannes Reinecke , megaraidlinux.pdl@broadcom.com, linux-scsi , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 3, 2021 at 6:00 PM James Bottomley wrote: > On Sun, 2021-01-03 at 17:26 +0100, Arnd Bergmann wrote: > [...] > > @@ -8209,7 +8208,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance > > *instance, > > if (instance->consistent_mask_64bit) > > put_unaligned_le64(sense_handle, sense_ptr); > > else > > - put_unaligned_le32(sense_handle, sense_ptr); > > + put_unaligned_le64(sense_handle, sense_ptr); > > } > > This hunk can't be right. It effectively means removing the if. I'm just trying to restore the state before the regression introduced in my 381d34e376e3 ("scsi: megaraid_sas: Check user-provided offsets"). The old code always stored 'sizeof(long)' bytes into sense_ptr, regardless of instance->consistent_mask_64bit, but it would truncate the address to 32 bit if that was cleared. This was clearly bogus and I tried to make it do something more meaningful, only storing 8 bytes into the structure if it was configured for 64-bit DMA, regardless of the capabilities of the kernel. > However, the if is needed because sense_handle is a dma_addr_t which > can be either 32 or 64 bit. What about changing the if to > > if (sizeof(dma_addr_t) == 8) > > instead? That would not be useful either, the device surely does not care if the kernel supports 64-bit DMA. What we'd really need here is someone with access to the interface specifications to see how many bytes should be stored in the structure. I suspect always storing 64 bits (as my patch does) is correct, and would send a proper patch to remove the if() if Phil confirms that my test patch fixes the regression. Arnd