Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp729062imm; Thu, 13 Sep 2018 06:56:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZs78ySnuJ+rA2X63UBn41tj27kjxCu2gZOjJ3bRrg/1EcaNc5vIkx/HMlNuo6zesz2KK5+ X-Received: by 2002:a63:d244:: with SMTP id t4-v6mr7196674pgi.335.1536846998944; Thu, 13 Sep 2018 06:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846998; cv=none; d=google.com; s=arc-20160816; b=rrP0vReVHbGEexetKcB9kgdtKk2UotaKA8ncHU2kCBeNWZ5Ta0eU0p3vBZnj3KI5sf DqGu0kWvBJu59qhnWmtcD8qgwPa1z/MKfJ1JlWFaZJ1/7EMcJveEhDq6Nqldek/wyPzz 75qBUGJ8tJwX/59BetbxVaAqLYJG8TK2dLp+kgE79P2csf3ZPmcE4pveOtgXM9N4vHxF IcDbaDVtyM78/lQ/y2OKjvy7yyBsgBzNF/MRlCIbJc8DjQqrLJUgLtd8vHv91LJ+xPOa mf388dehs3OkqTiceaf11Q7QK1xDmZYzfiV8hFaLbxwiRg/KmlhFC6MrIFjLWR4xuCFF 9kpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=yVb0hCaaCtjBvgu5y3NmDcMyMMbu9AbWmabauf+L/zg=; b=dfsogNWTPmnYgolX4KargGikO35XIx75lFwque97YN4dK16V0Ff8hWknSDeVHpcNTh bk7tVrCUMcj7HHw0NrfvtXk7rEp2TIJsH1f2Yf2naZA9DXpbzWUdCnEBoC6SJgcBszFG VRnbh/TMz0eXkOyxO7cRZruK7xA7aqB5Frc3uHHR9NKe678Lc2n6t+pXyus4gOvmtwxd 5p9RkUV4Ud6dpnb3iwkNhuaV4YeD0LN+iF4Zd2CFwDJRf0Bjt1rD7MTojzu+KhYsjXNH zfOl4GtbvFuiE97YGgUidWQ1k3QNvZlaFynQ5Fcbc3OG3RB9iyWVcwBNASWdhBDFVoYu +RLQ== 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 d3-v6si4320696pgk.610.2018.09.13.06.56.23; Thu, 13 Sep 2018 06:56:38 -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 S1731240AbeIMTEg (ORCPT + 99 others); Thu, 13 Sep 2018 15:04:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33942 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730414AbeIMTEg (ORCPT ); Thu, 13 Sep 2018 15:04:36 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 01299D1D; Thu, 13 Sep 2018 13:54:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jean-Tsung Hsiao , Jesper Dangaard Brouer , Yonghong Song , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.18 068/197] samples/bpf: all XDP samples should unload xdp/bpf prog on SIGTERM Date: Thu, 13 Sep 2018 15:30:17 +0200 Message-Id: <20180913131844.238179718@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jesper Dangaard Brouer [ Upstream commit 817b89beb9d8876450fcde9155e17425c329569d ] It is common XDP practice to unload/deattach the XDP bpf program, when the XDP sample program is Ctrl-C interrupted (SIGINT) or killed (SIGTERM). The samples/bpf programs xdp_redirect_cpu and xdp_rxq_info, forgot to trap signal SIGTERM (which is the default signal used by the kill command). This was discovered by Red Hat QA, which automated scripts depend on killing the XDP sample program after a timeout period. Fixes: fad3917e361b ("samples/bpf: add cpumap sample program xdp_redirect_cpu") Fixes: 0fca931a6f21 ("samples/bpf: program demonstrating access to xdp_rxq_info") Reported-by: Jean-Tsung Hsiao Signed-off-by: Jesper Dangaard Brouer Acked-by: Yonghong Song Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- samples/bpf/xdp_redirect_cpu_user.c | 3 ++- samples/bpf/xdp_rxq_info_user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/samples/bpf/xdp_redirect_cpu_user.c +++ b/samples/bpf/xdp_redirect_cpu_user.c @@ -679,8 +679,9 @@ int main(int argc, char **argv) return EXIT_FAIL_OPTION; } - /* Remove XDP program when program is interrupted */ + /* Remove XDP program when program is interrupted or killed */ signal(SIGINT, int_exit); + signal(SIGTERM, int_exit); if (bpf_set_link_xdp_fd(ifindex, prog_fd[prog_num], xdp_flags) < 0) { fprintf(stderr, "link set xdp fd failed\n"); --- a/samples/bpf/xdp_rxq_info_user.c +++ b/samples/bpf/xdp_rxq_info_user.c @@ -534,8 +534,9 @@ int main(int argc, char **argv) exit(EXIT_FAIL_BPF); } - /* Remove XDP program when program is interrupted */ + /* Remove XDP program when program is interrupted or killed */ signal(SIGINT, int_exit); + signal(SIGTERM, int_exit); if (bpf_set_link_xdp_fd(ifindex, prog_fd, xdp_flags) < 0) { fprintf(stderr, "link set xdp fd failed\n");