Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp481312imn; Wed, 27 Jul 2022 11:24:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vtChsEpf93VClF4t+Cofs2JVUuvPlKVKULplbjDwMVnBZ4IAdLIiGXTWXA7/d6Qh45Kccc X-Received: by 2002:a17:906:9b14:b0:72b:7c96:58c9 with SMTP id eo20-20020a1709069b1400b0072b7c9658c9mr18701547ejc.648.1658946270279; Wed, 27 Jul 2022 11:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946270; cv=none; d=google.com; s=arc-20160816; b=vJ9lMKfA/f4ehBIndeap2l5xn49Cq21SnUNWcqmwbODg07or4WD1vOmvjLKUyWX8OS 9ZbzFoJPEkqCTJ1cf2zJr7jBpoYaCEhAJYklj6ch5BMmIu0Wj2151G5QS9D5m9JV6qLp VsSkd4Egv/QAgwbX9+g8x7sq/NiFYCEvR78HqFCXZ0UNzHbruSWA0dvdPkeT5NzeWC3R fJVT3Zd5icGdGGuhFXxrgDM/Bud/PbSiQirT96uKn7hoa0I3cJD0n53CDSkGqKVKXrlM yJMeV0OPK5EE2aRyC4/2Nlhk8X1h7692AKFLW5iw4v6WSrgiS0jaR8yV0wn47sMvH7pw zQwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sxT14qKYI8Tg4dfO2Qol0qYqjiaOhZaHiIWym5n1ysU=; b=WaUPFWrAm+n09Hiis4xem6LRz1h6YiosN5JJmybNLzv9yWPQT/WeehEuklpnKjqcPX jz68uIEKlTdxFx6uiKrZuw9g7MeyQNmdbkAAa7hJg3f0YExKQHybGqaTukQ6xLdScwzh vNxVrXc+eePmx4DKSbGjvvPiGQAnKgRT9oOSvUNxR0oYBs24uzXh2qeUMeHjAx4QxRzk 8PCHlWhYNntiocXjss/lYv279bNm1KuPyk0uzPw49bMiTrxWafDFE1Px0srQjPSlMg80 0txA4FOpKm9e0SBUSnIjok5jDudJul6BCKOk2XtfL5vn2RoVbLyH24GeIXRaVx0zOcO1 BhRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R0bLRql+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw15-20020a170906478f00b0072f36fddba7si22670709ejc.812.2022.07.27.11.24.05; Wed, 27 Jul 2022 11:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R0bLRql+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240282AbiG0QpQ (ORCPT + 99 others); Wed, 27 Jul 2022 12:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240212AbiG0QoM (ORCPT ); Wed, 27 Jul 2022 12:44:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14063BC06; Wed, 27 Jul 2022 09:30:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 97D18619FD; Wed, 27 Jul 2022 16:30:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6111C433D7; Wed, 27 Jul 2022 16:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939449; bh=0nPcMk7X2zRWW6IEONlkgBKjawbM0P/bEPivCLl7JwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0bLRql+90Ym3LF+bTVxOQ+Ly7ruLKS6FS4eI7Dmdcshn24QfQkHO5S/7PAmYm9yq XC1tgLQ8A/lbGawh26Djck7TG/djGGSY7pugBLnpQuvyRYHElZ3L9XlLTfLj2cGWj8 3VJyMP0Fx0eA5ExnydGsvZa0P2Cfipi1F9ncEQJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars-Peter Clausen , Takashi Iwai Subject: [PATCH 5.4 73/87] ALSA: memalloc: Align buffer allocations in page size Date: Wed, 27 Jul 2022 18:11:06 +0200 Message-Id: <20220727161012.026313331@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161008.993711844@linuxfoundation.org> References: <20220727161008.993711844@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit 5c1733e33c888a3cb7f576564d8ad543d5ad4a9e upstream. Currently the standard memory allocator (snd_dma_malloc_pages*()) passes the byte size to allocate as is. Most of the backends allocates real pages, hence the actual allocations are aligned in page size. However, the genalloc doesn't seem assuring the size alignment, hence it may result in the access outside the buffer when the whole memory pages are exposed via mmap. For avoiding such inconsistencies, this patch makes the allocation size always to be aligned in page size. Note that, after this change, snd_dma_buffer.bytes field contains the aligned size, not the originally requested size. This value is also used for releasing the pages in return. Reviewed-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20201218145625.2045-2-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/memalloc.c | 1 + 1 file changed, 1 insertion(+) --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -124,6 +124,7 @@ int snd_dma_alloc_pages(int type, struct if (WARN_ON(!device)) return -EINVAL; + size = PAGE_ALIGN(size); dmab->dev.type = type; dmab->dev.dev = device; dmab->bytes = 0;