Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2592734pxb; Mon, 19 Apr 2021 09:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+qYYVpKrEiyAu9pfCD3oGAfTNrQ6oXiSi3s1Bf8IzwUkLHeVCfGygxDUWuF6yGnS6Gs2F X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr23129251edd.52.1618848456231; Mon, 19 Apr 2021 09:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618848456; cv=none; d=google.com; s=arc-20160816; b=LfXzCgm3YNIkj4fLkwQF9JApckVKuNcz8xhPOF5iIU9ETcA4cB2dnPeOfB6UB2Wj9A Krp8kiACSMLIvwDoPomswvdqAg5v1uZvXFx2BHDNXpTK54ynfI8Z1p6A6WtgUXBjhShF kmrn5aGQ9fkuRjCdNiUCAnYaSeoHhcg5J87Vuf3GdZWnryxUpuJzFEPJeZWdwzXAMbEW rDe2/wj5NnMJ/nLsntsui69ArtjVyXwaIEV2b+Ghy9uegoNX6JVsj5AC93LGjSqIwfPI bB8aQb0cdfH91cdOVZuHF7pgf5psYiW6WZ7HM2D+wNKsF6P0j1QJ79UpOsl7jhB2/r/g wD+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=Bo8YCeG6eSc07BV5eHkMBJp6Ml2NOFQczpioLFE73m4=; b=xtszrgg8YlSDvbwST3Jfj0a/k07OXmizmNQojotakN4wDeSVSop18HzxJ6VLeGjxsu ddqaee/82iMMnmAqG73egzOnFKOE5b6CjRYYaBfsU+xyLwGPoPgglJA6ms+Dlan//Lt9 N5eZ+YyCYscoXFcVTdgpZDBDUPMDk9ocv+KdAM15PdOXkHysnXEhMRN2EZzOxqChbWUc jF5lrujw73yAspD/LCFZLT+Pq6iBdEWTgwMOW5Vzsxcb4KMbAhwQ30thJ6N9BpLypXlL bEtWaMBgShkKVn1VSFErB/675eQckIux+xFybbLwQkMmzuiF1DA2RKVXkmYOKji+C1Oe zL+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@posteo.net header.s=2017 header.b=Zulet0XV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=posteo.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ep14si11604118ejc.71.2021.04.19.09.07.13; Mon, 19 Apr 2021 09:07:36 -0700 (PDT) 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=fail header.i=@posteo.net header.s=2017 header.b=Zulet0XV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240041AbhDSOgZ (ORCPT + 99 others); Mon, 19 Apr 2021 10:36:25 -0400 Received: from mout01.posteo.de ([185.67.36.65]:37135 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239842AbhDSOgY (ORCPT ); Mon, 19 Apr 2021 10:36:24 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id AC653240029 for ; Mon, 19 Apr 2021 16:35:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618842952; bh=Q4FpEAfTUHaz0QL2Th9Hes8LqYTrL/RKsTEwI7exR10=; h=From:To:Cc:Cc:Subject:Date:From; b=Zulet0XVS9yE24s/RDNr/DTF4oUHAtBiGq1V3xO6h/1sw9nboeZFNRyMvkYhKQwXe Vb2Kb1A6Vw3GXSig+vB2RxpCx1d399FbBBPInDi4IvybHzvZaGqtXn4O7h38aXWRqF 5/yyiBIvcKlTavX52bKcIJ6QrnZmUFjnZpGAGmpNV3SHHeoyBjfdTuD+8YhG2fSnUU 5YNMaXbkLUB5sTLIXI5qr1epDUm7mvRZcZeuGJfxwIIV3GvIB5C7BDEq9Zmm4e3kcK Z8U3KeIvTSudlD9Mjt2kfxpdvVeQ+z9K1wXc1gRg75D/PuIP7p0k42C/WhKz3wrQ7J cMElHc70BRR9g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FP8WC51R4z6tmZ; Mon, 19 Apr 2021 16:35:51 +0200 (CEST) From: Alexander Egorenkov To: Christoph Hellwig , Alexander Egorenkov Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] lib: scatterlist: Fix SGL length in sg_split() if !CONFIG_NEED_SG_DMA_LENGTH In-Reply-To: <20210419092325.GA3215674@infradead.org> References: <20210418081441.5040-1-egorenar-dev@posteo.net> <20210419092325.GA3215674@infradead.org> Date: Mon, 19 Apr 2021 14:35:50 +0000 Message-ID: <87y2de4a0p.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christoph Hellwig writes: > On Sun, Apr 18, 2021 at 08:14:41AM +0000, Alexander Egorenkov wrote: >> If CONFIG_NEED_SG_DMA_LENGTH is NOT enabled then sg_dma_len() is an alias >> for the length field in a SGL. In that case sg_split() wrongly resets >> the length of split SGLs to zero after it was set correctly before. > > Why is this routine messing with sg_dma_address and > sg_dma_lensg_dma_lensg_dma_len at all? This whole sg_spli() routine > seems rather dangerous because ownership and state of the DMA mapping is > entirely unclear. If i understood it correctly, then sg_split_phys() creates a new SGL from the given one, so it makes sense to initialize DMA fields of the new SGL. sg_split() allows one to split the given SGL into multiple ones and the original one doesn't have to be dma-mapped which is indicated by the parameter in_mapped_nents > 0. Regards Alex