From patchwork Wed Oct 31 23:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149884 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp96536ljp; Wed, 31 Oct 2018 16:05:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5e+9SgcP3e8efhHKgDrYKAfqN9AV2hTHEbcO4vMiOa1Cw/5njy4cNnSebEVroe2jA6Vr5ZW X-Received: by 2002:a62:62c3:: with SMTP id w186-v6mr5290180pfb.5.1541027145454; Wed, 31 Oct 2018 16:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027145; cv=none; d=google.com; s=arc-20160816; b=KCLt9N0fSpVmzqcU3cAAtW46JEmIu7eAk9bq3Y6kqnY7fyMpBQk+Qqgb+tVoTQc0Nm j8QHx5FBxAL3fvAmqJi4vQNMmxM5QRKDwcfb71HyzN7OSzu1TffiLi5kAMKW7Z1ZDBxS a4M1WKhIO6/nZS3JGffIFVBdt46iHaerrIunVgJj9K3N9bZ4N42i9i5m8DZYWNoqyk/X T8HLiR53WsK3ntvi6/qQwFLN9coexaSxRjaFx2yf26ib+yotHvDENa9K5UvnqPz++4SI bx1m5vc3PSySAuv5kLK1qX+v778uQmYTxzX/DAx6cxsFvKTSoeHzBKVJQ0UebI6acsca IWcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=fdzo3JVVvYpRas46erm1kDvqaAZ4rlmAMJQORzW/1ss=; b=szCPkKIpXwqFilp2niyzZByFLw/jLZ8GrulgpVp4+37hvZlT8skmUEfjsz1AZg/bYY gRMNvqwL33sQZVC1ODz6WEdzLCKjWwjSsKlOHIzR7x0V1wdzE2nxr/SNWIWjj9644sFR ESS7bj6f6yyQpDjBAg0UojlCDe50PmazFgq1QS62yDGm3Z8bQjJwy0I4rDKtRNW3AApd XnjQ/mQf/9iFrB5ejEdHgQ/6910hgCUmkJxQZqd/bT4LjSOjdzDYmRBzBkTzBmubeGXV nI+XpaDbdCc/DSDv4KGqi+rh1/19ocZ0+9gv0a/zTBaCKQYDhCrMEDctjzJKoBGPQIDY bH9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B9YM54d8; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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. [209.132.180.67]) by mx.google.com with ESMTP id m26-v6si13205954pfe.80.2018.10.31.16.05.45; Wed, 31 Oct 2018 16:05:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B9YM54d8; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1725986AbeKAIFy (ORCPT + 15 others); Thu, 1 Nov 2018 04:05:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:52496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbeKAIFy (ORCPT ); Thu, 1 Nov 2018 04:05:54 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A28420664; Wed, 31 Oct 2018 23:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027143; bh=tin9VUn5KBBLYgnFfPiCXX+PD8SLNdQ9X2aZueU12go=; h=From:To:Cc:Subject:Date:From; b=B9YM54d8eUvfjAoZuOpjvyOl4C0G6SSFCGsYSw+BTwQHQDJhOmZppUYmIBCDT7hUy jE+m2KjqCQFdXj5/6YCkL/w9JDPouyBG1bhwfy5IYjphVX4+5f48HTBO1KEl1x3jQ4 eQOZO6+VdbJF/XSnJkPdggFSxUepQSpcLG1Wz9ms= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Masahisa Kojima , Yoshitoyo Osaki , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 001/146] net: socionext: Reset tx queue in ndo_stop Date: Wed, 31 Oct 2018 19:03:16 -0400 Message-Id: <20181031230541.28822-1-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Masahisa Kojima [ Upstream commit 8d5b0bf611ec5b7618d5b772dddc93b8afa78cb8 ] We observed that packets and bytes count are not reset when user performs interface down. Eventually, tx queue is exhausted and packets will not be sent out. To avoid this problem, resets tx queue in ndo_stop. Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/socionext/netsec.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 4289ccb26e4e..d2caeb9edc04 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -940,6 +940,9 @@ static void netsec_uninit_pkt_dring(struct netsec_priv *priv, int id) dring->head = 0; dring->tail = 0; dring->pkt_cnt = 0; + + if (id == NETSEC_RING_TX) + netdev_reset_queue(priv->ndev); } static void netsec_free_dring(struct netsec_priv *priv, int id) From patchwork Wed Oct 31 23:03:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149886 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp96998ljp; Wed, 31 Oct 2018 16:06:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5c/DIYyP08MQ80H1nZWuGpbo3To6NHLiy8D93pbfZaTRQg4ziHq4rydUUyibWAYPfzEmr1r X-Received: by 2002:a63:fd58:: with SMTP id m24-v6mr5024481pgj.132.1541027169471; Wed, 31 Oct 2018 16:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027169; cv=none; d=google.com; s=arc-20160816; b=r6JxHoPOsHGvdDgzRcCqgbVTUPXda2fbCv0E9wpqY8fVns+TVLj1rKRLFYZXPjp+er wtWw8PsOBA/TqsicuoBz+ftWlfrx+jX4vld1uwDPKL5pSb6zOZiWFGU1Jb1dh5O+IhtZ NTqrGowdjB9k8GLZ6Q04PHqWct57joZTiWOdoRE4HtJKDCHzPtu5UbblgsI42NY7KMh5 fSrOPOoVleaCiEYxA5U/wHyPvO+Hh+pIslwKOANdIuCwLhIbeUxU5Zo6r5XFhGr2iE+t sGDefIDC8w8DSrODT7V4CrQ5yfs9I5mhYRZkPOzZmIpE36pXI1JQmw8iQIs+4bCjwXoB ZNeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=pvuMmfN1K4TUd7AE+lJ0UA/xNURe31Z9bxpOFNQhAnE=; b=eNkeN9xOovC+DHUTwAOj3oFvn99pBfY2O3FPQI6etAt9r5KyWi/7w3n/sLY7RDBW+E NSkzgbZIRpm/apO+r4JUogXld8bhdEh09lT8wvRl4UPq6vFroiljwMUuDGdFSq/vHSpL 1N/FuHzDfsy9xaiDGLUsDWXppxrRDHLw0y1Fli+UDb69yLpHznnpHQwk631NuEhqqxWX yYW130yMH78UD2E99yS9topw7Hx85xt1zd4dtAg43xzPsJ1ToDuERHqPt8o6NRxkHLBL lPbTV1MnUbdQemTf60nYScbeW1D00vL/CV913nxQjDFtx3sgEvLAp/sBjoe4fYgisMsy LDTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KMq1N/2q"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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. [209.132.180.67]) by mx.google.com with ESMTP id a23-v6si7930715pls.322.2018.10.31.16.06.09; Wed, 31 Oct 2018 16:06:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KMq1N/2q"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1727753AbeKAIGR (ORCPT + 15 others); Thu, 1 Nov 2018 04:06:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbeKAIGR (ORCPT ); Thu, 1 Nov 2018 04:06:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E43A72082E; Wed, 31 Oct 2018 23:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027166; bh=tuEJvDI3bM0wRAyEI8FVDVYwZNrGh0rzXm4cwq5rC7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMq1N/2qXJm8WpusQ3jRJcW4/LNP2XD0w1WpvresoAkSRZjGVbcnDoVlzuZUMv2U2 m3DHsHZ+V7J+2nL+PLPx1c52fmp5YPQZXDy8r28UEPTw5HCPXBSnQwZt1L6WH0mAIN Ajql6lPjgkbMfKyV6CAkji4xQ/bvStW9T45WW1i8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Masahiro Yamada , Miquel Raynal , Sasha Levin Subject: [PATCH AUTOSEL 4.19 026/146] mtd: rawnand: denali: set SPARE_AREA_SKIP_BYTES register to 8 if unset Date: Wed, 31 Oct 2018 19:03:41 -0400 Message-Id: <20181031230541.28822-26-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Masahiro Yamada [ Upstream commit 0d55c668b218a1db68b5044bce4de74e1bd0f0c8 ] NAND devices need additional data area (OOB) for error correction, but it is also used for Bad Block Marker (BBM). In many cases, the first byte in OOB is used for BBM, but the location actually depends on chip vendors. The NAND controller should preserve the precious BBM to keep track of bad blocks. In Denali IP, the SPARE_AREA_SKIP_BYTES register is used to specify the number of bytes to skip from the start of OOB. The ECC engine will automatically skip the specified number of bytes when it gets access to OOB area. The same value for SPARE_AREA_SKIP_BYTES should be used between firmware and the operating system if you intend to use the NAND device across the control hand-off. In fact, the current denali.c code expects firmware to have already set the SPARE_AREA_SKIP_BYTES register, then reads the value out. If no firmware (or bootloader) has initialized the controller, the register value is zero, which is the default after power-on-reset. In other words, the Linux driver cannot initialize the controller by itself. Some possible solutions are: [1] Add a DT property to specify the skipped bytes in OOB [2] Associate the preferred value with compatible [3] Hard-code the default value in the driver My first attempt was [1], but in the review process, [3] was suggested as a counter-implementation. (https://lore.kernel.org/patchwork/patch/983055/) The default value 8 was chosen to match to the boot ROM of the UniPhier platform. The preferred value may vary by platform. If so, please trade up to a different solution. Signed-off-by: Masahiro Yamada Reviewed-by: Boris Brezillon Signed-off-by: Miquel Raynal Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/denali.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index b864b93dd289..2242e999a76b 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -28,6 +28,7 @@ MODULE_LICENSE("GPL"); #define DENALI_NAND_NAME "denali-nand" +#define DENALI_DEFAULT_OOB_SKIP_BYTES 8 /* for Indexed Addressing */ #define DENALI_INDEXED_CTRL 0x00 @@ -1105,12 +1106,17 @@ static void denali_hw_init(struct denali_nand_info *denali) denali->revision = swab16(ioread32(denali->reg + REVISION)); /* - * tell driver how many bit controller will skip before - * writing ECC code in OOB, this register may be already - * set by firmware. So we read this value out. - * if this value is 0, just let it be. + * Set how many bytes should be skipped before writing data in OOB. + * If a non-zero value has already been set (by firmware or something), + * just use it. Otherwise, set the driver default. */ denali->oob_skip_bytes = ioread32(denali->reg + SPARE_AREA_SKIP_BYTES); + if (!denali->oob_skip_bytes) { + denali->oob_skip_bytes = DENALI_DEFAULT_OOB_SKIP_BYTES; + iowrite32(denali->oob_skip_bytes, + denali->reg + SPARE_AREA_SKIP_BYTES); + } + denali_detect_max_banks(denali); iowrite32(0x0F, denali->reg + RB_PIN_ENABLED); iowrite32(CHIP_EN_DONT_CARE__FLAG, denali->reg + CHIP_ENABLE_DONT_CARE); From patchwork Wed Oct 31 23:03:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149889 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp97276ljp; Wed, 31 Oct 2018 16:06:24 -0700 (PDT) X-Google-Smtp-Source: AJdET5fx/EOL7TLxucvsrRxI4vWI6g6CwCT0f/li2vq/0BUt+BZrh4LpH2EUMVDzTH+ey2PGQ09e X-Received: by 2002:a17:902:860a:: with SMTP id f10-v6mr5244901plo.96.1541027184454; Wed, 31 Oct 2018 16:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027184; cv=none; d=google.com; s=arc-20160816; b=mHaj+UlAMvUAsMSDnNNLESEY60/VjokCJzV6Qprn3wx5tkv2f4yQZnt7euFNzhA7uB VZuGRrXTNER2JlsQ1YDlNsIzQoOijiqqiw9EOy3f3cbseOujLqWOttdm6mglpb/pHncZ urxijvXTH+jRU7rJD5h7TYssuOgTwr1/9F22x1tpfIMBN9yE3zDTr4avvBJHxzORn/QL wp+vWgSyQLOUMOtUwhyNN8MNfBRmfLarL7DJ0llQZSy2OejZeWLsj0vj5rx0YnCl0chq a5BTfEqhu0FaKfRFEEeYzJ+HhDAStxyzrgVnSA6CgKgioran/+r9cYSlnL8zUCtvHQfe xpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gpaxxmyCSKdjZhQdoDKaPRq+2VzTXdsIR009LNIRRG0=; b=0VJAFVS0D6jVdwpxMzumSACpX62+jEWcVjYo10jin1M20ATfGMHsoRYYpuks7M+x++ ICeXtWybISXta1mC6sL5FEqPsJiOgRoXiodGLAWeLMD9nE7kJu0ntrDHgxndOXP3EzSx l9VKluOW7QQ5dlrrpfJamceKIV+IsKGegDJHkRFm+f17hG2B2dC0P5K8sWi4WAfFAjx4 5/fVk3B1xfIFVdYzUPraqkXk4lbF7PnS3o7C6F5a3NYebs8/SAmSftNkiIwNPUmor8xe L3bV7XCvvtpvkhu4Ix4oHuJqsPA8bBp2npBkZSdup/BVWbddTejgMqkfrZ7Ux81VMwx0 ZQSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xek6CXhM; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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. [209.132.180.67]) by mx.google.com with ESMTP id p4-v6si26875008plk.263.2018.10.31.16.06.23; Wed, 31 Oct 2018 16:06:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xek6CXhM; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1728062AbeKAIGc (ORCPT + 15 others); Thu, 1 Nov 2018 04:06:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:53400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728043AbeKAIGa (ORCPT ); Thu, 1 Nov 2018 04:06:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8E7D820830; Wed, 31 Oct 2018 23:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027180; bh=d3jqBbn/9Poqv+I1jgwvudd2LkeSuMY+WqtBmXR3PZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xek6CXhMUK8Oq2vs+bkrspkfKWceaDsE818ldUN7IAo8RB20nmODw6ivbJQPDgjfz 24vT0XjMjYwlAtDoJ4nmzB/UD6E5RFCy0q5V59U20stQ36B9ifQF7rHfEEj948OQb4 3WZCHRscBCOK0F4TIECMd6/MMhN8GmjiYD/sLQVE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Will Deacon , Arnd Bergmann , Dominik Brodowski , "Eric W. Biederman" , Andrew Morton , Al Viro , Oleg Nesterov , Catalin Marinas , Sasha Levin Subject: [PATCH AUTOSEL 4.19 042/146] signal: Introduce COMPAT_SIGMINSTKSZ for use in compat_sys_sigaltstack Date: Wed, 31 Oct 2018 19:03:57 -0400 Message-Id: <20181031230541.28822-42-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon [ Upstream commit 22839869f21ab3850fbbac9b425ccc4c0023926f ] The sigaltstack(2) system call fails with -ENOMEM if the new alternative signal stack is found to be smaller than SIGMINSTKSZ. On architectures such as arm64, where the native value for SIGMINSTKSZ is larger than the compat value, this can result in an unexpected error being reported to a compat task. See, for example: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=904385 This patch fixes the problem by extending do_sigaltstack to take the minimum signal stack size as an additional parameter, allowing the native and compat system call entry code to pass in their respective values. COMPAT_SIGMINSTKSZ is just defined as SIGMINSTKSZ if it has not been defined by the architecture. Cc: Arnd Bergmann Cc: Dominik Brodowski Cc: "Eric W. Biederman" Cc: Andrew Morton Cc: Al Viro Cc: Oleg Nesterov Reported-by: Steve McIntyre Tested-by: Steve McIntyre <93sam@debian.org> Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- include/linux/compat.h | 3 +++ kernel/signal.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/linux/compat.h b/include/linux/compat.h index 1a3c4f37e908..de0c13bdcd2c 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -103,6 +103,9 @@ typedef struct compat_sigaltstack { compat_size_t ss_size; } compat_stack_t; #endif +#ifndef COMPAT_MINSIGSTKSZ +#define COMPAT_MINSIGSTKSZ MINSIGSTKSZ +#endif #define compat_jiffies_to_clock_t(x) \ (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) diff --git a/kernel/signal.c b/kernel/signal.c index 5843c541fda9..e4aad0e90882 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3460,7 +3460,8 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) } static int -do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp) +do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp, + size_t min_ss_size) { struct task_struct *t = current; @@ -3490,7 +3491,7 @@ do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp) ss_size = 0; ss_sp = NULL; } else { - if (unlikely(ss_size < MINSIGSTKSZ)) + if (unlikely(ss_size < min_ss_size)) return -ENOMEM; } @@ -3508,7 +3509,8 @@ SYSCALL_DEFINE2(sigaltstack,const stack_t __user *,uss, stack_t __user *,uoss) if (uss && copy_from_user(&new, uss, sizeof(stack_t))) return -EFAULT; err = do_sigaltstack(uss ? &new : NULL, uoss ? &old : NULL, - current_user_stack_pointer()); + current_user_stack_pointer(), + MINSIGSTKSZ); if (!err && uoss && copy_to_user(uoss, &old, sizeof(stack_t))) err = -EFAULT; return err; @@ -3519,7 +3521,8 @@ int restore_altstack(const stack_t __user *uss) stack_t new; if (copy_from_user(&new, uss, sizeof(stack_t))) return -EFAULT; - (void)do_sigaltstack(&new, NULL, current_user_stack_pointer()); + (void)do_sigaltstack(&new, NULL, current_user_stack_pointer(), + MINSIGSTKSZ); /* squash all but EFAULT for now */ return 0; } @@ -3553,7 +3556,8 @@ static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr, uss.ss_size = uss32.ss_size; } ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, - compat_user_stack_pointer()); + compat_user_stack_pointer(), + COMPAT_MINSIGSTKSZ); if (ret >= 0 && uoss_ptr) { compat_stack_t old; memset(&old, 0, sizeof(old));