Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp315735imm; Thu, 5 Jul 2018 00:22:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeOPPNz8M/1yhpkLka8OvG/dXH+7YROfdmfZ8JnHKurCkGUVBYaP0I7TBa/rNtGinjWSPK1 X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr4969944plk.172.1530775357406; Thu, 05 Jul 2018 00:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530775357; cv=none; d=google.com; s=arc-20160816; b=CgMHROur4xfkgtR+CjQOXCaPDriFm5xicqpeeYjNnIHerXa4If5GxwUf534GUc5InN QJZoBfqmaZrllQ4Od9UDrQZ/i83Y2lEAfBPjViYfqzYaMQTZ48be/fu4tTFvOVIRHogR sxfUYte7DWxc2PPUUzj32Q+uYFGRazYsmA8TeyZ2Cf0x02t5y5JbJ+6li7BrbXCRcyiM rvPNS4dlHg+LjRYLJ3sAS5Qy2+jxTNM10bXQ50+bdjZcfhhl4JiP0K7A9YhD5b8DzuDs ckm8Mgh6D37jdzO63McdegsUbmVtEH7AO8zHvThDo6vtQMXNH4HehYXkPVtkJcNr+Orh Npig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MFwvfd9B6uyq9+CAIJGVH0iY1Ew777Hv/VhE5ZSDRgk=; b=JxamKY0aSaG2JBVjESMVq8DrSCpkZ2H3w1nsivrJWso3NT09sCMlK13O5OCO4DPzS2 y6eiFTdL0sQDtoJLxtRt0HHCvjlMsooTrAZsQHGHzZOac37t5LtK8SzZGO4DQ8zV5ll1 WNIevfkEDG1vbu5cH0oZ6q2VCj7Gm6FOYf0O1EynSzXUQdCOa9ILPlVNjKdSLWB4ja2C RyntcmwzfrDbnc+npa0gzX7c2ft5YqYqV5tZzV1KRcPPObT93tCs+njtKxWoPllfw3Vw capk24BBzYJ70LFgqtMVmQkKljUUsVfk8t26HCQjNcSAguVkD1NpOl9tl9LMp7qhn1i5 6gCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ldGpOKqF; 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; dmarc=fail (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 d34-v6si5330046pld.252.2018.07.05.00.22.22; Thu, 05 Jul 2018 00:22:37 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ldGpOKqF; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753353AbeGEHVj (ORCPT + 99 others); Thu, 5 Jul 2018 03:21:39 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:54436 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753172AbeGEHVf (ORCPT ); Thu, 5 Jul 2018 03:21:35 -0400 Received: by mail-wm0-f50.google.com with SMTP id i139-v6so9195141wmf.4; Thu, 05 Jul 2018 00:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MFwvfd9B6uyq9+CAIJGVH0iY1Ew777Hv/VhE5ZSDRgk=; b=ldGpOKqFspxxemifysGMKwAN2fRz0xs320lk9ZAutZhhUINjjgCOUNM72rV6DkLs2v 6S3nE6UgT83ybmUuxqdOY5mgEbYVfSCMg//fB7yThwXulSZGCMDCa/GGmXQ78Fxmx4IP TeF3KezdA6MOnqXVOurVYYmyZ/tmlhBNQTHOGndfinePG2XDEXn+aW4Yua/7xnIDWd77 FFd7HkgwROqekOssf/4C7cwmXl6XIVNYlEw3SS169z/MZpiZN5ETlozWO1+8VVl1AGLc 9EKAu9k/4n/96fUMUlbUxXMB5R/Z9l8dfhkvHfiEarjrYTBp/DstE9uUvUTJ/O+A6eHh ReBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MFwvfd9B6uyq9+CAIJGVH0iY1Ew777Hv/VhE5ZSDRgk=; b=Cf761eeJFt0TKa5DYJgIarcZ3tEcuE0xNeXqOHIurKVhfjh155NM+1Hcv8CVArq/7R JS8Ff/5g5r1WLRTmTyhLepYmPDo3Jkh6vB9xYd3W334LhTh4lSLCItSYlD0YXCX/B64u WxxfRkbTonill+msQCpHbO/s9ed8nXb6F9HaZVqVjtjSeulPa+57GzkaGa64c2f80T5B dh+VTQ7SIIrCFm6r9k+rd/ONjesrHwKqx1EnLy+aRcdKlYl15YxTizrqr8MBvB16cA6h iUhP4feH3HNL9FIIXM1IiPdwLUp9WD4JBSZxQW2AxJ0s1eoLSCLsqPS1cl/6wLqBLqQX oIvA== X-Gm-Message-State: APt69E2K0cWBnpr1giiBjlTbCMkfdomftcYHMKv7Y/rmVjLItNFreAh6 huZWuo86kdSMTpzdRMZIVvo= X-Received: by 2002:a5d:528f:: with SMTP id c15-v6mr3603718wrv.102.1530775293723; Thu, 05 Jul 2018 00:21:33 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id s17-v6sm4050217wmc.34.2018.07.05.00.21.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jul 2018 00:21:33 -0700 (PDT) Date: Thu, 5 Jul 2018 09:21:30 +0200 From: Ingo Molnar To: Kees Cook Cc: Daniel Borkmann , David Miller , Thomas Gleixner , syzbot+a4eb8c7766952a1ca872@syzkaller.appspotmail.com, Alexei Starovoitov , "H. Peter Anvin" , Alexey Kuznetsov , LKML , Ingo Molnar , Network Development , syzkaller-bugs@googlegroups.com, X86 ML , Hideaki YOSHIFUJI , Peter Zijlstra , Laura Abbott , Linus Torvalds , Eric Dumazet , Rik van Riel , Ard Biesheuvel Subject: Re: set_memory_* (was: Re: BUG: unable to handle kernel paging request in bpf_int_jit_compile) Message-ID: <20180705072130.GA4534@gmail.com> References: <000000000000d48c8e056f5b6c67@google.com> <20180624.161411.1560796210597132716.davem@davemloft.net> <20180624100249.GA9493@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Kees Cook wrote: > On Tue, Jun 26, 2018 at 3:53 PM, Daniel Borkmann wrote: > > In any case, for pairs like set_memory_ro() + set_memory_rw() that are also used > > outside of bpf e.g. STRICT_MODULE_RWX and friends which are mostly default these > > days for some archs, is the choice to not check errors from there by design or from > > historical context that it originated from 'debugging code' in that sense (DEBUG_RODATA / > > DEBUG_SET_MODULE_RONX) earlier? Also if no-one checks for errors (and if that would > > infact be the recommendation it is agreed upon) should the API be changed to void, > > or generally should actual error checking occur on these + potential rollback; but > > then question is what about restoring part from prior set_memory_ro() via set_memory_rw()? > > Kees/others, do you happen to have some more context on recommended use around this > > by any chance? (Would probably also help if we add some doc around assumptions into > > include/linux/set_memory.h for future users.) > > If set_memory_* can fail, I think it needs to be __must_check, and all > the callers need to deal with it gracefully. Those markings aren't > "advisory": they're expected to actually do what they say. Yes - but there's probably a few exceptions like early init code where the calls not succeeding are signs of bugs - so any error return should probably be WARN_ON()ed about. Thanks, Ingo