Received: by 10.223.176.46 with SMTP id f43csp4695169wra; Tue, 23 Jan 2018 13:07:13 -0800 (PST) X-Google-Smtp-Source: AH8x226ts4Q14zewwm8MBeCS/IN8HzTOPLH5InndEV3zTV2WNxByFvVz22qHwzIrKOhoH96N8d3I X-Received: by 10.107.242.14 with SMTP id q14mr5394403ioh.211.1516741633619; Tue, 23 Jan 2018 13:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516741633; cv=none; d=google.com; s=arc-20160816; b=oA+WcC9QA6yBJiT9vTtr++KmR5j/g46FVZGo/bFOTy4E/L2SVIZ/8x8BZTcQBfI7d7 CFdiGnj/XXlSYlQvZLLX8pcEHlGD7j8PB3SsLzGY1vOSHlw+H4Saio2WrVujRbgvbjhj 1X1ZPe4suiYMUVaKNlZUTSppQQ0hxbGLA3/q4Tz4/42Q9iyhvyTNNhle2FuAzX+7f9JA nWU1O9jESH0DMSXWOiErx5i4xEHa+vn/Y55synnAH72odYTryKhfetdxnWdHEay2hhQ9 ooNGf9wy0yxSUIzY05pBQO/y9wIR58leElP75Z0wg2TO0O9XE0JX+dCFa9E8cjhxKrNv bszQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=fwAGsvBrtxONstqQTN68dRvJJABPSuNxe8TV3upOiog=; b=QhHErE2/axxWN71/s+UCShlrXgzZdyHgP9O8G9/w5zEq3AdtPSnZ4ZTTq3hEAgj9Ez RXdN4vWWq0jItIHqMRYUmocKEHEaukie6IjxkIvjZdLp5g1HoByl+p9gLC66ZXx7UmAu 7KXKfRA95+edvPYNvmx8q4Egya10IuzbjbuJ0PhiR9svFfZydnjFMRJyO9LqrKcf9zUC QmAEaKPb/naBnE/MgfWy7kXTW9+J4w+SutGNsySDiy4tVHhieSoE82CE8D4oZZkqbsqO 77fTzdaa0A8SguPNwvpkcVoKNY0O9H7HZxqIsMzoMU9/j7ql9pDJBM3VnsfH7nI9ogZq Wq0w== 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 r69si16497213ioe.299.2018.01.23.13.06.56; Tue, 23 Jan 2018 13:07:13 -0800 (PST) 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 S932184AbeAWVGc (ORCPT + 99 others); Tue, 23 Jan 2018 16:06:32 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:45974 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932085AbeAWVG2 (ORCPT ); Tue, 23 Jan 2018 16:06:28 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ee5lz-0001Ad-Jv; Tue, 23 Jan 2018 14:06:27 -0700 Received: from 97-121-88-104.omah.qwest.net ([97.121.88.104] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ee5ly-0006e7-TV; Tue, 23 Jan 2018 14:06:27 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Cc: Oleg Nesterov , Al Viro , , Ram Pai References: <87373b6ghs.fsf@xmission.com> <87vag6zupo.fsf@xmission.com> <87k1wimybi.fsf_-_@xmission.com> Date: Tue, 23 Jan 2018 15:05:29 -0600 In-Reply-To: <87k1wimybi.fsf_-_@xmission.com> (Eric W. Biederman's message of "Mon, 15 Jan 2018 18:39:29 -0600") Message-ID: <87607s5lra.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1ee5ly-0006e7-TV;;;mid=<87607s5lra.fsf_-_@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.121.88.104;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19Q9NFrglHJxVLTzBXqEbEISeJAHrtNH54= X-SA-Exim-Connect-IP: 97.121.88.104 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.3 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,XMNoVowels autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *; X-Spam-Relay-Country: X-Spam-Timing: total 360 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.3 (0.7%), b_tie_ro: 1.65 (0.5%), parse: 0.76 (0.2%), extract_message_metadata: 10 (2.9%), get_uri_detail_list: 2.2 (0.6%), tests_pri_-1000: 4.4 (1.2%), tests_pri_-950: 1.11 (0.3%), tests_pri_-900: 0.94 (0.3%), tests_pri_-400: 30 (8.2%), check_bayes: 29 (7.9%), b_tokenize: 8 (2.2%), b_tok_get_all: 12 (3.2%), b_comp_prob: 2.4 (0.7%), b_tok_touch_all: 3.4 (1.0%), b_finish: 0.55 (0.2%), tests_pri_0: 304 (84.5%), check_dkim_signature: 0.47 (0.1%), check_dkim_adsp: 2.4 (0.7%), tests_pri_500: 3.7 (1.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 00/10] siginfo infrastructure X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following changes are available at: git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git siginfo-testing This updates the signal sending infrastructure to make it easier to get to the point where we are certain every struct siginfo we send to userspace is fully initialized and thus can be copied verbatim to userspace. Today copy_siginfo_to_user performs a piecewise copy of siginfo to userspace because we don't know that all of the struct siginfo has been initialized. Unfortunately do to bugs not even knowing the proper union member is enough to know that the fields we copy to userspace have all been initialized in every case. The core idiom that needs to be used is: struct siginfo si; clear_siginfo(&si); si.xxx = yyy; ... force_sig_info(SIG_sss, &si, tsk); As the fields for the different union members all need to be initialized this patchset works to make this less error prone by introducing a series of helpers that take the needed fields and properly initialize siginfo before sending it deeper into the signal stack. The helpers are: force_sig_fault force_sig_mceerr force_sig_bnderr force_sig_pkuerr send_sig_fault send_sig_mceer Today I count 227 calls of force_sig_info and send_sig_info in the kernel. After the helpers introduced here are used in the obvious places to use them the count shrinks to just 43. Something that is much more reasonable to maintain and to audit to ensure all of the details are just so. This changeset does not include all of the architecture changes as that is still a large set of changes that needs to be reviewed carefully. I expect those to be post 4.17 material. While the infrastrcture can go in in 4.16. In addition to the helpers a several general cleanups happen to help ensure that all instances of struct siginfo are intialized. Eric W. Biederman (10): ptrace: Use copy_siginfo in setsiginfo and getsiginfo signal/arm64: Better isolate the COMPAT_TASK portion of ptrace_hbptriggered signal: Don't use structure initializers for struct siginfo signal: Replace memset(info,...) with clear_siginfo for clarity signal: Add send_sig_fault and force_sig_fault signal: Helpers for faults with specialized siginfo layouts signal/powerpc: Remove unnecessary signal_code parameter of do_send_trap signal/ptrace: Add force_sig_ptrace_errno_trap and use it where needed mm/memory_failure: Remove unused trapno from memory_failure signal/memory-failure: Use force_sig_mceerr and send_sig_mceerr arch/arc/kernel/traps.c | 14 ++- arch/arm/kernel/ptrace.c | 8 +- arch/arm64/kernel/debug-monitors.c | 13 ++- arch/arm64/kernel/ptrace.c | 42 +++---- arch/m68k/mm/fault.c | 3 +- arch/mips/kernel/traps.c | 29 +++-- arch/parisc/kernel/pdt.c | 2 +- arch/powerpc/include/asm/debug.h | 2 +- arch/powerpc/kernel/process.c | 13 +-- arch/powerpc/kernel/traps.c | 12 +- .../powerpc/platforms/powernv/opal-memory-errors.c | 2 +- arch/tile/kernel/single_step.c | 24 ++-- arch/tile/kernel/traps.c | 4 +- arch/tile/kernel/unaligned.c | 46 ++++---- arch/um/kernel/trap.c | 2 +- arch/x86/kernel/cpu/mcheck/mce.c | 6 +- arch/xtensa/kernel/ptrace.c | 8 +- drivers/acpi/apei/ghes.c | 2 +- drivers/base/memory.c | 2 +- drivers/ras/cec.c | 2 +- drivers/usb/core/devio.c | 4 +- include/linux/mm.h | 4 +- include/linux/sched/signal.h | 28 +++++ kernel/ptrace.c | 4 +- kernel/seccomp.c | 2 +- kernel/signal.c | 126 ++++++++++++++++++++- kernel/time/posix-timers.c | 2 +- mm/hwpoison-inject.c | 2 +- mm/madvise.c | 2 +- mm/memory-failure.c | 48 ++++---- 30 files changed, 305 insertions(+), 153 deletions(-) Eric