Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1206716imm; Tue, 15 May 2018 15:44:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqzIgd8T67YUCLOAu6Jc1rfUGDxZ/jEVqV7ukanpKhqg/yjzE4IYhC4flmdg6X1R2oSqIK7 X-Received: by 2002:a65:6414:: with SMTP id a20-v6mr13889733pgv.226.1526424297180; Tue, 15 May 2018 15:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526424297; cv=none; d=google.com; s=arc-20160816; b=kVoiel/sYN5n17AC6sqnl8JbkXvEgtX+OgNP2D3REDqQqjtff6ipJFAoY3s/z03uYq ZOuuWx2yIIFxfoDEGr1ZHIWClCbI4y1fqbA972SC4nHr9ToURygDcKWk0536IgIsedAO rORAoEV8ALrcvC/cXIcuc5bc1hNkOE/NwwtVECUa0QVtpIYjJPmaB/YrP+Tgqg6l2Zrx SoyxUV8feMv+3nIiY/8PD0ROZuoIFZBZr6JmANeIphW87EtLcAJrk5X0K8tkP3jGJ7nQ b+FAGpk+z2SIJTKHB6I9EueBVjHBGgzkwPe7fGje8/S+PZYPF8RQAwqnKy9LfxhiPKSm mWqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=XoCvDIsgMVBgNq0YqbhRFBtXXbnsPD1vimVOgvo3GgQ=; b=o3v+oSK1FIure99FhC5+t5WRCIz7xR2Ju4DW6v58xHFC0RRdF62t4xT+B9Phsglriz +yWBl2AN8FxaLojwilAGIrjA5XLWyCNUajJplCojK6bTq3oFlvNK0pzH/jMXW+mVo0OE tfGWt96Gi/Hfu3ojbC9hr/Nsc6Fcx3QNXmsxtaMmj5zDC1t6v3IhnV8ezpEonTBzz4nB eiszGE+gf4SsIUZDeyWONfZe4yDwAgjswR6hqrr7rQZflCFvLh5Jt9KXSM7sivdznqpb r5t9Y3/CJrTzmruiwdfPJCwmqF/JjL1OnJ2R5AYhGm46kU2dQKvJpdenwnFpwxTg9gDS 6j8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6-v6si1042391pll.21.2018.05.15.15.44.42; Tue, 15 May 2018 15:44:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbeEOWoX (ORCPT + 99 others); Tue, 15 May 2018 18:44:23 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.150.224]:51952 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbeEOWoV (ORCPT ); Tue, 15 May 2018 18:44:21 -0400 X-Greylist: delayed 669 seconds by postgrey-1.27 at vger.kernel.org; Tue, 15 May 2018 18:43:56 EDT Received: from mipsdag02.mipstec.com (mail2.mips.com [12.201.5.32]) by mx4.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); Tue, 15 May 2018 22:43:51 +0000 Received: from [10.20.78.107] (10.20.78.107) by mipsdag02.mipstec.com (10.20.40.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Tue, 15 May 2018 15:33:23 -0700 Date: Tue, 15 May 2018 23:32:45 +0100 From: "Maciej W. Rozycki" To: Alexander Viro , James Hogan CC: Ralf Baechle , , , , Subject: [PATCH 1/3] binfmt_elf: Respect error return from `regset->active' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [10.20.78.107] X-ClientProxiedBy: mipsdag02.mipstec.com (10.20.40.47) To mipsdag02.mipstec.com (10.20.40.47) X-BESS-ID: 1526424196-298555-22307-24440-2 X-BESS-VER: 2018.6-r1805102334 X-BESS-Apparent-Source-IP: 12.201.5.32 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.193020 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The regset API documented in defines -ENODEV as the result of the `->active' handler to be used where the feature requested is not available on the hardware found. However code handling core file note generation in `fill_thread_core_info' interpretes any non-zero result from the `->active' handler as the regset requested being active. Consequently processing continues (and hopefully gracefully fails later on) rather than being abandoned right away for the regset requested. Fix the problem then by making the code proceed only if a positive result is returned from the `->active' handler. Cc: stable@vger.kernel.org # 2.6.25+ Fixes: 4206d3aa1978 ("elf core dump: notes user_regset") Signed-off-by: Maciej W. Rozycki --- Hi, Overall we could also use the count returned by ->active to limit the size of data requested, i.e. something along the lines of: ssize_t size; if (regset->active) size = regset->active(t->task, regset); else size = regset_size(t->task, regset); if (size > 0) { ... however that would be an optimisation that belongs to a separate change, which (due to the need to unload stuff I have in progress already) I am not going to make at this point. Perhaps someone else would be willing to pick up the idea. Anyway, please apply. Maciej --- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) linux-elf-core-regset-active.diff Index: linux-jhogan-test/fs/binfmt_elf.c =================================================================== --- linux-jhogan-test.orig/fs/binfmt_elf.c 2018-03-21 17:14:55.000000000 +0000 +++ linux-jhogan-test/fs/binfmt_elf.c 2018-05-09 23:25:50.742255000 +0100 @@ -1739,7 +1739,7 @@ static int fill_thread_core_info(struct const struct user_regset *regset = &view->regsets[i]; do_thread_regset_writeback(t->task, regset); if (regset->core_note_type && regset->get && - (!regset->active || regset->active(t->task, regset))) { + (!regset->active || regset->active(t->task, regset) > 0)) { int ret; size_t size = regset_size(t->task, regset); void *data = kmalloc(size, GFP_KERNEL);